summaryrefslogtreecommitdiffstats
path: root/web/attachments/239325-check_file_age.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/239325-check_file_age.patch')
-rw-r--r--web/attachments/239325-check_file_age.patch84
1 files changed, 84 insertions, 0 deletions
diff --git a/web/attachments/239325-check_file_age.patch b/web/attachments/239325-check_file_age.patch
new file mode 100644
index 0000000..9381765
--- /dev/null
+++ b/web/attachments/239325-check_file_age.patch
@@ -0,0 +1,84 @@
1--- check_file_age.bak 2007-07-27 14:24:15.000000000 +0100
2+++ check_file_age 2007-07-27 14:31:20.000000000 +0100
3@@ -33,22 +33,23 @@
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 ($result, $message, $age, $size, $st);
9-
10 $PROGNAME="check_file_age";
11
12-$opt_w = 240;
13-$opt_c = 600;
14-$opt_W = 0;
15-$opt_C = 0;
16-$opt_f = "";
17+my $opt_V = undef;
18+my $opt_w = 240;
19+my $opt_c = 600;
20+my $opt_W = 0;
21+my $opt_C = 0;
22+my $opt_f = "";
23+my $opt_d = "";
24+my $opt_h = "";
25
26 Getopt::Long::Configure('bundling');
27 GetOptions(
28 "V" => \$opt_V, "version" => \$opt_V,
29 "h" => \$opt_h, "help" => \$opt_h,
30 "f=s" => \$opt_f, "file" => \$opt_f,
31+ "d=s" => \$opt_d, "dir" => \$opt_d,
32 "w=f" => \$opt_w, "warning-age=f" => \$opt_w,
33 "W=f" => \$opt_W, "warning-size=f" => \$opt_W,
34 "c=f" => \$opt_c, "critical-age=f" => \$opt_c,
35@@ -64,25 +65,32 @@
36 exit $ERRORS{'OK'};
37 }
38
39-$opt_f = shift unless ($opt_f);
40+$opt_f = shift unless ($opt_f or $opt_d);
41
42-if (! $opt_f) {
43- print "No file specified\n";
44+if (not $opt_f and not $opt_d) {
45+ print "No file or directory specified\n";
46 exit $ERRORS{'UNKNOWN'};
47 }
48
49 # Examine the file.
50-unless (-f $opt_f) {
51+if ($opt_f and not -f $opt_f)
52+{
53 print "$opt_f: File not found\n";
54 exit $ERRORS{'UNKNOWN'};
55 }
56+elsif ($opt_d and not -d $opt_d)
57+{
58+ print "$opt_d: Directory not found\n";
59+ exit $ERRORS{'UNKNOWN'};
60+}
61
62-$st = File::stat::stat($opt_f);
63-$age = time - $st->mtime;
64-$size = $st->size;
65+my $file = $opt_f || $opt_d;
66
67+my $st = File::stat::stat($file);
68+my $age = time - $st->mtime;
69+my $size = $st->size;
70
71-$result = 'OK';
72+my $result = 'OK';
73
74 if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) {
75 $result = 'CRITICAL';
76@@ -91,7 +99,7 @@
77 $result = 'WARNING';
78 }
79
80-print "$result - $opt_f is $age seconds old and $size bytes\n";
81+print "$result - $file is $age seconds old and $size bytes\n";
82 exit $ERRORS{$result};
83
84 sub print_usage () {