diff options
Diffstat (limited to 'web/attachments/319236-check_file_age--allow_missing_file.diff')
-rw-r--r-- | web/attachments/319236-check_file_age--allow_missing_file.diff | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/web/attachments/319236-check_file_age--allow_missing_file.diff b/web/attachments/319236-check_file_age--allow_missing_file.diff new file mode 100644 index 0000000..6e51a5a --- /dev/null +++ b/web/attachments/319236-check_file_age--allow_missing_file.diff | |||
@@ -0,0 +1,37 @@ | |||
1 | --- a/check_file_age 2008-12-29 07:54:29.000000000 -0800 | ||
2 | +++ b/check_file_age 2009-03-23 22:35:54.000000000 -0700 | ||
3 | @@ -33,7 +33,7 @@ use utils qw (%ERRORS &print_revision &s | ||
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_m, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); | ||
9 | my ($result, $message, $age, $size, $st); | ||
10 | |||
11 | $PROGNAME="check_file_age"; | ||
12 | @@ -48,6 +48,7 @@ Getopt::Long::Configure('bundling'); | ||
13 | GetOptions( | ||
14 | "V" => \$opt_V, "version" => \$opt_V, | ||
15 | "h" => \$opt_h, "help" => \$opt_h, | ||
16 | + "m" => \$opt_m, "missing" => \$opt_m, | ||
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 | @@ -73,8 +74,14 @@ if (! $opt_f) { | ||
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 we allow missing files/directories, return OK | ||
27 | + if ($opt_m) { | ||
28 | + print "FILE_AGE OK: File not found - $opt_f\n"; | ||
29 | + exit $ERRORS{'OK'}; | ||
30 | + } else { | ||
31 | + print "FILE_AGE CRITICAL: File not found - $opt_f\n"; | ||
32 | + exit $ERRORS{'CRITICAL'}; | ||
33 | + } | ||
34 | } | ||
35 | |||
36 | $st = File::stat::stat($opt_f); | ||
37 | |||