How do I monitor # of files in a folder on a Windows client

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
wspackaging
Posts: 43
Joined: Mon Jul 15, 2013 10:36 am

How do I monitor # of files in a folder on a Windows client

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How do I monitor # of files in a folder on a Windows cli

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
wspackaging
Posts: 43
Joined: Mon Jul 15, 2013 10:36 am

Re: How do I monitor # of files in a folder on a Windows cli

Post 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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How do I monitor # of files in a folder on a Windows cli

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: How do I monitor # of files in a folder on a Windows cli

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
wspackaging
Posts: 43
Joined: Mon Jul 15, 2013 10:36 am

Re: How do I monitor # of files in a folder on a Windows cli

Post 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?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: How do I monitor # of files in a folder on a Windows cli

Post 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.
wspackaging
Posts: 43
Joined: Mon Jul 15, 2013 10:36 am

Re: How do I monitor # of files in a folder on a Windows cli

Post 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?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: How do I monitor # of files in a folder on a Windows cli

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
wspackaging
Posts: 43
Joined: Mon Jul 15, 2013 10:36 am

Re: How do I monitor # of files in a folder on a Windows cli

Post 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.
You do not have the required permissions to view the files attached to this post.
Locked