Operating System - HP-UX
1833174 Members
2965 Online
110051 Solutions
New Discussion

Re: Script to check for certain error message in logs

 
SOLVED
Go to solution
Hunki
Super Advisor

Script to check for certain error message in logs


I have to check for an error message : "many connections" in a log file on the system.And if that error occurs then mail me immediately. How can I achieve this.

grep "many connections" /home/jb/log/ser.log

thanks,

hunki
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script to check for certain error message in logs

Hi Hunki:

# grep -q "many connections" /home/jb/log/ser.log && mailx -s "Alert!!!" root < /dev/null

See the manpages for more information. This is a "quiet" grep. If the return code is zero (one or matches found), then a mail is generated.

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: Script to check for certain error message in logs

Shalom Hunki,

I've posted scripts like that very often.

grep "error message" /var/adm/syslog/syslog.log

You can do a count

number=(grep "error message" /var/adm/syslog/syslog.log | wc =l)

echo $number

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Hunki
Super Advisor

Re: Script to check for certain error message in logs

Thanks James , SEP.

hunki