Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing syslogd files

Status
Not open for further replies.

count23

MIS
Mar 20, 2003
2
US
I am pushing Cisco router logs to syslogd on a FreeBSD box. I want to be notified when high priority messages are logged. The notification would be via email. The problem I'm running into is I'm not sure how to parse the logs to find the right messages.

I am currently sending warning and higher priority logs to the same file. I could split this into 2 or more files if that will help. For instance, one file for messages I want to be alerted on and another file for everything else.

I do have some perl skills so I could probably write a script but I imagine there is already something out there that will do this for me.

If anyone has a suggestion for how this can be done I would appreciate hearing it.

Thanks in advance.
 
Something like this would probably do:

[tt]tail -1f yourlogfile | nawk '
BEGIN { getline }
/HighPriority/ {
system("echo \"" $0 "\" | mailx -s \"" $0 "\" youraddress@somewhere")
}
'&[/tt]

Obviously you could stick that in a script and run it in the background using nohup or similar. "HighPriority" is some string that matches something in your high priority messages. I had to use nawk on Solaris, you may get away with just awk on your OS. Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top