diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-29 22:03:24 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-29 22:03:24 (GMT) |
commit | 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 (patch) | |
tree | 1c2b6b21704a294940f87c7892676998d8371707 /web/attachments/405293-check_file_age-diff | |
download | site-0b6423f9c99d9edf8c96fefd0f6c453859395aa1.tar.gz |
Import Nagios Plugins site
Import the Nagios Plugins web site, Cronjobs, infrastructure scripts,
and configuration files.
Diffstat (limited to 'web/attachments/405293-check_file_age-diff')
-rw-r--r-- | web/attachments/405293-check_file_age-diff | 54 |
1 files changed, 54 insertions, 0 deletions
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 @@ | |||
1 | --- /usr/libexec/nagios/plugins/check_file_age 2011-03-23 12:17:55.000000000 -0400 | ||
2 | +++ /home/vargo/tmp/excavate/check_file_age 2011-03-23 12:18:49.000000000 -0400 | ||
3 | @@ -32,7 +32,7 @@ | ||
4 | sub print_help (); | ||
5 | sub print_usage (); | ||
6 | |||
7 | -my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); | ||
8 | +my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i); | ||
9 | my ($result, $message, $age, $size, $st); | ||
10 | |||
11 | $PROGNAME="check_file_age"; | ||
12 | @@ -47,6 +47,7 @@ | ||
13 | GetOptions( | ||
14 | "V" => \$opt_V, "version" => \$opt_V, | ||
15 | "h" => \$opt_h, "help" => \$opt_h, | ||
16 | + "i" => \$opt_i, "ignore-missing" => \$opt_i, | ||
17 | "f=s" => \$opt_f, "file" => \$opt_f, | ||
18 | "w=f" => \$opt_w, "warning-age=f" => \$opt_w, | ||
19 | "W=f" => \$opt_W, "warning-size=f" => \$opt_W, | ||
20 | @@ -72,8 +73,15 @@ | ||
21 | |||
22 | # Check that file exists (can be directory or link) | ||
23 | unless (-e $opt_f) { | ||
24 | - print "FILE_AGE CRITICAL: File not found - $opt_f\n"; | ||
25 | - exit $ERRORS{'CRITICAL'}; | ||
26 | + if ($opt_i) { | ||
27 | + $result = 'OK'; | ||
28 | + print "FILE_AGE $result: $opt_f doesn't exist, but ignore-missing was set\n"; | ||
29 | + exit $ERRORS{$result}; | ||
30 | + | ||
31 | + } else { | ||
32 | + print "FILE_AGE CRITICAL: File not found - $opt_f\n"; | ||
33 | + exit $ERRORS{'CRITICAL'}; | ||
34 | + } | ||
35 | } | ||
36 | |||
37 | $st = File::stat::stat($opt_f); | ||
38 | @@ -95,7 +103,7 @@ | ||
39 | |||
40 | sub print_usage () { | ||
41 | print "Usage:\n"; | ||
42 | - print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] -f <file>\n"; | ||
43 | + print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] [-i] -f <file>\n"; | ||
44 | print " $PROGNAME [-h | --help]\n"; | ||
45 | print " $PROGNAME [-V | --version]\n"; | ||
46 | } | ||
47 | @@ -105,6 +113,7 @@ | ||
48 | print "Copyright (c) 2003 Steven Grimm\n\n"; | ||
49 | print_usage(); | ||
50 | print "\n"; | ||
51 | + print " -i | --ignore-missing : return OK if the file does not exist\n"; | ||
52 | print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; | ||
53 | print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n"; | ||
54 | print "\n"; | ||