Hi,
I have a perl script that came with SNIPS network monitoring that takes
lines of a log file and parses them to create variables to be used to
send pager alerts. It works as I like until I want to add that last
variable, then it completely breaks.
Log file line ( This is all on one line if the log):
Sun Jul 26 01:37:03 1998 [ippingmon]: \
DEVICE Test-Device xxx.xxx.xxx.xxx VAR ICMP-ping 0 3 Pkts \
LEVEL Critical LOGLEVEL Critical STATE down
Working version (without STATE):
if ($#ARGV >= 0) { $PAGETO = $ARGV[0]; }
while (<STDIN>)
{
if(/.+\[(\S+)\]:\s+SITE|DEVICE\s+(\S+.+)\s+LEVEL\s+(\S+)\s+LOGLEVEL\s+(\
S+)\s+
..+$/)
{
# print "Sender=$1, Device=$2, Level=$3, Loglevel=$4
next if ($3 =~ /Info/ || /Critical/);
&sendmail2 ($1,$2,$3,$4,$MAILTO) ;
}
}
Non working version trying to add the STATE: if ($#ARGV >= 0) { $PAGETO
= $ARGV[0]; }
if ($#ARGV >= 0) { $PAGETO = $ARGV[0]; }
while (<STDIN>)
{
if(/.+\[(\S+)\]:\s+SITE|DEVICE\s+(\S+.+)\s+LEVEL\s+(\S+)\s+LOGLEVEL\s+(\
S+)\s+
STATE\s+(\S+.+)\s+.+$/)
{
# print "Sender=$1, Device=$2, Level=$3, Loglevel=$4, State=$5
next if ($4 =~ /Info/ || /Critical/);
&sendmail2 ($1,$2,$3,$4,$5,$MAILTO) ;
}
}