How to tell who is primary?

Alan Robertson alanr@unix.sh
Mon, 04 Nov 2002 10:40:42 -0700


John Sutton wrote:
> Hi
> 
> I'm writing rsync scripts to handle synchronisation of filesystems and I
> need to know whether the node the script is running on is currently
> primary or secondary (I'm using nice_failback in an active/standby
> configuration).
> 
> Of course, I can grep it out of ifconfig but I'm wondering if there is a
> proper (undocumented?) way to do it?

Not really.  The CVS versions allow your script to create files in 
/var/lib/heartbeat/rsctmp.  This directory is cleaned out each time 
heartbeat is restarted.  If you look, you'll see that the current IPaddr 
script does this to track aliases and eliminate race conditions.

So, you could keep some kind of resource state file there and use it. 
Heartbeat doesn't actually have a concept of primary or secondary.

	-- Alan Robertson
	   alanr@unix.sh