Refer to @rkennedy's post. NSClient 0.4.3 or greater is pretty key here.
Here's something I've labbed up:
Documents directory looks like this:
test.txt (written 18 days ago)
sub_directory/sub_file.txt (written 30 minutes ago)
sub_directory/more_sub/more_sub_file.txt (written 2 minutes ago)
This command checks a top-level directory for txt files written less than 1 hour ago:
Code: Select all
[root@localhost libexec]# ./check_nrpe -H 192.168.3.170 -c check_files -a path="C:\\users\\mcapra\\documents\\" pattern=*.txt 'filter=written > -60m' 'max-depth=1'
No files found
This command checks a top-level directory and recurses down 1 level:
Code: Select all
[root@localhost libexec]# ./check_nrpe -H 192.168.3.170 -c check_files -a path="C:\\users\\mcapra\\documents\\" pattern=*.txt 'filter=written > -60m' 'max-depth=2'
OK: All 1 files are ok
This command checks a top-level directory and recurses down 2 levels:
Code: Select all
[root@localhost libexec]# ./check_nrpe -H 192.168.3.170 -c check_files -a path="C:\\users\\mcapra\\documents\\" pattern=*.txt 'filter=written > -60m' 'max-depth=3'
OK: All 2 files are ok
Notice how the 3rd command recognizes more_sub_file.txt and includes it in the count.
You could add parameters such as
'warn=count < 2' 'crit=count < 1' to warn if there are a certain number of files being written in the last hour. Removing the
'max-depth' parameter causes this command to recurse through all sub-directories.