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/239325-check_file_age.patch | 84 +++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 web/attachments/239325-check_file_age.patch (limited to 'web/attachments/239325-check_file_age.patch') 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 @@ +--- check_file_age.bak 2007-07-27 14:24:15.000000000 +0100 ++++ check_file_age 2007-07-27 14:31:20.000000000 +0100 +@@ -33,22 +33,23 @@ + sub print_help (); + sub print_usage (); + +-my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); +-my ($result, $message, $age, $size, $st); +- + $PROGNAME="check_file_age"; + +-$opt_w = 240; +-$opt_c = 600; +-$opt_W = 0; +-$opt_C = 0; +-$opt_f = ""; ++my $opt_V = undef; ++my $opt_w = 240; ++my $opt_c = 600; ++my $opt_W = 0; ++my $opt_C = 0; ++my $opt_f = ""; ++my $opt_d = ""; ++my $opt_h = ""; + + Getopt::Long::Configure('bundling'); + GetOptions( + "V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, + "f=s" => \$opt_f, "file" => \$opt_f, ++ "d=s" => \$opt_d, "dir" => \$opt_d, + "w=f" => \$opt_w, "warning-age=f" => \$opt_w, + "W=f" => \$opt_W, "warning-size=f" => \$opt_W, + "c=f" => \$opt_c, "critical-age=f" => \$opt_c, +@@ -64,25 +65,32 @@ + exit $ERRORS{'OK'}; + } + +-$opt_f = shift unless ($opt_f); ++$opt_f = shift unless ($opt_f or $opt_d); + +-if (! $opt_f) { +- print "No file specified\n"; ++if (not $opt_f and not $opt_d) { ++ print "No file or directory specified\n"; + exit $ERRORS{'UNKNOWN'}; + } + + # Examine the file. +-unless (-f $opt_f) { ++if ($opt_f and not -f $opt_f) ++{ + print "$opt_f: File not found\n"; + exit $ERRORS{'UNKNOWN'}; + } ++elsif ($opt_d and not -d $opt_d) ++{ ++ print "$opt_d: Directory not found\n"; ++ exit $ERRORS{'UNKNOWN'}; ++} + +-$st = File::stat::stat($opt_f); +-$age = time - $st->mtime; +-$size = $st->size; ++my $file = $opt_f || $opt_d; + ++my $st = File::stat::stat($file); ++my $age = time - $st->mtime; ++my $size = $st->size; + +-$result = 'OK'; ++my $result = 'OK'; + + if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) { + $result = 'CRITICAL'; +@@ -91,7 +99,7 @@ + $result = 'WARNING'; + } + +-print "$result - $opt_f is $age seconds old and $size bytes\n"; ++print "$result - $file is $age seconds old and $size bytes\n"; + exit $ERRORS{$result}; + + sub print_usage () { -- cgit v1.2.3-74-g34f1