From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/405293-check_file_age-diff | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 web/attachments/405293-check_file_age-diff (limited to 'web/attachments/405293-check_file_age-diff') diff --git a/web/attachments/405293-check_file_age-diff b/web/attachments/405293-check_file_age-diff new file mode 100644 index 0000000..6b32f0d --- /dev/null +++ b/web/attachments/405293-check_file_age-diff @@ -0,0 +1,54 @@ +--- /usr/libexec/nagios/plugins/check_file_age 2011-03-23 12:17:55.000000000 -0400 ++++ /home/vargo/tmp/excavate/check_file_age 2011-03-23 12:18:49.000000000 -0400 +@@ -32,7 +32,7 @@ + sub print_help (); + sub print_usage (); + +-my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); ++my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i); + my ($result, $message, $age, $size, $st); + + $PROGNAME="check_file_age"; +@@ -47,6 +47,7 @@ + GetOptions( + "V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, ++ "i" => \$opt_i, "ignore-missing" => \$opt_i, + "f=s" => \$opt_f, "file" => \$opt_f, + "w=f" => \$opt_w, "warning-age=f" => \$opt_w, + "W=f" => \$opt_W, "warning-size=f" => \$opt_W, +@@ -72,8 +73,15 @@ + + # Check that file exists (can be directory or link) + unless (-e $opt_f) { +- print "FILE_AGE CRITICAL: File not found - $opt_f\n"; +- exit $ERRORS{'CRITICAL'}; ++ if ($opt_i) { ++ $result = 'OK'; ++ print "FILE_AGE $result: $opt_f doesn't exist, but ignore-missing was set\n"; ++ exit $ERRORS{$result}; ++ ++ } else { ++ print "FILE_AGE CRITICAL: File not found - $opt_f\n"; ++ exit $ERRORS{'CRITICAL'}; ++ } + } + + $st = File::stat::stat($opt_f); +@@ -95,7 +103,7 @@ + + sub print_usage () { + print "Usage:\n"; +- print " $PROGNAME [-w ] [-c ] [-W ] [-C ] -f \n"; ++ print " $PROGNAME [-w ] [-c ] [-W ] [-C ] [-i] -f \n"; + print " $PROGNAME [-h | --help]\n"; + print " $PROGNAME [-V | --version]\n"; + } +@@ -105,6 +113,7 @@ + print "Copyright (c) 2003 Steven Grimm\n\n"; + print_usage(); + print "\n"; ++ print " -i | --ignore-missing : return OK if the file does not exist\n"; + print " File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; + print " File must be at least this many bytes long (default: crit 0 bytes)\n"; + print "\n"; -- cgit v1.2.3-74-g34f1