Page 1 of 1
File count monitor for directories not sub-folders& it files
Posted: Thu Feb 22, 2018 2:34 am
by Gonela
Hi Team,
We trying to monitor file counts for windows server drive folders in NagiosXI with help of check_nrpe for NSClient 0.5
But here issue is, it is taking folder count as file count . Please help me on this.
Syntax:
./check_nrpe -H xx.xx.xx.xx -c check_files -a path='d:\\\\gis\\\\import\\\\photo' pattern=*.* 'filter= written < -10m' 'crit= count > 5' 'empty-state=ok' 'empty-syntax=${status}: No files found' 'top-syntax=${status}: ${count} files found'
Output :
CRITICAL: 1666 files found|'count'=1666;0;5
Here : 1666 files are folders . in each folder 0 files are there.
Re: File count monitor for directories not sub-folders& it f
Posted: Thu Feb 22, 2018 10:38 am
by mcapra
Which version of NSClient++ are you running these checks against? That's going to potentially affect some answers.
Here's an older post that discusses the
max-depth parameter of NSClient++'s CheckDisk module:
https://support.nagios.com/forum/viewto ... 22#p189522
max-depth is the key if you want to limit recursion into sub-directories.
Re: File count monitor for directories not sub-folders& it f
Posted: Thu Feb 22, 2018 12:20 pm
by lmiltchev
It seems like that NSClient++ counts folders as files. I was hoping to find an option to change this but the NSClient ++ documentation was not very useful.
There is another plugin that you could use with NSClient++ that may get the job done for you - check_winfile. You can download it (and see some examples) from here:
https://itefix.net/check_winfile
Place the "check_winfile.exe" in the NSClient++ scripts directory, and add the following entry to the nsclient.ini file under the [/settings/external scripts/scripts] section:
Code: Select all
check_winfile = scripts\check_winfile.exe //T:30 //NoLogo $ARG1$
Call the plugin from your Nagios XI server as such:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_winfile -a '<your arguments>'
For testing purposes, I added 4 sub-directories under c:\TEMP on my workstation, and added only one text file under the last sub-directory. Then I tested the plugin by running:
Code: Select all
[root@main-nagios-xi libexec]# ./check_nrpe -H x.x.x.x -c check_winfile -a '--target c:\TEMP --filter "age lt -10 minutes" --warn 5 --critical 10'
FILE OK - 0 files out of 1 to consider |'selected files'=0;5;10 'all files'=1 'deleted files'=0
[root@main-nagios-xi libexec]# ./check_nrpe -H x.x.x.x -c check_winfile -a '--target c:\TEMP --filter "age lt -1 minutes" --warn 5 --critical 10'
FILE OK - 1 files to consider |'selected files'=1;5;10 'all files'=1 'deleted files'=0
Next, I added two more files to one of the sub-directories, waited for a few minutes, and ran:
Code: Select all
[root@main-nagios-xi libexec]# ./check_nrpe -H x.x.x.x -c check_winfile -a '--target c:\TEMP --filter "age lt -1 minutes" --warn 1 --critical 5'
FILE WARNING - 3 files to consider |'selected files'=3;1;5 'all files'=3 'deleted files'=0
[root@main-nagios-xi libexec]# ./check_nrpe -H x.x.x.x -c check_winfile -a '--target c:\TEMP --filter "age lt -1 minutes" --warn 1 --critical 2'
FILE CRITICAL - 3 files to consider |'selected files'=3;1;2 'all files'=3 'deleted files'=0
As you can see, the filter (age) and thresholds worked as expected, and the plugin counted only files, not folders.
Hope this helps.
Re: File count monitor for directories not sub-folders& it f
Posted: Thu Feb 22, 2018 8:07 pm
by Gonela
Hi ,
Thanks for update,
Suppose if i use
[/b] , what will happen?
Folder structure:
C:.
├───Contacts
├───Desktop
├───Downloads
│ └───Evernote Import
├───Dropbox
│ ├───Apps
│ │ └───iftttcom
│ │ └───getpocketpdf
│ ├───Backup
│ ├───Camera Uploads
│ ├───Development
├───file1.txt
├───file2.txt
Re: File count monitor for directories not sub-folders& it f
Posted: Fri Feb 23, 2018 10:36 am
by lmiltchev
The "max-depth" option is not available for the "check_winfile" plugin I showed you examples for. The "check_winfile" plugin has a "--rootonly" option, which limits file search to the top level directory (no recursive traversal of directories). If you don't use this flag, all files (top directory + sub-directories) will be counted.
The "max-depth" option can be used with NSClient++, and it should look through all files/directories down the tree, however (I far as I know) it will count directories as files. Again, I couldn't find a way of changing this. Most probably this option is not available in NSClient++.
Re: File count monitor for directories not sub-folders& it f
Posted: Sun Feb 25, 2018 10:14 pm
by Gonela
Hi ,
My doubt in check_nrpe plugin.
./check_nrpe -H xx.xx.xx.xx -c check_files -a path='d:\\\\gis\\\\import\\\\photo' pattern=*.* max-depth=0 'filter= written < -10m' 'crit= count > 5' 'empty-state=ok' 'empty-syntax=${status}: No files found' 'top-syntax=${status}: ${count} files found'
what will happen? if i use max-depth=0
Re: File count monitor for directories not sub-folders& it f
Posted: Mon Feb 26, 2018 12:09 pm
by kyang
max-depth limits the recursion for the folders.
So having that set to 0 would not limit it, and it may just check all files.
You can see the examples from here.
https://docs.nsclient.org/0.5.0/samples/index.html