Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_file_count

Rating
8 votes
Favoured:
2
Current Version
0.8
Last Release Date
2009-11-10
Compatible With
  • Nagios 3.x
License
GPL
Hits
128150
Files:
FileDescription
check_file_count.tar.gzContains: README, check_file_count and check_file_count.php for graphs
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
check_file_count
Plugin to check/count the number of files and/or directories (incl/excl subs). Warnings on low/high/equal.
This is a Nagios plugin which checks the number of files and/or directories in some directory. If you want you can include subdirectories (and -files) in the check.
It produces warnings and criticals if the count becomes too high or too low, depending on the user input. It can also be set up to produce a critical if the count is not equal to a given value.
If you want it can produce performance output for graphs.

This plugin can be handy for monitoring your FTP or SMB. Or just to see whether some program is cleaning up it's logfiles and so on.

It has been tested on Nagios 3.x but I think it will work on version 2 and 1 as well.
Reviews (5)
Nagios Clinet (NRPE) is giving perfect output while the same doesn't happen from Nagios Core Server.

Here is the state:

On NRPE (Nagios Client) Server:-

./check_file_count -t=all -s=yes -wt=high -w 250 -c 300 -p=yes /var/named/
OK: Number of files and directories in /var/named/ is 216 (Warn=250, Crit=300) Files=213, Directories=3 | Total=216Count;250;300 Files=213Files 'Directories'=3Directories

From Nagios Core Server:-
./check_nrpe -H 172.16.1.10 -c check_file_count
OK: Number of files and directories in /var/named/ is -1 (Warn=250, Crit=300) Files=0, Directories=-1 | Total=-1Count;250;300 Files=0Files 'Directories'=-1Directories

Something is wrong with the script or call from Nagios Server. May be sudo...!!!

Please Guide.
byiraz098, March 18, 2018
I was not getting the perfdata values until my coleague recommended to change the line 238
"Performance data in the actual script (check_file_count) seems to be in row no 238 which is:
PERFDATA="| Total=$FILECOUNT"Count";$TESTEDWARN;$TESTEDCRIT Files=$FILENUMBER"Files" 'Directories'=$DIRNUMBER"Directories""
So commented the above and put the below line and it worked:
PERFDATA="| Total=$FILECOUNT;$TESTEDWARN;$TESTEDCRIT Files=$FILENUMBER Directories=$DIRNUMBER"
bycentury, May 20, 2012
great plugin, even if i had to do few modifications. you have to be noticed some options are not supported by some 'find' versions ... so in my case i just had to remove the '-nowarn' from the script.

thanks
for a valid search without subdirectory you need to add "maxdepth 1" on line 219 :

else if [ $SUBS = "-s=no" -a $TYPE = "-t=file" ]; then
219 FILECOUNT=$(echo `find $TESTEDDIR -nowarn -maxdepth 1 -type f | wc -l`)
220 FILENUMBER=$FILECOUNT
221 DIRNUMBER="0"
bybdealey, August 26, 2011
2 of 2 people found this review helpful
Need to change all "==" to "=". Once that was done, and ALL paramaters where specified, it worked well