Send Linux-ha-cvs mailing list submissions to linux-ha-cvs@lists.linux-ha.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Linux-ha-cvs digest..." Today's Topics: 1. Linux-HA CVS: ldirectord by horms from (linux-ha-cvs@lists.linux-ha.org) 2. Linux-HA CVS: ldirectord by horms from (linux-ha-cvs@lists.linux-ha.org) 3. Linux-HA CVS: ldirectord by horms from (linux-ha-cvs@lists.linux-ha.org) ---------------------------------------------------------------------- Message: 1 Date: Tue, 15 Aug 2006 01:17:06 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: ldirectord by horms from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : horms Host : Project : linux-ha Module : ldirectord Dir : linux-ha/ldirectord Modified Files: ldirectord.in Log Message: Add Daemon Status Keep track of the status of the daemon. Currently one of: starting, running, stopping, reloading Signed-Off-By: Simon Horman <[EMAIL PROTECTED]> =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord.in,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- ldirectord.in 15 Aug 2006 07:16:11 -0000 1.28 +++ ldirectord.in 15 Aug 2006 07:17:06 -0000 1.29 @@ -1,5 +1,5 @@ #!/usr/bin/perl -my($VERSION)=(qw$Id: ldirectord.in,v 1.28 2006/08/15 07:16:11 horms Exp $)[2]; +my($VERSION)=(qw$Id: ldirectord.in,v 1.29 2006/08/15 07:17:06 horms Exp $)[2]; ###################################################################### # ldirectord http://www.vergenet.net/linux/ldirectord/ @@ -487,7 +487,6 @@ $CONNECTTIMEOUT $LDIRECTORD $LDIRLOG - $LD_TERM_CALLED $NEGOTIATETIMEOUT $RUNPID $CHECKTIMEOUT @@ -505,7 +504,11 @@ $SUPERVISED $IPVSADM $checksum - $initializing + $DAEMON_STATUS + $DAEMON_STATUS_STARTING + $DAEMON_STATUS_RUNNING + $DAEMON_STATUS_STOPPING + $DAEMON_STATUS_RELOADING $opt_d $opt_h $pid @@ -520,6 +523,11 @@ $CRLF ); +$DAEMON_STATUS_STARTING = 0x1; +$DAEMON_STATUS_RUNNING = 0x2; +$DAEMON_STATUS_STOPPING = 0x4; +$DAEMON_STATUS_RELOADING = 0x8; + # default values $AUTOCHECK = "no"; $CHECKINTERVAL = 10; @@ -531,7 +539,6 @@ $LDIRECTORD = "@sbindir@/ldirectord"; } $LDIRLOG = "/var/log/ldirectord.log"; -$LD_TERM_CALLED = 0; $NEGOTIATETIMEOUT = 0; $RUNPID = "/var/run/ldirectord"; $SUPERVISED = "no"; @@ -609,12 +616,12 @@ exec_wrapper($0, @OLD_ARGV); } -$initializing = 1; +$DAEMON_STATUS = $DAEMON_STATUS_STARTING; ld_init(); ld_setup(); ld_start(); ld_cmd_children("start", %LD_INSTANCE); -$initializing = 0; +$DAEMON_STATUS = $DAEMON_STATUS_RUNNING; ld_main(); &ld_rm_file("$RUNPID.$CFGNAME.pid"); @@ -797,12 +804,12 @@ sub ld_handler_term { my ($signal) = (@_); - if ($LD_TERM_CALLED){ + if ($DAEMON_STATUS == $DAEMON_STATUS_STOPPING) { $SIG{'__DIE__'} = "IGNORE"; $SIG{"$signal"} = "IGNORE"; die("Exit Handler Repeatedly Called\n"); } - $LD_TERM_CALLED = 1; + $DAEMON_STATUS = $DAEMON_STATUS_STOPPING; ld_cmd_children("stop", %LD_INSTANCE); ld_stop(); @@ -824,6 +831,7 @@ { @OLDVIRTUAL = @VIRTUAL; my %OLD_INSTANCE = %LD_INSTANCE; + $DAEMON_STATUS = $DAEMON_STATUS_RELOADING; eval { &read_config(); my %NEW_INSTANCE = %LD_INSTANCE; @@ -846,6 +854,7 @@ @VIRTUAL = @OLDVIRTUAL; %LD_INSTANCE = %OLD_INSTANCE; } + $DAEMON_STATUS = $DAEMON_STATUS_RUNNING; undef @OLDVIRTUAL; } @@ -1538,7 +1547,7 @@ } $msg = "$msg_prefix: $msg"; - if ($opt_d or $initializing==1) { + if ($opt_d or $DAEMON_STATUS == $DAEMON_STATUS_STARTING) { print STDERR $msg; } else { @@ -1560,7 +1569,7 @@ my ($line, $msg) = @_; __config_log($line, "Error", $msg); - if ($initializing) { + if ($DAEMON_STATUS == $DAEMON_STATUS_STARTING) { &ld_rm_file("$RUNPID.$CFGNAME.pid"); &ld_exit(2, "config_error: Configuration Error"); } else { ------------------------------ Message: 2 Date: Tue, 15 Aug 2006 01:17:41 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: ldirectord by horms from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : horms Host : Project : linux-ha Module : ldirectord Dir : linux-ha/ldirectord Modified Files: ldirectord.in Log Message: Add daemon status to body of email alerts Signed-Off-By: Simon Horman <[EMAIL PROTECTED]> =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord.in,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- ldirectord.in 15 Aug 2006 07:17:06 -0000 1.29 +++ ldirectord.in 15 Aug 2006 07:17:41 -0000 1.30 @@ -1,5 +1,5 @@ #!/usr/bin/perl -my($VERSION)=(qw$Id: ldirectord.in,v 1.29 2006/08/15 07:17:06 horms Exp $)[2]; +my($VERSION)=(qw$Id: ldirectord.in,v 1.30 2006/08/15 07:17:41 horms Exp $)[2]; ###################################################################### # ldirectord http://www.vergenet.net/linux/ldirectord/ @@ -3173,6 +3173,24 @@ } +sub daemon_status_str +{ + if ($DAEMON_STATUS == $DAEMON_STATUS_STARTING) { + return "starting"; + } + elsif ($DAEMON_STATUS == $DAEMON_STATUS_RUNNING) { + return "running"; + } + elsif ($DAEMON_STATUS == $DAEMON_STATUS_STOPPING) { + return "stopping"; + } + elsif ($DAEMON_STATUS == $DAEMON_STATUS_RELOADING) { + return "reloading"; + } + return "UNKNOWN"; +} + + # ld_emailalert_send # Send email alerts per virtual server # pre: message: Message to email @@ -3216,7 +3234,9 @@ unless ($emailmsg = new Mail::Send Subject=>$subject, To=>$to_addr and $emailfh = $emailmsg->open - and print $emailfh $subject + and print $emailfh "Log-Message: $subject\n" . + "Daemon-Status: " . + &daemon_status_str() . "\n" and $emailfh->close) { &ld_log("failed to send email message\n"); $status = 1; ------------------------------ Message: 3 Date: Tue, 15 Aug 2006 01:28:45 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: ldirectord by horms from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : horms Host : Project : linux-ha Module : ldirectord Dir : linux-ha/ldirectord Modified Files: ldirectord.cf ldirectord.in Log Message: Add emailalertstatus Filter sending emailalerts based on the daemon's status Signed-Off-By: Simon Horman <[EMAIL PROTECTED]> =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord.cf,v retrieving revision 1.34 retrieving revision 1.35 diff -u -3 -r1.34 -r1.35 --- ldirectord.cf 15 Aug 2006 07:04:44 -0000 1.34 +++ ldirectord.cf 15 Aug 2006 07:28:45 -0000 1.35 @@ -17,6 +17,7 @@ #logfile="local0" #emailalert="[EMAIL PROTECTED]" #emailalertfreq=3600 +#emailalertstatus=all quiescent=yes # Sample for an http virtual service =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord.in,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- ldirectord.in 15 Aug 2006 07:17:41 -0000 1.30 +++ ldirectord.in 15 Aug 2006 07:28:45 -0000 1.31 @@ -1,5 +1,5 @@ #!/usr/bin/perl -my($VERSION)=(qw$Id: ldirectord.in,v 1.30 2006/08/15 07:17:41 horms Exp $)[2]; +my($VERSION)=(qw$Id: ldirectord.in,v 1.31 2006/08/15 07:28:45 horms Exp $)[2]; ###################################################################### # ldirectord http://www.vergenet.net/linux/ldirectord/ @@ -205,6 +205,19 @@ Default: 0 +B<emailalertstatus = >B<all>|B<none>|B<starting>|B<running>|B<stopping>|B<reloading>,... + +Comma delimited list of server states in which email alerts should be sent. +B<all> is a short-hand for +"B<starting>,B<running>,B<stopping>,B<reloading>". If B<none> is +specified, no other option may be specified, otherwise options are ored +with each other. + +If defined in a virtual server section then the global value is overridden. + +Default: all + + B<execute = ">I<configuration>B<"> Use this directive to start an instance of ldirectord for @@ -494,6 +507,7 @@ $QUIESCENT $EMAILALERT $EMAILALERTFREQ + $EMAILALERTSTATUS $CALLBACK $CFGNAME @@ -509,6 +523,7 @@ $DAEMON_STATUS_RUNNING $DAEMON_STATUS_STOPPING $DAEMON_STATUS_RELOADING + $DAEMON_STATUS_ALL $opt_d $opt_h $pid @@ -527,6 +542,10 @@ $DAEMON_STATUS_RUNNING = 0x2; $DAEMON_STATUS_STOPPING = 0x4; $DAEMON_STATUS_RELOADING = 0x8; +$DAEMON_STATUS_ALL = $DAEMON_STATUS_STARTING | + $DAEMON_STATUS_RUNNING | + $DAEMON_STATUS_STOPPING | + $DAEMON_STATUS_RELOADING; # default values $AUTOCHECK = "no"; @@ -858,6 +877,50 @@ undef @OLDVIRTUAL; } +sub parse_emailalertstatus +{ + my ($line, $arg) = (@_); + + my @s = split/\s*,\s*/, $arg; + my $none = 0; + my $status = 0; + + for my $i (@s) { + if ($i eq "none") { + $none++; + } + } + + for my $i (@s) { + if ($i eq "none") { + next; + } + elsif ($i eq "all") { + $status = $DAEMON_STATUS_ALL; + } + elsif ($i eq "starting") { + $status |= $DAEMON_STATUS_STARTING; + } + elsif ($i eq "stopping") { + $status |= $DAEMON_STATUS_STOPPING; + } + elsif ($i eq "running") { + $status |= $DAEMON_STATUS_RUNNING; + } + elsif ($i eq "reloading") { + $status |= $DAEMON_STATUS_RELOADING; + } + else { + &config_error($line, + "invalid email alert status at: \"$i\"") + } + if ($none > 0) { + &config_error($line, "invalid email alert status: " . + "\"$i\" specified with \"none\""); + } + } + return $status; +} sub read_config { @@ -1065,6 +1128,8 @@ } elsif ($rcmd =~ /^emailalertfreq\s*=\s*(\d*)/) { $1 =~ /(\d+)/ or &config_error($line, "invalid email alert frequency"); $vsrv{emailalertfreq} = $1; + } elsif ($_ =~ /^emailalertstatus\s*=\s*(.*)/) { + $vsrv{emailalertstatus} = &parse_emailalertstatus($line, $1); } else { &config_error($line, "Unknown command $_"); } @@ -1175,6 +1240,8 @@ $1 =~ /(\d+)/ or &config_error($line, "invalid email alert frequency"); $EMAILALERTFREQ = $1; + } elsif ($_ =~ /^emailalertstatus\s*=\s*(.*)/) { + $EMAILALERTSTATUS = &parse_emailalertstatus($line, $1); } else { if ($_ =~ /^timeout\s*=\s*(.*)/) { &config_error($line, @@ -3208,6 +3275,7 @@ my $frequency; my $virtual_str; my $id; + my $statusfilter; $virtual_str = &get_virtual($v); $id = "$rserver ($virtual_str)"; @@ -3220,6 +3288,12 @@ $EMAILSTATUS{$id}->{alerttime} = $currenttime; } + $statusfilter = defined $v->{emailalertstatus} ? + $v->{emailalertstatus} : $EMAILALERTSTATUS; + if (($DAEMON_STATUS & $statusfilter) == 0) { + return 0; + } + $to_addr = defined $v->{emailalert} ? $v->{emailalert} : $EMAILALERT; if ($to_addr eq "") { return 0; ------------------------------ _______________________________________________ Linux-ha-cvs mailing list Linux-ha-cvs@lists.linux-ha.org http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs End of Linux-ha-cvs Digest, Vol 33, Issue 41 ********************************************