Page 1 of 1

Can Nagio monitor a folder for files

Posted: Mon Jan 27, 2014 8:20 am
by jboddiford
Hi,

Very new to Nagio and evaluating it as a monitoring solution for a company.

One of the tasks we need monitored is the count of files in a folder... so basically if there are files in a folder at a specific time... it's working well... if the folder is empty... we need an alert.

Is this something Nagio can help with?

Thanks in advance!!
Josh

Re: Can Nagio monitor a folder for files

Posted: Mon Jan 27, 2014 10:26 am
by tmcdonald
This should be pretty easy to do. You could make a bash script that does

Code: Select all

ls -l | grep --invert ^d wc -l
And uses that (minus 1 since the first line it outputs is not a file) for a non-recursive file count. The grep removed all directory listings, and the wc -l gives a count of the files. Then it's just a matter of giving the proper exit code based on the file count.