diff options
Diffstat (limited to 'plugins-scripts/check_file_age.pl')
-rwxr-xr-x | plugins-scripts/check_file_age.pl | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl index 4cdb36db..2781c2ac 100755 --- a/plugins-scripts/check_file_age.pl +++ b/plugins-scripts/check_file_age.pl @@ -31,7 +31,7 @@ use utils qw (%ERRORS &print_revision &support); 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"; @@ -46,6 +46,7 @@ Getopt::Long::Configure('bundling'); 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, @@ -71,8 +72,15 @@ if (! $opt_f) { # 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); @@ -94,7 +102,7 @@ exit $ERRORS{$result}; sub print_usage () { print "Usage:\n"; - print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] -f <file>\n"; + print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] [-i] -f <file>\n"; print " $PROGNAME [-h | --help]\n"; print " $PROGNAME [-V | --version]\n"; } @@ -104,6 +112,7 @@ sub print_help () { 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 " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n"; print "\n"; |