Xymon Mailing List Archive search

File monitor not working in Xymon - using file list generated by wildcard

list Don Kuhlman
Fri, 5 Oct 2012 18:12:24 +0000
Message-Id: <user-4c0b57438d1c@xymon.invalid>

Hi Larry. Thanks for the reply.

There should always be files in the directories.  The dba keeps 7 days of backups and deletes anything > 8 days old.
So, here's an update to see if anyone has other suggestions.  It's still not working.  Details on current settings for client-local.cfg and analysis.cfg are below:

Any further help or alertnative method appreciated…

Don K

client-local.cfg for mysqlserver01:
[MYSQLSERVER01]
# dir:`find /Volumes/MySQL_Backups/ -name '*.sql' -mtime 0 2>/dev/null`
# file:/Volumes/MySQL_Backups/mysql_backup_20121004.sql
file:`find /Volumes/MySQL_Backups/ -name '*.sql' 2>/dev/null | sort -r | head -1`

This returns a file with the latest timestamp -
 Fri Oct 5 12:59:57 CDT 2012 - Files ok

[green] /Volumes/MySQL_Backups/mysql_backup_20121005.sql<http://srmxymon.ambrosi.com/xymon-cgi/svcstatus.sh?CLIENT=MYSQLSERVER01&SECTION=file:/Volumes/MySQL_Backups/mysql_backup_20121005.sql>;


Clicking the link above gives this:

[file:/Volumes/MySQL_Backups/mysql_backup_20121005.sql]
type:100000 (file)
mode:644 (-rw-r--r--)
linkcount:1
owner:0 (root)
group:0 (root)
size:501060
clock:1349460427 (2012/10/05-13:07:07)
atime:1349444863 (2012/10/05-08:47:43)
ctime:1349444867 (2012/10/05-08:47:47)
mtime:1349444867 (2012/10/05-08:47:47)


From the directory listing snip below:

[root at MySQLServer01 MySQL_Backups]# ls -la
total 9933676
drwxr-xr-x 2 root root       4096 Oct  5 08:47 .
drwxrwxrwx 4 root root       4096 Oct  5 08:48 ..
-rw-r--r-- 1 root root     501060 Oct  3 00:10 mysql_backup_20121003.sql
-rw-r--r-- 1 root root     501060 Oct  4 00:10 mysql_backup_20121004.sql
-rw-r--r-- 1 root root     501060 Oct  5 08:47 mysql_backup_20121005.sql
[root at MySQLServer01 MySQL_Backups]#


I have setup analysis.cfg as below:

HOST=MYSQLSERVER01
FILE /Volumes/MySQL_Backups/mysql_backup_20121005.sql red mtime<600
# FILE %^.sql COLOR=red mtime<86400
# FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql red mtime<600
# FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql COLOR=red mtime<600
# FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql red mtime>86400
# FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql red mtime<86400
# FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql red mtime>600
# FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql mtime>86400 noexist


From: Larry Barber <user-6ef9c2864140@xymon.invalid<mailto:user-6ef9c2864140@xymon.invalid>>
Date: Fri, 5 Oct 2012 09:40:44 -0500
To: Don Kuhlman <user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid>>
Cc: Xymon Email List <xymon at xymon.com<mailto:xymon at xymon.com>>
Subject: Re: [Xymon] File monitor not working in Xymon - using file list generated by wildcard

If there will always be files in that directory you might want to consider getting rid of the -mtime argument to your find command. That way you will always get a file returned and then your mtime test in analysis.cfg will catch that the returned file, which should be the newest one in the directory thanks to  the sort,  is too old.

Thanks,
Larry Barber

On Fri, Oct 5, 2012 at 9:17 AM, Don Kuhlman <user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid>> wrote:
Thanks Ryan. Do you have any suggestions on how to get an alert if the
file doesn't exist ?  It only gives me "no files checked" when the file
isn't there.  That's okay if I can get that translated into an email that
informs someone that no file was created.

Does that make sense, or is my logic flawed ?

Don

On 10/5/12 9:08 AM, "Novosielski, Ryan" <user-ae4522577e16@xymon.invalid<mailto:user-ae4522577e16@xymon.invalid>> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'd meant there "head -1" by itself, which means "show the first
line." BTW, if you wanted to show just the last line, that would be
"tail -1".

On 10/05/2012 09:46 AM, Don Kuhlman wrote:
Thanks Cynthia, Larry, and Ryan!

I modified the client-local.cfg file as below: [MYSQLSERVER01]
file:`find /Volumes/MySQL_Backups/ -name "*.sql" -mtime 0
2>/dev/null | sort -r |head -1 --lines=1`

The webpage shows the file is present -


Fri Oct 5 08:35:16 CDT 2012 - Files ok

green /Volumes/MySQL_Backups/mysql_backup_20121005.sql

<http://srmxymon.ambrosi.com/xymon-cgi/svcstatus.sh?CLIENT=MYSQLSERVER01&;
SECTION=file:/Volumes/MySQL_Backups/mysql_backup_20121005.sql>

 If I click the link on the webpage it gives this:
[file:/Volumes/MySQL_Backups/mysql_backup_20121005.sql]

type:100000 (file) mode:644 (-rw-r--r--) linkcount:1 owner:0
(root) group:0 (root) size:501060 clock:1349444303
(2012/10/05-08:38:23) atime:1349425844 (2012/10/05-03:30:44)
ctime:1349413801 (2012/10/05-00:10:01) mtime:1349413801
(2012/10/05-00:10:01)

Next I changed the directory so no file matches the find command
and then the files icon goes white and gives me the "No files
checked" message.


Fri Oct 5 08:45:23 CDT 2012 - Files ok

No files checked

Can anyone advise how I translate that into an email to our DBA to
indicate the file doesn't exist ?

Thanks

Don K


From: "Novosielski, Ryan" <user-ae4522577e16@xymon.invalid<mailto:user-ae4522577e16@xymon.invalid>
<mailto:user-ae4522577e16@xymon.invalid<mailto:user-ae4522577e16@xymon.invalid>>> Date: Fri, 5 Oct 2012 01:33:14 -0400
To: "'user-6ef9c2864140@xymon.invalid<mailto:user-6ef9c2864140@xymon.invalid> <mailto:'user-6ef9c2864140@xymon.invalid<mailto:user-6ef9c2864140@xymon.invalid>>'"
<user-6ef9c2864140@xymon.invalid<mailto:user-6ef9c2864140@xymon.invalid> <mailto:user-6ef9c2864140@xymon.invalid<mailto:user-6ef9c2864140@xymon.invalid>>>, Don Kuhlman
<user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid> <mailto:user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid>>> Cc:
"'xymon at xymon.com<mailto:xymon at xymon.com> <mailto:'xymon at xymon.com<mailto:xymon at xymon.com>>'" <xymon at xymon.com<mailto:xymon at xymon.com>
<mailto:xymon at xymon.com<mailto:xymon at xymon.com>>> Subject: Re: [Xymon] File monitor not
working in Xymon - using file list generated by wildcard

head -1 is probably a lot more standard (I've been encountering a
lot of GNU scripts lately that have made me crazy).


*From*: Larry Barber [mailto:user-6ef9c2864140@xymon.invalid<mailto:user-6ef9c2864140@xymon.invalid>] *Sent*: Thursday,
October 04, 2012 05:39 PM *To*: Don Kuhlman <user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid>
<mailto:user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid>>> *Cc*: Xymon Email List
<xymon at xymon.com<mailto:xymon at xymon.com> <mailto:xymon at xymon.com<mailto:xymon at xymon.com>>> *Subject*: Re: [Xymon]
File monitor not working in Xymon - using file list generated by
wildcard

Perhaps if you set up your client-local.cfg entry like:

file:`find /Volumes/MySQL_Backups/ -name '*.sql' -mtime 0
2>/dev/null | sort -r | head --lines=1`

so that only the most recent file (by name) will be returned.

Thanks, Larry Barber


On Thu, Oct 4, 2012 at 4:11 PM, Don Kuhlman
<user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid> <mailto:user-5eb2bfadc6c6@xymon.invalid<mailto:user-5eb2bfadc6c6@xymon.invalid>>> wrote:

Hi folks. I've been trying to figure this out for a while and
would appreciate any help.

I'm trying to monitor for a sql backup by watching for a set of
files that are created every morning at 00:05 AM by a cron job on
a server. There are several files created each night the sql dump
runs. It creates them as filename_backup__yyyymmdd.sql So each day
there are new file names created (never the same name) I want to
alert if the file doesn't get created each day with the new name.

I have configured the client-local.cfg file as follows:
[MYSQLSERVER01] # dir:`find /Volumes/MySQL_Backups/ -name '*.sql'
-mtime 0 2>/dev/null` #
file:/Volumes/MySQL_Backups/mysql_backup_20121004.sql file:`find
/Volumes/MySQL_Backups/ -name '*.sql' -mtime 0 2>/dev/null`

Analysis.cfg is as follows: HOST=MYSQLSERVER01 FILE %^.sql
COLOR=red mtime<600 # FILE
/Volumes/MySQL_Backups/mysql_backup_20121004.sql red mtime<600 #
FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql COLOR=red
mtime<600 # FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql
red mtime>86400 # FILE
/Volumes/MySQL_Backups/mysql_backup_20121004.sql red mtime<86400 #
FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql red
mtime>600 # FILE /Volumes/MySQL_Backups/mysql_backup_20121004.sql
mtime>86400 noexist

Xymon generates this msg when I use the full filename ­ eg
mysqlbackup20121004.sql in analysis.cfg It doesn't work when I try
to use a wildcard name (which I need because the filename will
change each day) - eg FILE %^.sql

Example alert is below using full real filename:


Thu Oct 4 16:02:11 CDT 2012 - Files NOT ok

red /Volumes/MySQL_Backups/mysql_backup_20121004.sql

<http://srmxymon.ambrosi.com/xymon-cgi/svcstatus.sh?CLIENT=MYSQLSERVER01&;
SECTION=file:/Volumes/MySQL_Backups/mysql_backup_20121004.sql>

File was modified 57134 seconds ago - should be <600

green /Volumes/MySQL_Backups/herbalife_backup_20121004.sql

<http://srmxymon.ambrosi.com/xymon-cgi/svcstatus.sh?CLIENT=MYSQLSERVER01&;
SECTION=file:/Volumes/MySQL_Backups/herbalife_backup_20121004.sql>


Example below using %^.sql:


Thu Oct 4 16:10:15 CDT 2012 - Files ok

green /Volumes/MySQL_Backups/mysql_backup_20121004.sql

<http://srmxymon.ambrosi.com/xymon-cgi/svcstatus.sh?CLIENT=MYSQLSERVER01&;
SECTION=file:/Volumes/MySQL_Backups/mysql_backup_20121004.sql>green
/Volumes/MySQL_Backups/herbalife_backup_20121004.sql

<http://srmxymon.ambrosi.com/xymon-cgi/svcstatus.sh?CLIENT=MYSQLSERVER01&;
SECTION=file:/Volumes/MySQL_Backups/herbalife_backup_20121004.sql>

 Thanks


Don K

- --
- ---- _  _ _  _ ___  _  _  _
|Y#| |  | |\/| |  \ |\ |  | |Ryan Novosielski - Sr. Systems Programmer
|$&| |__| |  | |__/ | \| _| |user-ae4522577e16@xymon.invalid<mailto:user-ae4522577e16@xymon.invalid> - 973/972.0922<tel:973%2F972.0922> (2-0922)
\__/ Univ. of Med. and Dent.|IST/EI-Academic Svcs. - ADMC 450, Newark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBu6cYACgkQmb+gadEcsb4+nwCgmDPWgoqU3CArx2qcUMklTceW
ky8An1+npPWhxkVCANKk+DUu8sXkrIXO
=7gwh
-----END PGP SIGNATURE-----