Unix - Shell Script for Log4j Log Analysis and exception reporting


#!/bin/ksh

EMAIL_SUBJECT="Exceptions-Log"
EMAIL_TO="xyz@yahoo.com"
`grep "xception" Out.log >> /home/xyz/test1`
`cat /home/xyz/test1 | sed -n 's/.* \([^ ]*xception[^ ]*\) .*/\1/p' | awk '!x[$0]++' >> /home/xyz/test2`

`rm test3`

while read line
do
lineNum=`sed -n "/$line/,/EST/{=;q;}" Out.log`
let bl=$lineNum-5
let el=$lineNum+15
echo "************************************************* \n $line \n ************************************************** \n\n" >> test3
`sed -n "$bl,$el p" Out.log >> test3`
echo "\n\n\n" >> test3
done < "/home/xyz/test2"

`cat test3 | /bin/mail -s $EMAIL_SUBJECT $EMAIL_TO`


Related Post -
Unix Shell Scripts for Log Monitoring , Production and Application Support.
http://www.buggybread.com/2012/03/log-monitoring-shell-script-to-send.html