Monitor single file by last modified dat

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.
Locked
vauran
Posts: 12
Joined: Wed Mar 18, 2015 4:10 pm

Monitor single file by last modified dat

Post by vauran »

Hey Guys,

I need to monitor the last modified date of a single file on a remote server. The file, when our software is working, gets updated at least once per minute. So in theory, the Date Modified should always reflect the current time on the server. The issue is that sometimes the software stops working and one of the ways to tell is that the file doesn't get updated anymore. I'd like to monitor the file and get an alert once the date modified is over 1 minute old. I've played around with this a bit but not sure if what I have works. I'd like to be pointed in the right direction if possible.

Couple of the things I've done:

1. I tried using check_file_age but I get the following error:
[root@server plugins]# ./check_nrpe -H 192.168.X.XXX -c check_file_age -a 5 -a 5 -a 'C:\\Program Files (x86)\\PATH\FILE.EXT'
UNKNOWN: No handler for that command

I researched that and figured I'm missing things in the NSCLient++ folder on the remote server but have no idea where to get what I need or how to set it up correctly.

2. The recent thing I did, which I think is working correctly but can't really test, is using check_nrpe and CheckFiles:

/usr/local/nagios/etc/objects/commands.cfg
define command {
command_name commandNameA
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c CheckFiles -a path='C:\\Program Files (x86)\\PATH\FILE.EXT' 'filter=written < -1m' MaxCrit=1

}
/usr/local/nagios/etc/servers/server.cfg
define service {
host_name serverName
check_command commandNameA
max_check_attempts 5
normal_check_interval 15
retry_interval 5
active_checks_enabled 1
passive_checks_enabled 1
check_period 24x7
parallelize_check 1
obsess_over_service 1
check_freshness 1
freshness_threshold 0
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 20
notification_period 24x7
notifications_enabled 1
failure_prediction_enabled 1
service_description Blah
display_name
notification_options u,c,r,f
stalking_options o,w,u,c
contact_groups Email - Group IT Support,Pagers
}


Can someone help out with this? Did I go down a rabbit hole and I'm missing something easy?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Monitor single file by last modified dat

Post by tgriep »

Is the remote system a Windows system?
If it is, can you post the nsc.ini (Older NSClient) or the nsclient.ini (Newer NSClient) file so we can review it?
It is in the folder that the NSClient is installed in.

Also, take a look at this site for some examples of using NSClient and file/folder checks.
http://sites.box293.com/nagios/guides/c ... es-folders
Be sure to check out our Knowledgebase for helpful articles and solutions!
vauran
Posts: 12
Joined: Wed Mar 18, 2015 4:10 pm

Re: Monitor single file by last modified dat

Post by vauran »

Hey,

The number 2 option in my original post actually works "perfectly". Our software crashed and I got alerts saying the file hadn't been updated which is what we were looking for.

Thanks :).
Locked