script for e-mail notification of a matching syslog message
Posted on 2011-03-04
I am looking for a simple bash script that can send me e-mail notification every time a matching text pattern in the syslog is found.
basically from a continuously running : tail -f Syslog > some.program
then somewhere in some.program, there should be a text match string like:
and a command like:
./mailx -s "Alert: Interface down" email@example.com </dev/null.
The message need not have any body, just a subject will be fine.
Finally, I want the script to exit gracefully after the FIRST grep match of the match string so that it doesn´t generate hundreds of e-mails everytime it seems the same message in the syslog.
Could someone assist me setting up such a script?
Thanks very much.