Hi
I have written below log monitoring script to egrep multiple words and redirect the output to a text file and its working fine but I want to add some more below given functionality to it, which is very advance and im not very good in it, so please help if you can
- I am egrepping all the error codes, so I want rather than egrepping all error codes, I should grep for
HTTP/1.1 200
which is successful code and which ever line does not have this redirects output to output file. - ignore any line which has
/akamai/sureroute
- right now I am using cron to run this script every 5 min, so my script will send the same error again and again, so I want the script not to send the same error more than 3 times. (based on the time stamp).
- for e.g. if server goes down I do not want 1000's error messages, so if there are more than 100 error messages, script should send only 1 mail.
=====================================
find /home/bharat/ -type f -name "apache_logs.txt" |while read file
do
RESULT=$(egrep "[^0](400|401|403|404|405|406|407|408|409|410|411|412|413|414|415|416|417|418|422|425|426|428|429|431|451|500|501|502|503|504|505|511)" $file)
if [[ ! -z $RESULT ]]
then
echo "Error(s) in $file on $HOSTNAME at "$(date)": $RESULT">> email_result.txt
fi
done