As I don’t think in seconds about time and more like hours days etc. I’ve added this small bit of code to Nagios check_file_age script to display age in days. I’m using this to check PID file age for service that needs daily/weekly restarts.
By default you will get something like this:
FILE_AGE CRITICAL: /var/run/server.pid is 457395 seconds old and 4 bytes
I’m to lazy to calculate this
Find this line in the code:
print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes\n";
and replace it with:
my $days = $age/86400;
$days = sprintf("%.1f", $days);
print "FILE_AGE $result: $opt_f is $age seconds ($days days) old and $size bytes\n";
Now you will get:
FILE_AGE CRITICAL: /var/run/server.pid is 457381 seconds (5.3 days) old and 4 bytes
Much nicer






Recent Comments