Operating System - HP-UX
1827730 Members
2953 Online
109968 Solutions
New Discussion

Re: Help needed: scripting

 
Sunil Sharma_1
Honored Contributor

Help needed: scripting

Hi,

I don't know the scripiting.

I want to write a script which moitor syslog.log file and when a perticular message appear It send alert to me.

I get exit code in syslog.log so whenever exit code is not equal to zero i should get alert.

Thanks in advance

Sunil
*** Dream as if you'll live forever. Live as if you'll die today ***
2 REPLIES 2
Elmar P. Kolkman
Honored Contributor

Re: Help needed: scripting

Well, it depends on how the line looks in your syslog and how you want to be alerted, but it will look something like this, I guess. Just change the grep-pattern and the alert command.

tail -f /var/adm/syslog/syslog.log |grep 'exitcode!=zero' | while read line
do
alert sunil $line
done
Every problem has at least one solution. Only some solutions are harder to find.
Sanjay Kumar Suri
Honored Contributor

Re: Help needed: scripting

Have a look at this:

http://www.unixguide.net/scripts/nightowl

Bit lenghty (and may be risky).

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.