track the errors in log file

OS: SuSE Linux Enterprise Server 10

Goal:
To track the errors in log file, If they exits users will be notify by email.

We have a script below:

SrchKey="SRVE0242I:"
LogFile=/PATHtemOut.log
MailTo="DN@mail.com
http:// ! -f PATH/alert.last  && touch PATH/alert.last
egrep $SrchKey $LogFile > PATH/alert.new
if http:// -s PATH/alert.new  ;then
diff PATH/alert.new PATH/alert.last > PATH/alert.msg
cp PATH/alert.new PATH/alert.last
http:// -s PATH/alert.msg  &&
mailx -v -s "$SrchKey Alert" $MailTo < PATH/alert.msg
else
echo "Nothing to report, sir." | mailx -s "No Alert Today" ${MailTo}
fi

OUT PUT:

Received email
Subject:SRVE0242I: Alert

Message: "1d0
< Binary file /PATH/log/SystemOut.log matches"

1) We have multiple error messages,
how to add more messages in the script?

2) If one of the message does not exits we should receive message for other existing error code or messages.

thanks
D

Any feedback will be appreciated

You will need to define the serach parameters/error code and repeat the same you already have. Try using the extended RE.

example:

egrep "one|two|three" filename > msg

[ will grep for the strings one or two or three etc]

so code will be as below:

SrchKey="SRVE0242I:| error| hang"
LogFile=/PATHtemOut.log
MailTo="DN@mail.com
http:// ! -f PATH/alert.last && touch PATH/alert.last
egrep $SrchKey $LogFile > PATH/alert.new
if http:// -s PATH/alert.new ;then
diff PATH/alert.new PATH/alert.last > PATH/alert.msg
cp PATH/alert.new PATH/alert.last
http:// -s PATH/alert.msg &&
mailx -v -s "$SrchKey Alert" $MailTo < PATH/alert.msg
else
echo "Nothing to report, sir." | mailx -s "No Alert Today" ${MailTo}
fi