This has worked for me for the last few months.  This tells me if the cameras haven't been updated in 10 minutes or if there are any files in /opt/powermonitor-notices/ (if there is then it tells me there is a power outages somewhere).<div>

<br></div><div>This doesn't help directly, but perhaps consider monitor one directory which contains the latest backup and then rotates them out of it.<br><div><br></div><div>client-local.cfg:</div><div><div>[<a href="http://FOOBAR.imaginenetworksllc.com">FOOBAR.imaginenetworksllc.com</a>]</div>

<div>file:/var/www/inxwireless/network/output.png</div><div>file:/var/www/inxwireless/BARFF/outage.png</div><div>file:/var/www/inxwireless/images/officecam.jpg</div><div>file:/var/www/inxwireless/images/gf36cam.jpg</div>
<div>
file:`ls -1 /opt/powermonitor-notices/*`</div><div><br></div><div>hobbit-clients.cfg:</div><div><div>HOST=<a href="http://FOOBAR.imaginenetworksllc.com">FOOBAR.imaginenetworksllc.com</a></div><div>        PROC    httpd 1 -1 red</div>

<div>        PROC    cron 1 -1 red</div><div>        PROC    ntpd  1 -1 red</div><div>        FILE    /var/www/inxwireless/network/output.png red mtime<600</div><div>        FILE    /var/www/inxwireless/BARFF/outage.png red mtime<600</div>

<div>        FILE    /var/www/inxwireless/images/officecam.jpg red mtime<600</div><div>        FILE    /var/www/inxwireless/images/gf36cam.jpg red mtime<600</div><div>        FILE    %/opt/powermonitor-notices/noticeofpowerfailure.* red noexist</div>

</div><div><br></div>Josh Luthman<br>Office: 937-552-2340<br>Direct: 937-552-2343<br>1100 Wayne St<br>Suite 1337<br>Troy, OH 45373<br>
<br><br><div class="gmail_quote">On Mon, Oct 8, 2012 at 2:38 PM, Don Kuhlman <span dir="ltr"><<a href="mailto:Don.Kuhlman@schawk.com" target="_blank">Don.Kuhlman@schawk.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi folks. I'm posting this to the list as a summary of what was done so<br>
that it's all in one place.  Hopefully, this may help others trying to do<br>
the same thing.  Much thanks to Larry B, Ryan N, Cynthia R, and Jeremy L<br>
for their input on this problem.<br>
<br>
Question:  How do I monitor if a file is less than 24 hours old in a Linux<br>
Directory and alert if none are found using Xymon?<br>
Purpose:  To validate that SQL Backups are running by checking for<br>
existence of a SQL dump file being created daily by a cron job at various<br>
times.<br>
<br>
Description:  We run cron jobs to do mysql dumps on various hosts every<br>
morning at 00:05 and 00:10 am.<br>
We also run a cron job at 00:15 to delete files older than 8 days. Not<br>
doing any monitoring for this event though.<br>
<br>
Requirement: We need to have our Xymon server monitor the directories and<br>
alert/email if there has not been a new file created within the past 24<br>
hours.  There can be more than one file created since there can be more<br>
than one database on a host.  This results in us needing to search for<br>
multiple files in the same directories with the same timestamp requirement<br>
being < 24 hour old.<br>
<br>
Logic - We use the Xymon agent to check a directory for a file that is<br>
created with a name of ???????_backup.YYYYmmdd.sql<br>
There may be more than one file created during each dump. So we need to<br>
look for any file that matches the date value.<br>
Our logic is that in order to verify our dumps are working, we should<br>
always see new files that are less than 24 hours old in the target<br>
directories. We will use Xymon to watch for specific files and alert if<br>
the file doesn't exist.<br>
This is done using a combination of a find command in the<br>
client-local.cfg, a regex in the analysis.cfg, and the corresponding<br>
alerts.cfg to send the email to the right people.<br>
<br>
Here are the values we used in our Xymon configurations to check for files<br>
and then only return two entries to the analysis engine, and alert if<br>
either of these two files are older than 24 hours. That would signal to us<br>
that a dump did not occur the night before.<br>
<br>
Client-local.cfg<br>
# This will cause the Xymon client agent to do a find command on the<br>
directory /Volumes/MySQL_Backups for any file ending in<br>
# .sql. It will pipe the output to the sort command to reverse the order<br>
(eg newest files on top) and then return only the<br>
# first two lines of the results sorted by the YYYYmmdd values and not the<br>
first part of the filename.<br>
<br>
[hostservernamegoeshere]<br>
file:`find /Volumes/MySQL_Backups/ -name '*.sql' |sort -r  -t"_" -k3 -k1<br>
-k2 | head -2`<br>
<br>
This returns two files as below because they are the newest files found:<br>
/Volumes/MySQL_Backups/mysql_backup_20120923.sql - file date/time Sept 23<br>
2012 00:10<br>
/Volumes/MySQL_Backups/othersql_backup_20121008.sql - file date/time Oct 8<br>
2012 00:10<br>
<br>
<br>
<br>
Analysis.cfg<br>
<br>
<br>
# This will cause the Xymon analysis engine to look at the results (from<br>
above) for this host and<br>
# if either of the two files returned have a modified time greater than 24<br>
hours it will create a red alert condition.<br>
HOST=hostservernamegoeshere<br>
FILE %/Volumes/MySQL_Backups/.*\.sql red mtime<86400<br>
<br>
Alerts.cfg<br>
# This line will send an email to the recipient when the Xymon analysis<br>
engine creates a files event for this host<br>
# it will send it every 5 minutes using a custom perl email script<br>
HOST=hostservernamegoeshere SERVICE=files<br>
script /usr/lib64/xymon/server/ext/<a href="http://html_mail.pl" target="_blank">html_mail.pl</a> <a href="mailto:alertrecipient@company.com">alertrecipient@company.com</a><br>
FORMAT=TEXT REPEAT=5m<br>
<br>
<br>
<br>
Here is the resulting xymon webpage alert and email if either of the two<br>
files does NOT exist:<br>
<br>
red Mon Oct  8 11:22:43 CDT 2012 - Files NOT ok<br>
<br>
 /Volumes/Backups/MySQL_Backups/mysql_backup_20120923.sql<br>
CLIENT=hostservernamegoeshere&SECTION=file:/Volumes/MySQL_Backups/mysql_bac<br>
kup_20120923.sql><br>
File was modified 850245 seconds ago - should be <86400<br>
<br>
<br>
Green Mon Oct 8 11:22:43 CDT 2012 - File OK<br>
 /Volumes/Backups/MySQL_Backups/othersql_backup_20121008.sql<br>
CLIENT=twist01_dev&SECTION=file:/Volumes/MySQL_Backups/othersql_backup_2012<br>
1008.sql><br>
<br>
<br>
<br>
Don K<br>
<br>
<br>
_______________________________________________<br>
Xymon mailing list<br>
<a href="mailto:Xymon@xymon.com">Xymon@xymon.com</a><br>
<a href="http://lists.xymon.com/mailman/listinfo/xymon" target="_blank">http://lists.xymon.com/mailman/listinfo/xymon</a><br>
</blockquote></div><br></div></div>