Robin Brown wrote:
> 
> Hi,

Hello,

> 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):
> 
> [snip code]
> 
> 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) ;
>   }
> }


$PAGETO = $ARGV[0] if @ARGV;

while ( <STDIN> ) {
    if( /\[                 (\S+)]:\s+     # sender
         (?:SITE|DEVICE)\s+ (\S.+\S)\s+
         LEVEL\s+           (\S+)\s+
         LOGLEVEL\s+        (\S+)\s+
         STATE\s+           (\S+)\s*
         $/x ) {

        # print "Sender=$1, Device=$2, Level=$3, Loglevel=$4, State=$5
        next if $4 eq 'Info' || $4 eq 'Critical';
        sendmail2( $1, $2, $3, $4, $5, $MAILTO );
    }
}



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to