Page 1 of 1

Check file age

Posted: Tue Mar 08, 2016 11:57 am
by jkinning
I am trying to get this check so that it is alright but goes critical if it gets modified. I want to monitor our DNS named.conf file and if it gets changed Nagios sends out a critical alert.
command[check_file_named]=/usr/local/nagios/libexec/check_file_age -f /etc/named.conf -w ? -c ? I have been playing with different values but cannot for the life of me get this to work. Is there a different or better check?

It seems easier enough. This file shouldn't change, if it does then Nagios send out alerts.
3957 Sep 8 14:03 named.conf

Re: Check file age

Posted: Tue Mar 08, 2016 12:29 pm
by tgriep
That plugin will generate a Warning or Critical alert is a file is older than a certain time and to get it to generate an alert for the file being less than a certain time, it will have to be edited.
Edit the check_file_age plugin and change the following 2 lines from

Code: Select all

if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) {
elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) {
to

Code: Select all

if (($opt_c and $age < $opt_c) or ($opt_C and $size < $opt_C)) {
elsif (($opt_w and $age < $opt_w) or ($opt_W and $size < $opt_W)) {
Save it out and now the plugin will generate an alert for a file being less than the warning and critical thresholds you specify.

Re: Check file age

Posted: Tue Mar 08, 2016 1:03 pm
by jkinning
The time is in seconds as well, correct? The w and c values?

That does appear to have worked.

Re: Check file age

Posted: Tue Mar 08, 2016 1:32 pm
by tgriep
Yes, they are in seconds.

Re: Check file age

Posted: Tue Mar 08, 2016 1:37 pm
by jkinning
Great! Thanks again and you can close at your convenience.