Directory monitoring
Re: Directory monitoring
I'm not sure if check_dir is defined as a command on remote hosts but I'm pretty sure it's a standard plugin. The OP might want to see if the check can be defined just from CCM and not touch the remote host. It makes things easier. Here's an example using a random dir. It should warn at 500 files...
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -t 75 -c check_dir -a ' -d /var/www/html/ -w 500'
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -t 75 -c check_dir -a ' -d /var/www/html/ -w 500'
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Directory monitoring
@donnyforbes, Looks like all .txt files are in a subdirectory.
Please change the command to:
Please change the command to:
And restart the nrpe.command[check_files]=/usr/local/nagios/libexec/folder_watch.pl -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
donnyforbes
- Posts: 357
- Joined: Tue Jun 13, 2017 2:17 pm
Re: Directory monitoring
Perfect this worked great! Now I just need to add into the XI for nagios... Can you direct me on this?npolovenko wrote:@donnyforbes, Looks like all .txt files are in a subdirectory.
Please change the command to:And restart the nrpe.command[check_files]=/usr/local/nagios/libexec/folder_watch.pl -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
Thanks
Re: Directory monitoring
Adding a new plugin, command, and service is quite easy in Nagios XI. You can follow the steps, outlined in the document below (skip the steps that you've already done):
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
donnyforbes
- Posts: 357
- Joined: Tue Jun 13, 2017 2:17 pm
Re: Directory monitoring
I have looked at this before, however this does not make since to me. I am not doing a count_down_to_date... I need to add one for the thing I am doing above and not sure how to do this.
-
donnyforbes
- Posts: 357
- Joined: Tue Jun 13, 2017 2:17 pm
Re: Directory monitoring
Here is what I did.
config name: Proxy4gl.domain.com
description: /user/rmca/doc_image check for txt files
check command: check_nrpe
command view: $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
$ARG1$: check_files
$ARG2$: -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
I tested this from the console and here is the output:
******************************************************************************************************************************
[nagios@nag ~]$ /usr/local/nagios/libexec/check_nrpe -H 192.168.1.12 -t 30 -c check_files -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
Last Modified: 09-06-2013
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required
Usage: check_nrpe -H <host> [ -b <bindaddr> ] [-4] [-6] [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]
Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
<bindaddr> = bind to local address
-4 = user ipv4 only
-6 = user ipv6 only
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.
Note:
This plugin requires that you have the NRPE daemon running on the remote host.
You must also have configured the daemon to associate a specific plugin command
with the [command] option you are specifying here. Upon receipt of the
[command] argument, the NRPE daemon will run the appropriate plugin command and
send the plugin output and return code back to *this* plugin. This allows you
to execute plugins on remote hosts and 'fake' the results to make Nagios think
the plugin is being run locally.
**************************************************************************************************************************************
Any idea what I am doing wrong?
config name: Proxy4gl.domain.com
description: /user/rmca/doc_image check for txt files
check command: check_nrpe
command view: $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
$ARG1$: check_files
$ARG2$: -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
I tested this from the console and here is the output:
******************************************************************************************************************************
[nagios@nag ~]$ /usr/local/nagios/libexec/check_nrpe -H 192.168.1.12 -t 30 -c check_files -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
Last Modified: 09-06-2013
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required
Usage: check_nrpe -H <host> [ -b <bindaddr> ] [-4] [-6] [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]
Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
<bindaddr> = bind to local address
-4 = user ipv4 only
-6 = user ipv6 only
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.
Note:
This plugin requires that you have the NRPE daemon running on the remote host.
You must also have configured the daemon to associate a specific plugin command
with the [command] option you are specifying here. Upon receipt of the
[command] argument, the NRPE daemon will run the appropriate plugin command and
send the plugin output and return code back to *this* plugin. This allows you
to execute plugins on remote hosts and 'fake' the results to make Nagios think
the plugin is being run locally.
**************************************************************************************************************************************
Any idea what I am doing wrong?
-
donnyforbes
- Posts: 357
- Joined: Tue Jun 13, 2017 2:17 pm
Re: Directory monitoring
Here is the screenshot of what I did.
You do not have the required permissions to view the files attached to this post.
Re: Directory monitoring
I believe you already "hard-coded" the arguments in your command on the remote box:
Test your command from the command line on the Nagios XI server as such:
As an alternative, you could try to pass arguments in XI (as you had it):
and NRPE restarted.
In this case, you would test your check in Nagios XI by running:
NRPE syntax:
Note: Sometimes, it is easier to hard-code arguments as passing them in Nagios XI could fail because of escaping issues. You need to test both scenarios and see which one works for you.
Hope this helps.
so you don't need to put anything in the $ARG2$ field... You should leave it blank.command[check_files]=/usr/local/nagios/libexec/folder_watch.pl -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
Test your command from the command line on the Nagios XI server as such:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <remote IP> -c check_filesbut in this case, the check_files command on the remote box needs to be defined as such:$ARG2$: -r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
Code: Select all
command[check_files]=/usr/local/nagios/libexec/folder_watch.pl $ARG1$In this case, you would test your check in Nagios XI by running:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <remote IP> -c check_files -a "-r -f -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500"Code: Select all
./check_nrpe -H <ip address> -c <command> -a <arguments>Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
donnyforbes
- Posts: 357
- Joined: Tue Jun 13, 2017 2:17 pm
Re: Directory monitoring
Ok I removed $ARG2$ and then it seemed to work. Just to clarify --- With what I added and did this will notify me if there is more then 500
TXT files correct? Just want to verify this..
Just tested everything and it works : )
Thanks for all your help.
TXT files correct? Just want to verify this..
Just tested everything and it works : )
Thanks for all your help.
Re: Directory monitoring
Yes, you should get a WARNING if the number of files is greater than 480, and CRITICAL if the number of files is greater than 500.With what I added and did this will notify me if there is more then 500
TXT files correct? Just want to verify this..
Let us know if you have any further questions or it's ok to lock this topic. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!