Hi to everyone

I've set up a heartbeat cluster (on SLES9) that acts as a front TCP connection 
redirector (stunnel +
rinetd) to two realservers.

mon (mon-0.99.2-352.1) is used on the cluster to detect service failures on the 
realservers.

I wrote myself an action script (in perl) that, when triggered by mon, rewrites 
the rinetd
configuration and HUPs the rinetd processes, effectively causing all the client 
traffic to be
redirected to the other node.

Now, the problem is that the only information I have in the action script is 
that a given hostgroup
has failed.
I already had to split up the two realservers into two hostgroups because mon 
didn't give me the
information on /what/ node inside the hostgroup has failed.
But that's not an issue, I've just made two hostgroups. As every hostgroup has 
only one node, I do
know what node has failed.

Nevertheless, the information is not sufficient, as I need to know the state of 
the other node to
decide on how to rewrite the configuration for rinetd.
e.g. we have app1 and app2 (the realservers), and mon tells my script app1 is 
dead:
- I have to know the state of app2 to decide whether I tell rinetd to forward 
to app2 or to forward
to a fallback apache on the cluster (showing some maintenance page)
- as mon doesn't give that information to my script, I decided to retrieve it 
myself using the
Mon::Client perl package

The problem is that when I run the script from the shell, it works great, but 
when mon calls the
script because it has been triggered by a realserver failure, it hangs on the 
connection.
I assume that it is related to the way mon is calling my script (blocking?).

--->8---------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use Sys::Syslog;
use Mon::Client;

eval('require("/etc/mon/rinetd-failover.cf")');
if ($@) {
        openlog('rinetd-failover', 'nowait', 'user');
        syslog('crit', "Failed to read configuration file 
/etc/mon/rinetd-failover.cf: $@");
        closelog();
        exit 1;
}

openlog('rinetd-failover', 'nowait', 'user');

my $mon = new Mon::Client(host => $main::MON_HOST, port => $main::MON_PORT);

### HANGS HERE: ###
if (! $mon->connect()) {
        syslog('crit', "failed to connect to mon on 
${main::MON_HOST}:${main::MON_PORT}");
        closelog();
        exit 1;
}

my %s = $mon->list_opstatus();
$mon->disconnect();
...
--->8---------------------------------------------------------------------------------------

Any hint, tip, idea ?

I also tried to use "depends" to have different actions triggered when either:
- app1 is down
- app2 is down
- both app1 and app2 are down
but I really didn't manage to do that (I guess that's not really possible with 
mon).
Is it ?


Thanks for any help ;)

cheers
-- 
  -o) Pascal Bleser               ATOS Worldline/Aachen(DE)
  /\\   System Architect              WLP Business Platform
 _\_v "Really, I'm not out to destroy Microsoft.  That will
just be a completely unintentional side effect."-L.Torvalds

_______________________________________________
mon mailing list
mon@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/mon

Reply via email to