An alarm program from the online.log
Posted in 1999
Topics: General Discussion
Hi group! I am trying to write a script that will periodically check the online log for certain events, through egrep and awk, and eventually mail and page me. I checked the alarm program in /etc and would use it, but I need the program to look at several instances across the network and figure the logs are the best place to find the information (things like out of space,CDR connections dropping etc etc). I am looking for suggestions, examples from anybody that's done this. Thanks in advance! Kevin
On Wed, 31 Mar 1999 12:02:06 -0500, Kevin <kevin_burdish@timeinc.com> wrote:
>I am trying to write a script that will periodically check the online log
>for certain events, through
>egrep and awk, and eventually mail and page me. I checked the alarm program
>in /etc and
>would use it, but I need the program to look at several instances across the
>network and figure the logs are the best place to find the information
>(things like out of space,CDR connections dropping etc etc). I am looking
>for suggestions, examples from anybody that's done this.
This is the alarm program I wrote -- It uses the Perl module SNPP to send an
alphanumeric message directly to my pager:
#!/usr/local/bin/perl
use Config;
use Net::SNPP;
my $backup_cmd = "onbar -l";
my $exit_status = 0;
my $event_severity = $ARGV[0];
my $event_class = $ARGV[1];
my $event_msg = $ARGV[2];
my $event_add_text = $ARGV[3];
my $event_file = $ARGV[4];
my $onconfig = $ENV{'ONCONFIG'};
my $hostname = $Config{'myhostname'};
my %severity = (
"3" => "Attention",
"4" => "Emergency",
"5" => "Fatal",
);
chomp $onconfig;
$database = (split /\\./, $onconfig)[1];
if ($event_class == 23) {
`$backup_cmd 2>&1 >> /dev/null`;
$exit_status = $?;
}
if ($event_severity > 2) {
$snpp = Net::SNPP->new('your.pagingservice.com'); # your paging company
$snpp->send( Pager => 8005551212, # your pager number
Message => "$severity{$event_severity}: $hostname $database $event_msg"
) or die $snpp->message;
$exit_status = 1;
$snpp->quit;
}
exit $exit_status;
--
Clay Irving
clay@panix.com