Unable to get check_procs to run via check_ncpa.py

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Unable to get check_procs to run via check_ncpa.py

Post by skynardo »

Trying to get check_procs plugin to monitor a remote system that is running ncpa_listener, but can't seem to get the command to fire correctly. From the ncpa_listener.log DEBUG, it seems to pre-pend a u' to the command line and I can't figure out why it is doing that. Can anyone see the error of my ways?

example of ncpa_listener.log error
2014-04-29 13:51:51,184 16251 DEBUG Running process with command line: [u'"/usr/local/nagios/libexec/check_procs"']

define service{
use linux-service
host devut514
check_command check_procs!$HOSTNAME$
service_description check_linux_procs
}

define command{
command_name check_procs
command_line $USER1$/check_ncpa.py -H $ARG1$ -t SecretStuff -M agent/plugin/check_procs
}

ncpa_listener.log

2014-04-29 13:51:51,184 16251 DEBUG Running process with command line: [u'"/usr/local/nagios/libexec/check_procs"']
2014-04-29 13:51:51,194 16251 ERROR [Errno 2] No such file or directory
Traceback (most recent call last):
File "/tmp/ncpa/agent/listener/server.py", line 210, in plugin_api
File "/tmp/ncpa/agent/listener/pluginapi.py", line 209, in execute_plugin
File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
if p2cwrite is not None:
File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child
# This method is called (indirectly) by __del__, so it cannot
OSError: [Errno 2] No such file or directory
2014-04-29 13:51:51,198 16251 INFO 10.204.240.28 - - [29/Apr/2014 13:51:51] "GET /api/agent/plugin/check_procs/?token=SecretStuff&check=1 HTTP/1.0" 302 -
2014-04-29 13:51:51,211 16251 INFO 10.204.240.28 - - [29/Apr/2014 13:51:51] "GET /error/Error%20running%20plugin. HTTP/1.0" 200 –

Running check_procs on the remote system

[nagios@devut514 ~]$ /usr/local/nagios/libexec/check_procs
PROCS OK: 130 processes | procs=130;;;0;
Last edited by skynardo on Wed Apr 30, 2014 10:36 am, edited 1 time in total.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Unable to get check_procs to run via check_ncpa.py

Post by slansing »

define service{
use linux-service
host devut514
check_command check_procs!
service_description check_linux_procs
}

define command{
command_name check_procs
command_line $USER1$/check_ncpa.py -H $ARG1$ -t SecretStuff -M agent/plugin/check_procs
}
Are you sure you didn't mean to use $HOSTADDRESS$? Like so?:

Code: Select all

define service{
use linux-service
host devut514
check_command check_procs!-t SecretStuff -M agent/plugin/check_procs
service_description check_linux_procs
}

define command{
command_name check_procs
command_line $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}
It almost looks like you are passing it a command to look for a plugin in a different location, a location where the nagios plugins would be installed to. But in your command you show "agent/plugin/check_procs". What is the exact path to the plugin on the remote host?
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Re: Unable to get check_procs to run via check_ncpa.py

Post by skynardo »

My plugins are located here on the remote host:
/usr/local/nagios/libexec/check_procs

My remote ncpa.cfg has the following entry:
[plugin directives]
plugin_path = /usr/local/nagios/libexec/

Is the issue caused by check_procs not having an extension (i.e. .sh or .pl ) so it is falling through the plugin directives?

When I change the command to:
command_line $USER1$/check_ncpa.py -H $ARG1$ -t SecretStuff -M /usr/local/nagios/libexec/check_procs

I see the following in the ncpa_listener.log on the remote host:
[30/Apr/2014 11:26:46] "GET /api//usr/local/nagios/libexec/check_procs?token=SecretStuff&check=1 HTTP/1.0" 404 -
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Re: Unable to get check_procs to run via check_ncpa.py

Post by skynardo »

I tried the following and it seems to work. Is there a better way to do this?

I had previously added the .p2exe for a home grown plugin I was testing, so I renamed check_procs to check_procs.p2exe and now it seems to be working:

[plugin directives]
plugin_path = /usr/local/nagios/libexec/
.sh = /bin/sh $plugin_name $plugin_args
.p2exe = $plugin_name $plugin_args

Snippet from ncpa_listener.log

2014-04-30 11:41:45,572 16251 INFO 10.204.240.28 - - [30/Apr/2014 11:41:45] "GET /api/agent/plugin/check_procs.p2exe?token=SecretStuff&check=1 HTTP/1.0" 301 -
2014-04-30 11:41:45,582 16251 DEBUG Executing the plugin with instruction contained in config. Instruction is: $plugin_name $plugin_args
2014-04-30 11:41:45,583 16251 DEBUG Running process with command line: ['/usr/local/nagios/libexec/check_procs.p2exe', 'None']
2014-04-30 11:41:45,606 16251 INFO 10.204.240.28 - - [30/Apr/2014 11:41:45] "GET /api/agent/plugin/check_procs.p2exe/?token=SecretStuff&check=1 HTTP/1.0" 200 -
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Unable to get check_procs to run via check_ncpa.py

Post by tmcdonald »

Those debug messages look promising. I say if it works for you, go for it.
Former Nagios employee
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Re: Unable to get check_procs to run via check_ncpa.py

Post by skynardo »

It is working fine, just seems to be a bit of a hack. Was wondering if anyone knows a way to run a plugin (that does not have an extension) with ncpa without having to rename the plugin.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Unable to get check_procs to run via check_ncpa.py

Post by sreinhardt »

I would agree that it should not need to be this way. Let me get an email off to the dev and do some testing internally. However to our knowledge it should not need extensions, and will attempt to use a standard system call to start and exe, scripts likely will need something defined for what shell to use.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked