Trying to setup plugin check_numoffiles.sh
-
- Posts: 29
- Joined: Wed Apr 08, 2015 1:55 pm
Trying to setup plugin check_numoffiles.sh
I have downloaded the check_numoffile.sh plugin to warn me if the number of files in a directory exceeds a particular number.
I have tried to follow their usage example but cannot get it to pass the pre-check.
At first the issue was the command was not defined any where. So, I started looking at \nagios\etc\objects\command.cfg
I cannot figure out the proper syntax in my command.cfg. Below is the line I have in mine now:
#'check_numoffiles' command definition
define command{
command_name check_numoffiles
command_line $USER1$/check_numoffiles -d $PATH$ -w $WARN$ -c $CRIT$
}
This is the service definition below from my server object config file:
define service{
use doceserve-services
host_name doc-e-serve
service_description Active Folder Check
check_command check_numoffiles -d C:\DoceServe\Active -w 2 -c 4
}
Also, I placed the plugin "check_numoffiles.ssh" in my /nagios/libexec folder.
I am running Nagios Core Version 4.0.8 with the plugins package.
I have tried to follow their usage example but cannot get it to pass the pre-check.
At first the issue was the command was not defined any where. So, I started looking at \nagios\etc\objects\command.cfg
I cannot figure out the proper syntax in my command.cfg. Below is the line I have in mine now:
#'check_numoffiles' command definition
define command{
command_name check_numoffiles
command_line $USER1$/check_numoffiles -d $PATH$ -w $WARN$ -c $CRIT$
}
This is the service definition below from my server object config file:
define service{
use doceserve-services
host_name doc-e-serve
service_description Active Folder Check
check_command check_numoffiles -d C:\DoceServe\Active -w 2 -c 4
}
Also, I placed the plugin "check_numoffiles.ssh" in my /nagios/libexec folder.
I am running Nagios Core Version 4.0.8 with the plugins package.
Re: Trying to setup plugin check_numoffiles.sh
Could you share the guide you followed?
I assume you are referring to this plugin?
https://exchange.nagios.org/directory/P ... nt/details
Couple of things:
Your command definition uses the $PATH$, $WARN$, and $CRIT$ macros. Are these macros defined anywhere? Info about macros:
https://assets.nagios.com/downloads/nag ... acros.html
This Service definition is not properly formatted for passing arguments. Also, on the receiving end with your Command definition accepting arguments generally uses the built-in macros $ARG1$, $ARG2$, $ARG3$, $ARGn$. See the above macros document for further information on this.
Is your Nagios Core installation running on a Windows machine? That looks like a Windows file path, where as the check_numoffiles.sh plugin is written as a shell script. Shell scripts will not run on Windows typically without the introduction of something like cygwin.
I assume you are referring to this plugin?
https://exchange.nagios.org/directory/P ... nt/details
Couple of things:
Code: Select all
define command{
command_name check_numoffiles
command_line $USER1$/check_numoffiles -d $PATH$ -w $WARN$ -c $CRIT$
}
https://assets.nagios.com/downloads/nag ... acros.html
Code: Select all
define service{
use doceserve-services
host_name doc-e-serve
service_description Active Folder Check
check_command check_numoffiles -d C:\DoceServe\Active -w 2 -c 4
}
Is your Nagios Core installation running on a Windows machine? That looks like a Windows file path, where as the check_numoffiles.sh plugin is written as a shell script. Shell scripts will not run on Windows typically without the introduction of something like cygwin.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- Posts: 29
- Joined: Wed Apr 08, 2015 1:55 pm
Re: Trying to setup plugin check_numoffiles.sh
The part here I was guessing.
define command{
command_name check_numoffiles
command_line $USER1$/check_numoffiles -d $PATH$ -w $WARN$ -c $CRIT$
}
define command{
command_name check_numoffiles
command_line $USER1$/check_numoffiles -d $PATH$ -w $WARN$ -c $CRIT$
}
-
- Posts: 29
- Joined: Wed Apr 08, 2015 1:55 pm
Re: Trying to setup plugin check_numoffiles.sh
Nagios COre itself is running on Ubunto Linux. The folder it is checking is a windows host though.
They did not really have a guide to follow for this plugin. I found the plugin itself off the Nagios site.
They did not really have a guide to follow for this plugin. I found the plugin itself off the Nagios site.
-
- Posts: 29
- Joined: Wed Apr 08, 2015 1:55 pm
Re: Trying to setup plugin check_numoffiles.sh
I change the code in command.cfg to the following based on the replies:
I am still running into the following error when I run the pre-check.
-------------------------------------------------------------------------------------------------------------------------
Error: Service check command 'check_numofffiles -d C:\DoceServe\Active -w 2 -c 4' specified in service 'Active Folder Check' for host 'doc-e-serve' not defined anywhere.
-------------------------------------------------------------------------------------------------------------------------
Below is the code for the service from the host object cfg file.
Code: Select all
#'check_numoffiles' command definition
define command{
command_name check_numoffiles
command_line $USER1$/check_numoffiles -d $ARG1$ -w $ARG2$ -c $ARG3$$
}
-------------------------------------------------------------------------------------------------------------------------
Error: Service check command 'check_numofffiles -d C:\DoceServe\Active -w 2 -c 4' specified in service 'Active Folder Check' for host 'doc-e-serve' not defined anywhere.
-------------------------------------------------------------------------------------------------------------------------
Below is the code for the service from the host object cfg file.
Code: Select all
define service{
use doceserve-services
host_name doc-e-serve
service_description Active Folder Check
check_command check_numoffiles -d C:\DoceServe\Active -w 2 -c 4
}
Re: Trying to setup plugin check_numoffiles.sh
Your command definition has an extra $ on the 3rd argument. Your Service definition is pretty close! Example 2 in the docs I linked shows how to pass arguments in a Service definition:
Your Service definition should look like this:
It's also worth mentioning that Nagios Core by itself has virtually no way to talk to a remote Windows machine (except ping/telnet) unless that Windows machine has an agent installed. Here's a document that briefly describes the process of setting up an agent on a Windows machine and monitoring that machine:
https://assets.nagios.com/downloads/nag ... ndows.html
Looking at the source, the check_numoffiles plugin doesn't have a way to request information from a remote machine; Everything is local. Also since it is written as a shell script, it is not an ideal candidate for monitoring a Windows environment.
Your Service definition should look like this:
Code: Select all
define service{
use doceserve-services
host_name doc-e-serve
service_description Active Folder Check
check_command check_numoffiles!C:\DoceServe\Active!2!4
}
https://assets.nagios.com/downloads/nag ... ndows.html
Looking at the source, the check_numoffiles plugin doesn't have a way to request information from a remote machine; Everything is local. Also since it is written as a shell script, it is not an ideal candidate for monitoring a Windows environment.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- Posts: 29
- Joined: Wed Apr 08, 2015 1:55 pm
Re: Trying to setup plugin check_numoffiles.sh
I have an agent both the old nsclient agent and the NRPE agent runningon the host windows machine.
I will fix my extra $ and the command line for the service and let you know. Thanks!!
I will fix my extra $ and the command line for the service and let you know. Thanks!!
-
- Posts: 29
- Joined: Wed Apr 08, 2015 1:55 pm
Re: Trying to setup plugin check_numoffiles.sh
So, I am real close.
I was able to get things to pass the verification. However, I get the following warning from Nagios.
It is complaining about the path.
-----------------------
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_numoffiles, ...) failed. errno is 2: No such file or directory
-----------------------
Command Code:
Service Code:
I think the issue now is the path or how I am passing it. Not sure if I need quotes, etc...
I was able to get things to pass the verification. However, I get the following warning from Nagios.
It is complaining about the path.
-----------------------
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_numoffiles, ...) failed. errno is 2: No such file or directory
-----------------------
Command Code:
Code: Select all
#'check_numoffiles' command definition
define command{
command_name check_numoffiles
command_line $USER1$/check_numoffiles -d $ARG1$ -w $ARG2$ -c $ARG3$
}
Code: Select all
define service{
use doceserve-services
host_name doc-e-serve
service_description Active Folder Check
check_command check_numoffiles!C:\DoceServe\Active!2!4
}
Re: Trying to setup plugin check_numoffiles.sh
Are you certain the file /usr/local/nagios/libexec/check_numoffiles exists? The plugin I referenced is originally named check_nomoffiles.sh. If this is the plugin you are using, I would verify it's path. I would also make sure the nagios command group and user has permission to execute the script.
Also, if your intention is to use this plugin to check the number of files on a remote machine, you would need to put that script on the remote machine and execute it via check_nt, check_nrpe, or check_by_ssh.
Also, if your intention is to use this plugin to check the number of files on a remote machine, you would need to put that script on the remote machine and execute it via check_nt, check_nrpe, or check_by_ssh.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- Posts: 29
- Joined: Wed Apr 08, 2015 1:55 pm
Re: Trying to setup plugin check_numoffiles.sh
I have corrected the command syntax.
I now get (Return code of 13 is out of bounds) in the Nagios reported error.
Command Definition Code:
Service Definition Code:
I now get (Return code of 13 is out of bounds) in the Nagios reported error.
Command Definition Code:
Code: Select all
#'check_numoffiles' command definition
define command{
command_name check_numoffiles.sh
command_line $USER1$/check_numoffiles.sh -d $ARG1$ -w $ARG2$ -c $ARG3$
}
Code: Select all
define service{
use doceserve-services
host_name doc-e-serve
service_description Active Folder Check
check_command check_numoffiles.sh!C:\DoceServe\Active\!2!4
}