Nagios
Nagios is an open source monitoring software package. I've been using Nagios since its earlier name Netsaint was still in effect. Nagios will be the subject of another post here on linfactory so stick around.
Plugins
Plugins do the heavy lifting for Nagios. These plugins are small pieces of code that do something useful like check a ping timeout or in this case, a file's existence and age.
Check_file_age
I found a stock plugin called check_file_age. Here's how it works:
-sh-3.00$ /usr/lib/nagios/plugins/check_file_age --help
check_file_age (nagios-plugins 1.4.2) $Id: check_file_age.pl,v 1.2 2003/10/21 15:56:35 tonvoon Exp
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Copyright (c) 2003 Steven Grimm
Usage:
check_file_age [-w] [-c ] [-W ] [-C ] -f
check_file_age [-h | --help]
check_file_age [-V | --version]
File must be no more than this many seconds old
File must be at least this many bytes long
Send email to nagios-users@lists.sourceforge.net if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to nagiosplug-devel@lists.sourceforge.net.
Please include version information with all correspondence (when possible,
use output from the --version option of the plugin itself).
Test Invocation
[nagios@lnciserver1 ~]$ /usr/lib/nagios/plugins/check_file_age -f /var/lib/cobbler/lock -w 3600 -c 7200
/var/lib/cobbler/lock: File not found
So, the check_file_age plugin tells us that this file is missing.
Let's look at the return code.
[nagios@lnciserver1 ~]$ echo $?
3
A non-zero return code indicates a problem. In this case the 3 corresponds to "UNKOWN." Nagios doesn't know what to make of this situation. I need to tweak this plugin. No problem, this is open source after all. I need to allow for the absence of the file as this is okay in my situation. That would just indicate the cobbler has cleaned up successfully and deleted its lock file.
Modification
For the cobbler case above, we need this situation to retun a 0.
Here's the change.
-sh-3.00$ diff -c /usr/lib/nagios/plugins/check_file_age /usr/lib/nagios/plugins/check_file_age2
*** /usr/lib/nagios/plugins/check_file_age 2006-03-06 23:57:22.000000000 +0000
--- /usr/lib/nagios/plugins/check_file_age2 2007-10-19 23:26:24.000000000 +0000
***************
*** 74,80 ****
# Examine the file.
unless (-f $opt_f) {
print "$opt_f: File not found\n";
! exit $ERRORS{'UNKNOWN'};
}
$st = File::stat::stat($opt_f);
--- 74,80 ----
# Examine the file.
unless (-f $opt_f) {
print "$opt_f: File not found\n";
! exit $ERRORS{'OK'};
}
$st = File::stat::stat($opt_f);
Invoking the Plugin
Now that we have a modified plugin in place, we'll run it to see what is up with our cobbler server.
Invocation Take Two
[nagios@lnciserver1 ~]$ /usr/lib/nagios/plugins/check_file_age2 -f /var/lib/cobbler/lock -w 3600 -c 7200
/var/lib/cobbler/lock: File not found
[nagios@lnciserver1 ~]$ echo $?
0
All good!
1 comment:
Hi,
I want to monitor windows file age and file count using Nagios core version 3.3.1, after searching a lot I found check_winfile plugin but I'm able to configure as it. here is link
https://www.itefix.no/i2/check_winfile
Post a Comment