<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Alert on Simon Žekar — unix, communications, stupidities</title><link>https://simon.zekar.com/tags/alert/</link><description>Recent content in Alert on Simon Žekar — unix, communications, stupidities</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 04 Feb 2009 22:53:24 +0000</lastBuildDate><atom:link href="https://simon.zekar.com/tags/alert/index.xml" rel="self" type="application/rss+xml"/><item><title>swatch – alerting you of certain log entries</title><link>https://simon.zekar.com/2009/02/04/swatch-log-monitor/</link><pubDate>Wed, 04 Feb 2009 22:53:24 +0000</pubDate><guid>https://simon.zekar.com/2009/02/04/swatch-log-monitor/</guid><description>&lt;p>A few minutes before coding my own &lt;a href="http://www.perl.org/">perl&lt;/a> script, which would alert me on certain log entries, I’ve found a software which does it’s job very well.&lt;/p>
&lt;p>It’s called &lt;a href="http://swatch.sourceforge.net/">swatch&lt;/a> – yes, really impressing web site and lack of documentation, examples is tipical for a geek’s tool.&lt;/p>
&lt;p>example config – very simple:&lt;/p>
&lt;pre tabindex="0">&lt;code>watchfor /Security violation occurred/
mail addresses=ninja@level13.org,subject=&amp;#34;SWATCH warning - switch_name&amp;#34;
&lt;/code>&lt;/pre>&lt;p>and the command line invocation:&lt;br>
&lt;code># /usr/local/bin/swatch -c /usr/local/etc/swatch/switch_name.conf -t /var/log/syslog/switch_name.log --daemon --use-cpan-file-tail&lt;/code>&lt;/p>
&lt;p>&lt;strong>–daemon&lt;/strong> for forking it in the background&lt;/p>
&lt;p>&lt;strong>–use-cpan-file-tail&lt;/strong> is needed so that the swatch will tail file even after it’s rotated by the rotating script, but make sure that the perl module &lt;a href="http://search.cpan.org/perldoc?File::Tail">File::Tail&lt;/a> is installed&lt;/p>
&lt;p>It can of course match multiple patterns (multiple watchfor sections) on the same log file, but you must run multiple instances of the software for tailing multiple log files.&lt;/p>
&lt;p>Make sure to read &lt;a href="http://linux.die.net/man/1/swatch">swatch man page&lt;/a>.&lt;/p>
&lt;p>S.&lt;/p></description></item></channel></rss>