Non recursive directory monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
kadaw978
Posts: 27
Joined: Mon Feb 29, 2016 1:58 pm

Non recursive directory monitoring

Post 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%'
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Non recursive directory monitoring

Post 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
Former Nagios Employee
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Non recursive directory monitoring

Post 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.
Former Nagios employee
https://www.mcapra.com/
kadaw978
Posts: 27
Joined: Mon Feb 29, 2016 1:58 pm

Re: Non recursive directory monitoring

Post by kadaw978 »

Thanks all.

I will give this a try.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Non recursive directory monitoring

Post by mcapra »

Let us know if you hit any walls!
Former Nagios employee
https://www.mcapra.com/
kadaw978
Posts: 27
Joined: Mon Feb 29, 2016 1:58 pm

Re: Non recursive directory monitoring

Post 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?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Non recursive directory monitoring

Post 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.
Former Nagios employee
https://www.mcapra.com/
Locked