#!/usr/local/bin/perl ## ### ### This script reads the page.log file, formats the data, and sends it ### to the nco_p_data FIFO for use by the pmgrd process. ### ### April 2, 2004 ### Added space for message and date to be seperate # # use File::Tail; # Preset variables my $LogFile="/opt/app/bmc/PATROL3.5/lib/psl/EMProg/CEM/page.log"; # my $PipeName="/opt/app/PatrolAdmin/docs/eventmgr/pipes/nco_p_data"; # my $fi=tie *FH,"File::Tail",(name=>$LogFile,reset_tail=>0); ### If told to stop kill process and not restart if ($ARGV[0] eq "stop"){ @procs=`ps -ef \| grep eventFIFO \| grep -v grep | grep -v $$`; foreach $line (@procs){ $line =~ /\w+\s+(\d+)\s/; $pid = $1; system(`kill $pid`); } exit 0; } unless( -p $PipeName) { unlink $PipeName; system("mkfifo -m 644 $PipeName") && die "Can't mkfifo $PipeName: $!"; } while (FH) { $line = $fi->read; if($line =~ /(.*)\|~\|(.*)\|~\|([\W\w]+)\|~\|(.*)/) { $contline=""; $PagerID=$1; $Message=$2." ".$3; $Status=$4; } else { $contline=$contline.$line; if($contline =~ /(.*)\|~\|(.*)\|~\|([\w\W]+)\|~\|(.*)/) { $contline=""; $PagerID=$1; $Message=$2." ".$3; $Status=$4; $contline=""; } else { next; } } open(FIFO,">$PipeName") || die "Couldn't open file $PipeName - $!\n"; print FIFO "NEW|TODAY|NOW|\"\"|$PagerID|$Message|$Status\n"; close(FIFO); }