index 2ab1a28b761ad74f20bf29121bd2ccc528b71213..dcd5efab8305983cda8c529be2f25b52cbf0d1bd 100755 (executable)
#!/bin/perl -w
-# $Id$
-# check_file.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com>
+# check_file_age.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com>
#
# Checks a file's size and modification time to make sure it's not empty
# and that it's sufficiently recent.
my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V);
my ($result, $message, $age, $size, $st);
-$PROGNAME="check_file";
+$PROGNAME="check_file_age";
$opt_w = 240;
$opt_c = 600;
"C=f" => \$opt_C, "critical-size=f" => \$opt_C);
if ($opt_V) {
- print_revision($PROGNAME, '$Id$');
+ print_revision($PROGNAME, '@NP_VERSION@');
exit $ERRORS{'OK'};
}
$opt_f = shift unless ($opt_f);
if (! $opt_f) {
- print "No file specified\n";
+ print "FILE_AGE UNKNOWN: No file specified\n";
exit $ERRORS{'UNKNOWN'};
}
-# Examine the file.
-unless (-f $opt_f) {
- print "$opt_f: File not found\n";
- exit $ERRORS{'UNKNOWN'};
+# 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'};
}
$st = File::stat::stat($opt_f);
$result = 'WARNING';
}
-print "$result - $opt_f is $age seconds old and $size bytes\n";
+print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes\n";
exit $ERRORS{$result};
sub print_usage () {
}
sub print_help () {
- print_revision($PROGNAME, '$Id$');
+ print_revision($PROGNAME, '@NP_VERSION@');
print "Copyright (c) 2003 Steven Grimm\n\n";
print_usage();
print "\n";
- print " <secs> File must be no more than this many seconds old\n";
- print " <size> File must be at least this many bytes long\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";
support();
}