#!/usr/local/bin/perl
#
# THIS IS JUST A SAMPLE SCRIPT. Modify before using.
#
# Pipe the output of noclogd into this script and send yourself email or
# whatever else is required to send a page to yourself.
#
# sample log line:
#
#  Sun Jul 26 01:37:03 1998 [ippingmon]: \
#	SITE rabbinical-FR-p 206.137.132.146 VAR ICMP-ping 0 3 Pkts \
#	LEVEL Critical LOGLEVEL Critical NOCOP down
#
#	-vikas@navya.com
#

$PAGETO = "harry" ;
$PAGEPROG = "/usr/local/bin/sendpage"; 	# or mail

if ($#ARGV >= 0) { $PAGETO = $ARGV[0]; }

while (<STDIN>)
{
  if(/.+\[(\S+)\]:\s+SITE\s+(\S+.+)\s+LEVEL\s+(\S+)\s+LOGLEVEL\s+(\S+)\s+.+$/)
  {
    # print "Sender=$1, Device=$2, Level=$3, Loglevel=$4
    next if ($3 =~ /Info/);
    if ($2 =~ /CoreGateway/)	# sitename as well as site address
    {
      system ($PAGEPROG, "nocol $2 $3", $PAGETO) ;
    }
  }
}

exit 0;
