Re: [Mon-devel] snpp.alert
Brought to you by:
trockij
From: Ed R. <er...@pa...> - 2005-07-22 05:12:16
|
On Thu, Jul 21, 2005 at 07:50:19PM -0700, Konstantin 'Kastus' Shchuka wrote: > I had to make the following changes to make snpp.alert work: > > --- cvsroot/mon/alert.d/snpp.alert 2004-06-08 22:18:07.000000000 -0700 > +++ cvsroot-mine/mon/alert.d/snpp.alert 2005-07-21 19:15:31.000000000 -0700 > @@ -25,7 +25,7 @@ > # $Id: snpp.alert,v 1.1.1.1 2004/06/09 05:18:07 trockij Exp $ > # > use strict; > -use vars qw /$opt_g $opt_q $opt_s $opt_t/; > +use vars qw /$opt_g $opt_q $opt_s $opt_t $opt_h $opt_l $opt_u/; > use Getopt::Std; > use Net::SNPP; > > @@ -52,7 +52,7 @@ > > my $snpp = Net::SNPP->new ($opt_q) or die; > > -$ALERT = $opt_u ? "UPALERT" : "ALERT"; > +my $ALERT = $opt_u ? "UPALERT" : "ALERT"; > > $snpp->send ( Pager => [ @ARGV ], Message => "$ALERT $opt_g/$opt_s: $summary ($wday $mon $day $tm)" ); Yeah, me too. I guess not too many people were using it. Here's my version, which adds a few more of the features that are supposed to be in all monitor scripts: @@ -47,13 +47,15 @@ my $summary = <STDIN>; chomp $summary; -my $t = localtime ($opt_t); +my $t = localtime ($opt_t || time); my ($wday,$mon,$day,$tm) = split (/\s+/, $t); my $snpp = Net::SNPP->new ($opt_q) or die; -$ALERT = $opt_u ? "UPALERT" : "ALERT"; +my $ALERT= $opt_u ? "UPALERT" : "ALERT"; +my $GROUP= $opt_g || $ENV{MON_GROUP}; +my $SERVICE= $opt_s || $ENV{MON_SERVICE}; -$snpp->send ( Pager => [ @ARGV ], Message => "$ALERT $opt_g/$opt_s: $summary ($wday $mon $day $tm)" ); +$snpp->send ( Pager => [ @ARGV ], Message => "$ALERT $GROUP/$SERVICE: $summary ($wday $mon $day $tm)" ); $snpp->quit; |