Page 1 of 2

plugin to monitor number of files in a directory

Posted: Wed Mar 06, 2013 12:46 pm
by infrati.fornecedores
Hello

I would like to monitor the amount of files in a directory from a Windows server.

Found that at the site of Nagios that there are some plugins that make this function, for example:

directory_file_count

check_winfile-1.5

count_file.pl

check_file_count

Could you help me what I have to configures the Nagios server and Windows server to do this monitoring?

Example:

I need to monitor the directory c: \ temp if you have more than 50 files send an e-mail with a warning, and if you are over 70 files forward an e-mail to critical.

thank you

Romario Faria

Re: plugin to monitor number of files in a directory

Posted: Wed Mar 06, 2013 1:46 pm
by slansing
Hello,

First we will want to configure NSClient++ with windows, have you done this already?

Please take a look at the following documentation for a guide on how to do this:

http://assets.nagios.com/downloads/nagi ... _Agent.pdf

http://www.nsclient.org/nscp/wiki/doc/installation

I would suggest using the most lightweight of the check_file checks as it is a pretty simple check, it all depends on what you would like to do beyond getting the standard count.

Re: plugin to monitor number of files in a directory

Posted: Thu Mar 07, 2013 8:37 am
by infrati.fornecedores
hello,

The client already installed on Windows servers I want to monitor.

Now to use the plugin suggested check_file what I have to do in the Nagios server and Windows?

Not yet installed any plugin in Nagios so I have some doubts that how to configure it to work.

Example:

The plugin on the Nagios server must fiicar in which directory? / usr / local / nagios / libexec this path is correct?

After adding the plugin in any server I edit file information with this new plugin?

And the Windows client is some configuration needed?

thanks

Re: plugin to monitor number of files in a directory

Posted: Thu Mar 07, 2013 10:22 am
by slansing
You will need to add the plugin to the scripts folder within the NSClient++ directory on your windows system, then we must define it in the nsclient/NSC.ini file as an external script, and create an alias for it to be called from the nagios xi server. These steps are outlined below:

In the scripts section of the following documentation an example is outlined for adding the external script's definition to NSClient++'s configuration file:

http://www.nsclient.org/nscp/wiki/doc/c ... ptSections

For version 0.4.x please view this version:

http://www.nsclient.org/nscp/wiki/doc/c ... IPTSECTION

Let us know if you need help in between these steps or afterwords.

Re: plugin to monitor number of files in a directory

Posted: Thu Mar 07, 2013 3:14 pm
by infrati.fornecedores
hello,

Thanks for the information, now I need an aid in relation to check_file.vbs

He is returning this error:

C:\Program Files\NSClient++\scripts\check_files.vbs(132, 1) Microsoft VBScript runtime error: Class not defined: 'NagiosPlugin'

Re: plugin to monitor number of files in a directory

Posted: Thu Mar 07, 2013 4:27 pm
by slansing
Hello infrati.fornecedores,

Can you provide us with a link to the specific plugin you are using so that we can give it a test run as well?

Re: plugin to monitor number of files in a directory

Posted: Fri Mar 08, 2013 7:14 am
by infrati.fornecedores
Hello,

This is the vbs script to install mode dretorio the Nagios client.

C: \ Program Files \ NSClient + + \ scripts \ check_files.vbs

Re: plugin to monitor number of files in a directory

Posted: Fri Mar 08, 2013 11:39 am
by lmiltchev
You should have the following line in the NSC.ini (or nsclient.ini) file on the windows box:

Code: Select all

[Wrapped Scripts]
check_files=check_files.vbs $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$ $ARG9$ $ARG10$ $ARG11$ $ARG12$ $ARG13$ $ARG14$
or could be under [/settings/external scripts/wrapped scripts] in the newer versions of nsclient++

Then you can call the "check_files" command from nagios via check_nrpe, for example you can run something like this:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a '/path:"c:\\tmp" /searchdepth:1 /warning:10 /critical:20'
OK: Testing c://tmp  newer than 5 d : 0 w:10 c: 20|count=0;10;20
I would recommend opening the check_files.vbs in a text editor, and reading the comments. There are some usage examples in it.

Re: plugin to monitor number of files in a directory

Posted: Fri Mar 08, 2013 1:23 pm
by infrati.fornecedores
hello, lmiltchev.

The settings that are in the comments of the file check_files already done.

When I run this command

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a '/path:"c:\\tmp" /searchdepth:1 /warning:10 /critical:20'


message is presented below:

C:\Program Files\NSClient++\scripts\check_files.vbs(132, 1) Microsoft VBScript runtime error: Class not defined: 'NagiosPlugin'

he says that the class "Nagios Plugin" was not defined, it is possible to send you the file that you used in the test?

thank you

Re: plugin to monitor number of files in a directory

Posted: Fri Mar 08, 2013 3:03 pm
by lmiltchev
Please, post your NSC.ini (or nsclient.ini) file. Remove the sensitive data - IPs, passwords, etc.