Check file age

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Check file age

Post by slansing »

So what happens when you run this check to a standard directory?

Code: Select all

directory of plugin/check_file_age -w value -c value -f /usr/local/nagios/etc/commands.cfg
linuxnewbie
Posts: 21
Joined: Tue Feb 19, 2013 6:54 pm

Re: Check file age

Post by linuxnewbie »

So what happens when you run this check to a standard directory?
Here is what I got for this:

Code: Select all

tmc@mybox:/usr/local/nagios/libexec$ ./check_file_age -w 600 -c 1200 -f /usr/local/nagios/etc/objects/commands.cfg
FILE_AGE CRITICAL: /usr/local/nagios/etc/objects/commands.cfg is 23 hours (1 days) old and 20448 bytes
Now that I know I have the correct command I ran it on the file nagios says it cannot find:

Code: Select all

tmc@mybox:/usr/local/nagios/libexec$ ./check_file_age -w 600 -c 1200 -f /media/tmc/Data/OffSite_BU/Hopkins_Server/EagleSoft/Data/PattersonPM.db
FILE_AGE CRITICAL: /media/tmc/Data/OffSite_BU/Hopkins_Server/EagleSoft/Data/PattersonPM.db is 13 hours (1 days) old and 687390720 bytes
So nagios can see it and see that the file is OK, so the syntax must be wrong in my config's.

The command I'm using:

Code: Select all

define command {
       command_name	check_file_age_Hopkins
       command_line	$USER1$/check_file_age -w 432000 -c 518400 -f /media/tmc/Data/OffSite_BU/Hopkins_Server/EagleSoft/Data/PattersonPM.db
       }
The service I'm using:

Code: Select all

define service{
       use			local-service
       host_name		TMC-Offsite-Backup-Server
       service_description	Hopkins_BU
       check_command		check_file_age_Hopkins
       contact_groups		admins, Hopkins       
}

If you need anything else from me please let me know.

Thanks for all of your help!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Check file age

Post by slansing »

I am having trouble finding anything wrong with your definition, what happens when you change the command definition to check for the commands.cfg as I mentioned above and you force the check through the web UI. I'm wondering if it will tell you it cant find that file too..
linuxnewbie
Posts: 21
Joined: Tue Feb 19, 2013 6:54 pm

Re: Check file age

Post by linuxnewbie »

slansing wrote:I am having trouble finding anything wrong with your definition, what happens when you change the command definition to check for the commands.cfg as I mentioned above and you force the check through the web UI. I'm wondering if it will tell you it cant find that file too..
Ran a test:

Code: Select all

# check file age for Test
define command {
       command_name	check_file_age_Test
       command_line	$USER1$/check_file_age -w 432000 -c 518000 -f /usr/local/nagios/etc/objects/commands.cfg
}
It shows the file as being OK!

Im going to run a few more tests to see how deep into the media directory nagios can see files.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Check file age

Post by sreinhardt »

That sounds like a good idea! Another thought might be to add the nagios user to tmc group so that it will have access.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
linuxnewbie
Posts: 21
Joined: Tue Feb 19, 2013 6:54 pm

Re: Check file age

Post by linuxnewbie »

sreinhardt wrote:That sounds like a good idea! Another thought might be to add the nagios user to tmc group so that it will have access.
I added nagios to the tmc group and tmc to the nagios group a few days ago and that did not help.

I found the reason why it was not working... /media and /media/tmc are owned by root:root. The reason Nagios did not have access is /media/tmc was lacking 'other' read rights. As soon as I gave the /media/tmc folder nagios can see everything just fine!

Thank you everyone! Still very new to Linux and it feels like I'm trying to swim before learning how to dog paddle... But its fun!

Thanks again!
Locked