[Nagiosplug-checkins] nagiosplug/plugins-scripts check_file_age.pl,1.2,1.3

Ton Voon tonvoon at users.sourceforge.net
Thu Dec 15 07:19:09 CET 2005


Update of /cvsroot/nagiosplug/nagiosplug/plugins-scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv306/plugins-scripts

Modified Files:
	check_file_age.pl 
Log Message:
Allow directories and links to be tested by check_file_age. Sanitise output.
Added tests


Index: check_file_age.pl
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/check_file_age.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_file_age.pl	21 Oct 2003 15:56:35 -0000	1.2
+++ check_file_age.pl	15 Dec 2005 15:17:49 -0000	1.3
@@ -67,14 +67,14 @@
 $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 @@
 	$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 @@
 	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();
 }





More information about the Commits mailing list