Imported Upstream version 2.0
This commit is contained in:
parent
c89ccc3c74
commit
0841b5c7c7
165 changed files with 25440 additions and 4442 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/bin/perl -w
|
||||
#!@PERL@ -w
|
||||
|
||||
# check_file_age.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com>
|
||||
#
|
||||
|
@ -17,26 +17,31 @@
|
|||
# GNU General Public License for more details.
|
||||
#
|
||||
# you should have received a copy of the GNU General Public License
|
||||
# along with this program (or with Nagios); if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA
|
||||
# along with this program if not, write to the Free Software Foundation,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
use strict;
|
||||
use English;
|
||||
use Getopt::Long;
|
||||
use File::stat;
|
||||
use vars qw($PROGNAME);
|
||||
use lib ".";
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib '@libexecdir@';
|
||||
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";
|
||||
|
||||
$ENV{'PATH'}='@TRUSTED_PATH@';
|
||||
$ENV{'BASH_ENV'}='';
|
||||
$ENV{'ENV'}='';
|
||||
|
||||
$opt_w = 240;
|
||||
$opt_c = 600;
|
||||
$opt_W = 0;
|
||||
|
@ -47,6 +52,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,
|
||||
|
@ -72,8 +78,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);
|
||||
|
@ -95,7 +108,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";
|
||||
}
|
||||
|
@ -105,6 +118,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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue