aboutsummaryrefslogtreecommitdiff
path: root/plugins-scripts/check_file_age.pl
diff options
context:
space:
mode:
authorGravatar Ton Voon <tonvoon@users.sourceforge.net> 2005-12-15 15:17:49 +0000
committerGravatar Ton Voon <tonvoon@users.sourceforge.net> 2005-12-15 15:17:49 +0000
commit73b77a44c43960b6fcf8b3c29c1016ba1940aa89 (patch)
treea8adb7ae427b4cf7b7c6c4f35de9fc0a918140d4 /plugins-scripts/check_file_age.pl
parent162faf883a864a94c0f75ca0e21360cbd001e0f3 (diff)
downloadmonitoring-plugins-73b77a44c43960b6fcf8b3c29c1016ba1940aa89.tar.gz
Allow directories and links to be tested by check_file_age. Sanitise output.
Added tests git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1297 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/check_file_age.pl')
-rwxr-xr-xplugins-scripts/check_file_age.pl16
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl
index 43038fae..0215c0f6 100755
--- a/plugins-scripts/check_file_age.pl
+++ b/plugins-scripts/check_file_age.pl
@@ -67,14 +67,14 @@ if ($opt_h) {
$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);
@@ -91,7 +91,7 @@ elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) {
$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 () {
@@ -106,8 +106,8 @@ sub print_help () {
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();
}