Hi Guys,
I am developing a script to monitor GUI based FileNet Component "Component Manager" which logs it's running status in a log file.
Log file is a huge file so in script I put last 300 lines of log file in seperate file and run script every 5 minutes.
I am searching the string "Component Manager stopped" in the below shown log file output.
My requirement is -
If string "Component Manager stopped" is found in log file, a simple file should generate which will be taken by the tivoli alert as tivoli alert input and alert will generate.
Problem faced by me -
I am finding it difficult to handle multiple entries of string "component manager stopped" also I just want the latest entry to be monitored and if once monitored the same alert should not be alerted again .
Log file shows following error message when the component manager stops .
-----------------------------------------------------------------
pe.txt.2012-03-28:2012/03/28 00:57:48 [RMI TCP Connection(536)-10.87.130.42] INFO filenet.vw.ComponentIntegrator Component Manager stopped.
pe.txt.2012-03-28:2012/03/28 00:57:48 [RMI TCP Connection(536)-10.87.130.42] INFO filenet.vw.ComponentIntegrator Component Manager stopped.
------------------------------------------------------------------
Script Description -
In my script , I am searching for string from bottom to top in log file to get latest alert only and if entry found take it's time stamp save it in text file , compare the time stamp with current time stamp ..if it matches then do not generate alert but if it does not match , generate alert ..
Script code -
#!/bin/ksh
tail -300 pe_1.txt > msgtime.txt
head -1 newfile.txt | sed 's/://g' | read temp
tac msgtime.txt | grep "Component Manager stopped" msgtime.txt | while read line
do
awk '{ print $2}' | sed 's/://g' | read msgtime
done
test $temp -eq $msgtime
if [ $? -eq 0 ]; then
echo "tivoli already generated"
else
echo "$msgtime" > newfile.txt
touch $msgtime.txt ComponentManagerDown_on_`hostname`.txt
fi
kindly help for any modifications required as the script does not give the result intended .