Page 1 of 1

Non recursive directory monitoring

Posted: Wed Jul 13, 2016 9:41 am
by kadaw978
Hi,

So, we have file age monitoring for a windows directory, but would like to exclude sub-directories. I did some digging, but only found some articles on plugins and not much else. Is this possible with NagiosXI 5.2.9?

Below is the command that we have setup.

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFiles -a path="d:\\test\\folder\\" pattern=*.csv 'filter=written < -240m' MaxCrit=1 'syntax=%filename%: %write%'

Re: Non recursive directory monitoring

Posted: Wed Jul 13, 2016 12:34 pm
by rkennedy
This isn't a limitation for Nagios 5.2.9, it's more of an issue with NSClient++. What version of NSClient++ are you running on your client machine?

If it's 0.3.9, then you'll need to upgrade. If you're using a newer version, then you should be able to follow what @mickem mentioned on a similar GitHub issue.

Code: Select all

Excluding them should be as simple as "filter=creation < -60m and file != '.' and file != '..'" not 100% sure if the syntax of my head, but you can find that in the docs.
See the original GitHub issue here - https://github.com/mickem/nscp/issues/145

Re: Non recursive directory monitoring

Posted: Wed Jul 13, 2016 12:38 pm
by mcapra
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.

Re: Non recursive directory monitoring

Posted: Wed Jul 13, 2016 1:07 pm
by kadaw978
Thanks all.

I will give this a try.

Re: Non recursive directory monitoring

Posted: Wed Jul 13, 2016 1:13 pm
by mcapra
Let us know if you hit any walls!

Re: Non recursive directory monitoring

Posted: Wed Jul 13, 2016 2:20 pm
by kadaw978
We are currently using 0.39 version of nsclient++. Can we use the old nsc.ini configuration file or do we need to manually configure it?

Re: Non recursive directory monitoring

Posted: Wed Jul 13, 2016 2:32 pm
by mcapra
0.3.9 uses slightly different conventions than 0.4.3 as well as a different file name. Many of the definitions are the same, but you will likely need to review both the old configuration and the new configuration for changes.