Page 1 of 3
How do I monitor # of files in a folder on a Windows client
Posted: Wed Jan 21, 2015 12:06 pm
by wspackaging
Hello,
I am looking for assistance how to setup/configure a Windows client so I can monitor the number of files in a particular folder.
Basically I have an application that dumps files into a folder and when the application starts failing the number of files start to grow. So I want to create an alert that says if there are more than 100 files in the folder to alert us.
Thanks
Travis Haufschildt
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Wed Jan 21, 2015 12:44 pm
by lmiltchev
I would recommend browsing the
Nagios Exchange and looking for suitable plugins. I found some 3rd party plugins:
http://exchange.nagios.org/directory/Pl ... in/details
http://exchange.nagios.org/directory/Pl ... TK/details
http://exchange.nagios.org/directory/Pl ... le/details
You can try them. If they work, you can set up a command and a check in XI by following this guide:
http://exchange.nagios.org/directory/Pl ... le/details
Also, if you had a script that you could run locally on the Windows box, you could call it via NSClient++ or NCPA. Hope this helps.
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Wed Jan 21, 2015 1:49 pm
by wspackaging
Thanks for the info. I am new to Nagios. Is there a document out there on how you implement a plugin? Is it as simple as droping the scripts in a particular folder on the the client or does there need to be changes made to the Nagios server?
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Wed Jan 21, 2015 2:17 pm
by lmiltchev
I am sorry, I meant to give the link to our "Managing Plugins In Nagios XI" document but I posted a wrong one...
Here it is:
http://assets.nagios.com/downloads/nagi ... ios-XI.pdf
You can either copy the plugin manually to "/usr/local/nagios/libexec" directory or download it and install it via the web UI:
Admin->Manage Plugins->Browse->your plugin->Upload Plugin
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Wed Jan 21, 2015 9:41 pm
by Box293
NSClient++ can do this as it has this functionality built in (no need to download extra scripts):
Check the amount of files in a folder (and sub-folders). Generate a warning if more that 500 files exist, critical if more than 1000 files exist.
Code: Select all
Command:
check_nrpe -H 192.168.142.1 -t 30 -c CheckFiles -a path='C:\\NO BACKUP' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=500 MaxCrit=1000
Output:
{12347 Files Found}, found files: 12347 > critical|'found files'=12347;500;1000
Here's some instructions to install NSClient++:
http://sites.box293.com/nagios/guides/n ... dows/0-4-x
Here's some other file related checks you can do with NSClient++:
http://sites.box293.com/nagios/guides/c ... es-folders
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Thu Jan 22, 2015 10:20 am
by wspackaging
I ran the command and I am getting the following errors in the Nagios log
2015-01-22 09:08:02: error:modules\NRPEListener\NRPEListener.cpp:422: Request contained arguments (not currently allowed, check the allow_arguments option).
2015-01-22 09:08:03: error:modules\NRPEListener\NRPEListener.cpp:320: Exception handling NRPE packet
Any idea where to set those options?
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Thu Jan 22, 2015 10:31 am
by slansing
Yes, so in the nsclient configuration file in it's installation directory, you will want to copy the command from the top that is noted as (Expands the full configuration file). Once copied, open cmd and descend to the nsclient installation directory and issue the command. Now, you will want to re-open that config file, you should see an allow arguments section, simply allow them there, and you should be good to go. There may be additional options you'd like, such as allowing nasty meta characters, etc. You will want to restart the service after this.
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Thu Jan 22, 2015 11:34 am
by wspackaging
Ok found that and enabled. I did restart the service as well. Now when I run it I get "OUTPUT: Parsing failed:"
The one thing I have is a space in a folder directory not sure if that is it but here is the command I am running
check_nrpe -H 10.100.32.120 -t 30 -c CheckFiles -a path='E:\Quest Software\ArchiveManager\Error' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=5 MaxCrit=1000
Am I missing something?
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Thu Jan 22, 2015 1:43 pm
by Box293
Use double \\ in your folder path:
Code: Select all
check_nrpe -H 10.100.32.120 -t 30 -c CheckFiles -a path='E:\\Quest Software\\ArchiveManager\\Error' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=5 MaxCrit=1000
Re: How do I monitor # of files in a folder on a Windows cli
Posted: Thu Jan 22, 2015 1:50 pm
by wspackaging
When I do that then I see 4 "\" in the results
COMMAND: /usr/local/nagios/libexec/check_nrpe -H dc1ms032120 -t 30 -c CheckFiles -a path='E:\\\\Quest Software\\\\ArchiveManager\\\\Error' pattern=\*.\* 'master-syntax=\{%total% Files Found\}' MaxWarn=5 MaxCrit=1000
OUTPUT: Parsing failed:
I entered two arguments for this - one is CheckFiles and the other is the rest of the statement. Is that a problem?
I have attached a pic.