Can Nagio monitor a folder for files

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jboddiford
Posts: 1
Joined: Mon Jan 27, 2014 8:15 am

Can Nagio monitor a folder for files

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Can Nagio monitor a folder for files

Post 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.
Former Nagios employee
Locked