Home Directory Plugins System Metrics File System check_file_ages_in_dirs

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com


Remember Me

Directory Tree


10 votes
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
This plugin pulls all files in each specified directory, and checks their created time against the current time. If the maximum age of any file is exceeded, a warning/critical message is returned as appropriate. This is useful for examining backup directories for freshness.

The only requirement is the bash shell interpreter, which most systems have installed by default.
The plugin is maintained on GitHub, visit here for more information.
Reviews (7)
bysysc000, October 23, 2017
Hi, it's possible to check against Windows directories? How?

byNanne, June 11, 2015
Works fine as a quick solution, only feature I miss is to be able to exclude files from a certain directory that will not be updated // are allowed to be older.

Apart from that, it uses "Let" which seems to not-work on ubuntu that uses dash instead of bash: replace the /bin/sh with /bin/bash and you're fine.
byjhirbour, November 20, 2013
Line 10 of this check_file_ages_in_dirs.sh has:
" . $PROGPATH/utils.sh"

This file is not in the download that I can see.

In order to get this plugin working I needed to do the following:

1. Comment out the utils.sh "#. $PROGPATH/utils.sh"
2. Add the following below where utils.sh was

This makes the plugin work.
Owner's reply

utils.sh is now provided with the package if you need it, RHEL/CentOS systems provide this file as part of the nagios-plugins package.


How to check file freshness on Remote SMB/Windows Shares ?
Owner's reply

The plugin *should* work for any directory structure that exists in the local filesystem. Haven't tested it specifically with something like NFS, and I've never used Samba, so can't speak to that.

On SLES 10 with Bash 3.1.17 the script needs some minor modifications that it works.

I got these errors:

line 299: let: FILE_AGE = 1335536854 - : syntax error: operand expected (error token is " ")
line 300: let: FILE_AGE_UNITS = / 3600: syntax error: operand expected (error token is "/ 3600")
line 303: [: -gt: unary operator expected
line 306: [: -gt: unary operator expected

How to fix it
Line 294 from:
st_ctime=`stat --printf=%Y ${next_filepath}`

Line 294 to:
st_ctime=`stat --format=%Y ${next_filepath}`

Line 303 from:
if [ $FILE_AGE -gt $MAX_CRIT_AGE ]; then

Line 303 to:
if [[ $FILE_AGE -gt $MAX_CRIT_AGE ]]; then

Line 306 from:
elif [ $FILE_AGE -gt $MAX_WARN_AGE ]; then

Line 306 to:
elif [[ $FILE_AGE -gt $MAX_WARN_AGE ]]; then

Besides that nice work!
byolivier.carre@jci.com, November 15, 2011
I have only modify 2 lines to allow listing of files named with space
bybrownie, March 21, 2011

I've read your information about your plugin and i want to use it, but i have a question.
You can set warnings/crits on any given time, but can you also decide what the warning must say e.g.: "Warning: the file 'test.txt' is too long in this folder!!" ?
I haven't tried your plugin YET, because i don't have a test environment YET.

Can you please answer my question, it would make a whole difference ;-)


Owner's reply

Very delayed reply, and, no, you currently can't set the content of the messages.