Check file age

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Check file age

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Check file age

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Check file age

Post by jkinning »

The time is in seconds as well, correct? The w and c values?

That does appear to have worked.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Check file age

Post by tgriep »

Yes, they are in seconds.
Be sure to check out our Knowledgebase for helpful articles and solutions!
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Check file age

Post by jkinning »

Great! Thanks again and you can close at your convenience.
Locked