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 02:46:22 -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:
      Tag: STABLE_1_2
        ldirectord 


Log Message:
Add Daemon Status

Keep track of the status of the daemon.
Currently one of: starting, running, stopping, reloading

Backport of 1.173 (ldirectord.cf 1.29)

Signed-Off-By: Simon Horman <[EMAIL PROTECTED]>

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/Attic/ldirectord,v
retrieving revision 1.77.2.76
retrieving revision 1.77.2.77
diff -u -3 -r1.77.2.76 -r1.77.2.77
--- ldirectord  15 Aug 2006 08:44:43 -0000      1.77.2.76
+++ ldirectord  15 Aug 2006 08:46:21 -0000      1.77.2.77
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.77.2.76 2006/08/15 08:44:43 horms Exp 
$)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.77.2.77 2006/08/15 08:46:21 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 = "/usr/sbin/ldirectord";
 }
 $LDIRLOG          = "/var/log/ldirectord.log";
-$LD_TERM_CALLED   = 0;
 $NEGOTIATETIMEOUT = 0;
 $RUNPID           = "/var/run/ldirectord";
 $SUPERVISED       = "no";
@@ -600,12 +607,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");
@@ -788,12 +795,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();
@@ -815,6 +822,7 @@
 {
        @OLDVIRTUAL = @VIRTUAL;
        my %OLD_INSTANCE = %LD_INSTANCE;
+       $DAEMON_STATUS = $DAEMON_STATUS_RELOADING;
        eval {
                &read_config();
                my %NEW_INSTANCE = %LD_INSTANCE;
@@ -837,6 +845,7 @@
                @VIRTUAL = @OLDVIRTUAL;
                %LD_INSTANCE = %OLD_INSTANCE;
        }
+       $DAEMON_STATUS = $DAEMON_STATUS_RUNNING;
        undef @OLDVIRTUAL;
 }
 
@@ -1529,7 +1538,7 @@
        }
        $msg = "$msg_prefix: $msg";
 
-       if ($opt_d or $initializing==1) {
+       if ($opt_d or $DAEMON_STATUS == $DAEMON_STATUS_STARTING) {
                print STDERR $msg;
        } 
        else {
@@ -1551,7 +1560,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 02:47:23 -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:
      Tag: STABLE_1_2
        ldirectord 


Log Message:
Add daemon status to body of email alerts

Backport of 1.174 (ldirectord.in 1.30)

Signed-Off-By: Simon Horman <[EMAIL PROTECTED]>

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/Attic/ldirectord,v
retrieving revision 1.77.2.77
retrieving revision 1.77.2.78
diff -u -3 -r1.77.2.77 -r1.77.2.78
--- ldirectord  15 Aug 2006 08:46:21 -0000      1.77.2.77
+++ ldirectord  15 Aug 2006 08:47:23 -0000      1.77.2.78
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.77.2.77 2006/08/15 08:46:21 horms Exp 
$)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.77.2.78 2006/08/15 08:47:23 horms Exp 
$)[2];
 
 ######################################################################
 # ldirectord                 http://www.vergenet.net/linux/ldirectord/
@@ -3164,6 +3164,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
@@ -3207,7 +3225,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 02:48:57 -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:
      Tag: STABLE_1_2
        ldirectord ldirectord.cf 


Log Message:
Add emailalertstatus

Filter sending emailalerts based on the daemon's status

Backport of 1.176 (ldirectord.in 1.32)

Signed-Off-By: Simon Horman <[EMAIL PROTECTED]>

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/Attic/ldirectord,v
retrieving revision 1.77.2.78
retrieving revision 1.77.2.79
diff -u -3 -r1.77.2.78 -r1.77.2.79
--- ldirectord  15 Aug 2006 08:47:23 -0000      1.77.2.78
+++ ldirectord  15 Aug 2006 08:48:57 -0000      1.77.2.79
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.77.2.78 2006/08/15 08:47:23 horms Exp 
$)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.77.2.79 2006/08/15 08:48:57 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";
@@ -545,6 +564,7 @@
 $QUIESCENT        = "yes";
 $EMAILALERT      = "";
 $EMAILALERTFREQ          = 0;
+$EMAILALERTSTATUS = $DAEMON_STATUS_ALL;
 
 $CRLF = "\x0d\x0a";
 
@@ -849,6 +869,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
 {
@@ -1056,6 +1120,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 
$_");
                                }
@@ -1166,6 +1232,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, 
@@ -3199,6 +3267,7 @@
        my $frequency;
        my $virtual_str;
        my $id;
+       my $statusfilter;
 
        $virtual_str = &get_virtual($v);
        $id = "$rserver ($virtual_str)";
@@ -3211,6 +3280,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;
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord.cf,v
retrieving revision 1.19.2.12
retrieving revision 1.19.2.13
diff -u -3 -r1.19.2.12 -r1.19.2.13
--- ldirectord.cf       15 Aug 2006 08:30:08 -0000      1.19.2.12
+++ ldirectord.cf       15 Aug 2006 08:48:57 -0000      1.19.2.13
@@ -17,6 +17,7 @@
 #logfile="local0"
 #emailalert="[EMAIL PROTECTED]"
 #emailalertfreq=3600
+#emailalertstatus=all
 quiescent=yes
 
 # Sample for an http virtual service




------------------------------

_______________________________________________
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 57
********************************************

Reply via email to