Hi All;
I have a log file(dynamic) which i need to monitor; the format of the log
file is as follows
#Session ID STATUS
The status can be one of the three /starting ;/loading ;/success
Example
#Session ID STATUS
ABC /started.html
XYZ /started.html
ABC /loading.html
ABC /success.html
XYZ /loading.html
MNO /started.html
XYZ /loading.html
XYZ /success.html
XYZ /started.html
XYZ /loading.html
MNO /loading.html
MNO /success.html
XYZ /success.htm
The criteria to monitor is that NO Session ID is to have more than ONE
LOADING status
I need to run a script to monitor this every growing file.
I have written a script;I request you all to provide some inputs on the code
as which is the easiest way of running it every 90 seconds
My script does a while loop for entries (all session IDS) now the question is
that the file is quite big I dont want to check the entries.Can you help me
on Varibalising the file line count with each run and then the file needs to
process only the lines which have been added.
the code is a follows
while true
do
MAIL_RECEPIENT="root"
LOGDIR="/tmp_test"
EXTENSION=`date +%Y%m%d-%s`
awk '{print $1}' $1|sort -u|while read IN;
do
grep "$IN" $1; done|grep -i -A2 "l
oading" |uniq -d > $LOGDIR/log.$EXTENSION
if [ -s $LOGDIR/log.$EXTENSION ]
then
cat $LOGDIR/log.$EXTENSION|while read SD
do
sid=`echo $SD|awk '{print $1}'`
status=`echo $SD|awk '{print $2}'`
echo "Session ID $sid has an issue.Please check"|mailx -s "Session ID $sid
having issue" $MAIL_RECIEPIENT
echo "Session ID $sid has an issue.Please check"
done
fi
sleep 90
done