On Wed, Oct 12, 2005 at 11:08:49AM -0400, Ed Ravin wrote: ... > I also contributed a few fixes to the alerts that don't seem to > be in mon-1-1-0pre2 - none of the alerts knew about the options for the > new forms of alerts (like ackalerts and trapalerts). Here are my local > patches to snpp.alert:
Oh, but just ignore that last patch set, that's totally the wrong one. I'm surprised no one tweaked me on it - maybe no one ever reads my mail all the way down to the bottom? Anyway, I've attached a patch set that demonstrates the problem. Note the extra options I added for the new alert types, the verbose descriptions of the alarms more worthy of an IBM operating system manual than a nifty project like Mon, and the addition of the monitor description (very handy for reminding folks about what broke, and you can put a hint as to how to fix it in the description field in mon.cf), and the last monitor output (which will only work if you commit the fix I submitted in my previous email). This patch is against my custom copy of "mail.alert", so it won't apply directly to any of the regular alerts, but you get the idea. -- Ed
--- mymail.alert 2005/04/27 21:18:48 1.1 +++ mymail.alert 2005/10/21 20:46:10 @@ -8,7 +8,7 @@ # By Ed Ravin, [EMAIL PROTECTED], based on the mail.alert by Jim Trocki # in mon-0.38.18 -# $Header: /devel/build/NetBSD/mon/mon-1.1-devel/mon/alert.d/RCS/mymail.alert,v 1.1 2005/04/27 21:18:48 root Exp $ +# $Header: /devel/build/NetBSD/mon/mon-1.1-devel/mon/alert.d/RCS/mymail.alert,v 1.4 2005/10/21 20:46:03 root Exp $ # # This program is free software; you can redistribute it and/or modify @@ -25,11 +25,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -$RCSID='$Id: mymail.alert,v 1.1 2005/04/27 21:18:48 root Exp $'; +$RCSID='$Id: mymail.alert,v 1.4 2005/10/21 20:46:03 root Exp $'; use Getopt::Std; use Text::Wrap; -getopts ("S:s:g:h:t:l:u"); +getopts ("S:s:g:h:t:l:aDTOu"); $summary=<STDIN>; chomp $summary; @@ -39,16 +39,34 @@ $mailaddrs = join (',', @ARGV); $t = localtime($opt_t); -$failtime= $ENV{MON_FIRST_FAILURE}; +$failtime= $ENV{'MON_FIRST_FAILURE'}; $downtime= time - $failtime; +$desc= $ENV{'MON_DESCRIPTION'} || ""; + if ($opt_u) { $ALERT = "UPALERT"; $downmsg="Service is back up, was down for $downtime seconds."; +} elsif ($opt_a) { + $ALERT= "ACKALERT"; + $downmsg= "Problem has been acknowledged: $summary\n" . + "Last error output: $ENV{'MON_LAST_SUMMARY'}"; +} elsif ($opt_D) { + $ALERT= "DISABLEALERT"; + $downmsg= + "A host in this group has been disabled. The monitoring system will show" . + "successful recovery even if that host's service is still down."; +} elsif ($opt_T) { + $ALERT= "TRAPALERT"; + $downmsg= "A trap has been received for this service."; +} elsif ($opt_O) { + $ALERT= "TRAPTIMEOUTALERT"; + $downmsg= "A heartbeat trap has failed to arrive for this service."; } else { $ALERT= "ALERT"; $t= localtime($failtime); $downmsg= "Down for $downtime seconds"; + $downmsg .= "\n\nNotes: $desc\n" if length($desc); } ($wday,$mon,$day,$tm) = split (/\s+/, $t); @@ -78,13 +96,13 @@ Detailed text (if any) follows: ------------------------------- + EOF # # The remaining lines normally contain more detailed information, # but this is monitor-dependent. # -while (<STDIN>) { - print MAIL; -} + +print MAIL $ENV{'MON_LAST_OUTPUT'}; close (MAIL);
_______________________________________________ mon mailing list mon@linux.kernel.org http://linux.kernel.org/mailman/listinfo/mon