My script triggers and e-mail if keywords supplied to it were found.
Problem is if it find the same keyword continously (due to continous server errors), it triggers mails and fillup my mail box with same message (which is not required)
I want my script to NOT to send an e-mail if it finds the same keyword more than twice.
Following is my script
#!/bin/sh
TOTAL_LINES=0
DELTA=0
ERR=0
LINE_NO=`cat /sybase/B10/temp.txt`
echo $LINE_NO
TOTAL_LINES=`more /sybase/B10/ASE-15_0/install/B10.log | wc -l`
echo $TOTAL_LINES
DELTA=`expr $TOTAL_LINES - $LINE_NO`
echo $DELTA
ERR=`tail -$DELTA /sybase/B10/ASE-15_0/install/B10.log | egrep -i "infected|signal|error|warning|severity|fail|suspect|corrupt|deadlock|critical|problem|threshold|NO_LOG|logsegment|stacktrace|encountered"| grep -v "background task error"|wc -l`
echo $ERR
if [ "ERR" -gt 0 ]; then
tail -$DELTA /sybase/B10/ASE-15_0/install/B10.log | egrep -i "infected|signal|error|severity|fail|suspect|corrupt|deadlock|critical|problem|threshold|NO_LOG|logsegment|stacktrace"| grep -v "background task error" | mailx -s "Errors found in B10.log. Pls check" rajeshneemkar@gmail.com
rm /sybase/B10/temp.txt
echo "$TOTAL_LINES" >/sybase/B10/temp.txt"
fi
Any help in this regards is highly appreciated
Best Regards,
Rajesh