check_ncpa not passing arguments?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jvestrum
Posts: 46
Joined: Tue Mar 03, 2015 10:45 am

check_ncpa not passing arguments?

Post by jvestrum »

Hello - I'm using NCPA 1.8.1 and trying to get a plugin (check_drbd) working. I need to pass it an argument but it doesn't seem to get through. I know it's finding the plugin because of the output:

xi-server$ ./check_ncpa.py -H myhost -t mytoken -M agent/plugin/check_drbd -a "-d All"
DRBD UNKNOWN: Could not find device 0

When I run the plugin locally with the "-d All" argument I get the DRBD OK I'm looking for. Is my check_ncpa.py syntax right? I'm following this: https://assets.nagios.com/downloads/ncp ... un-by-ncpa
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_ncpa not passing arguments?

Post by ssax »

Looks right, please run the command from the command line and post the entire output (we do not have DRBD configured here):

Code: Select all

./check_drbd -d all
Does it differ?


Thank you
jvestrum
Posts: 46
Joined: Tue Mar 03, 2015 10:45 am

Re: check_ncpa not passing arguments?

Post by jvestrum »

Yes, it works running it locally on the host:

Code: Select all

# ./check_drbd -d all
DRBD OK: Dev 1 ConUpT, Dev 3 ConUpT, Dev 6 ConUpT
The "DRBD UNKNOWN: Could not find device 0" is what you get if you run it without arguments (it defaults to looking for device 0, which doesn't exist in my case).
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_ncpa not passing arguments?

Post by ssax »

Please edit the check_drbd plugin and change this (around line 265):

Code: Select all

&myexit('UNKNOWN',"Could not find device $device");
To this:

Code: Select all

&myexit('UNKNOWN',"Could not find device $device - $drbd_devices");
Then run it through NCPA again and post the output.
jvestrum
Posts: 46
Joined: Tue Mar 03, 2015 10:45 am

Re: check_ncpa not passing arguments?

Post by jvestrum »

Okay, I've done that. The output is always the same, no matter what arguments I pass:

Code: Select all

# ./check_ncpa.py -H myhost -t mytoken -M agent/plugin/check_drbd -a '-d all'
DRBD UNKNOWN: Could not find device 0 - 0
# ./check_ncpa.py -H myhost -t mytoken -M agent/plugin/check_drbd -a '-d All'
DRBD UNKNOWN: Could not find device 0 - 0
# ./check_ncpa.py -H myhost -t mytoken -M agent/plugin/check_drbd -a '--help'
DRBD UNKNOWN: Could not find device 0 - 0
I could just change the check_drbd script to make the default device "All" and then it works. But it would be nice to get the check_ncpa.py -a working.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_ncpa not passing arguments?

Post by ssax »

Please PM me your /usr/local/nagios/etc/ncpa.cfg file.

That's very strange, arguments don't seem to be working for you, I get different output.

Also, please run this on the client and then run the check again:

Code: Select all

service ncpa_listener restart
Then send the output of this command on the client:

Code: Select all

tail -n100 /usr/local/ncpa/var/ncpa_listener.log
Thank you
jvestrum
Posts: 46
Joined: Tue Mar 03, 2015 10:45 am

Re: check_ncpa not passing arguments?

Post by jvestrum »

Okay, I'm finally getting back around to this. After some experimentation I found that the first syntax below fails, but the second one works:

Code: Select all

# ./check_ncpa.py -H myhost -t mytoken -M agent/plugin/check_drbd --arguments='-d All'
DRBD UNKNOWN: Could not find device 0 - 0
# ./check_ncpa.py -H myhost -t mytoken -M agent/plugin/check_drbd/-d/All/
DRBD OK: Dev 1 ConUpT, Dev 3 ConUpT, Dev 6 ConUpT
Here are the corresponding snippets from the ncpa_listener log:

Code: Select all

2016-06-06 12:51:53,645 130613 DEBUG Initializing WebSocket
2016-06-06 12:51:53,646 130613 DEBUG Validating WebSocket request
2016-06-06 12:51:53,648 130613 DEBUG Running process with command line: `plugins/check_drbd`
2016-06-06 12:51:53,677 130613 INFO 169.10.69.96 - - [2016-06-06 12:51:53] "GET /api/agent/plugin/check_drbd?token=mytoken&check=1&arguments=-d+All HTTP/1.0" 200 314 0.031747
2016-06-06 12:51:54,443 130613 DEBUG Initializing WebSocket
2016-06-06 12:51:54,443 130613 DEBUG Validating WebSocket request
2016-06-06 12:51:54,444 130613 DEBUG Running process with command line: `plugins/check_drbd -d All`
2016-06-06 12:51:54,475 130613 INFO 169.10.69.96 - - [2016-06-06 12:51:54] "GET /api/agent/plugin/check_drbd/-d/All/?token=mytoken&check=1 HTTP/1.0" 200 322 0.031773
I'll PM you that ncpa.cfg, I think the only things I changed was setting debug loglevel and the community_string.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_ncpa not passing arguments?

Post by lmiltchev »

Can you run the following commands and show the output?

On the Nagios XI server:

Code: Select all

./check_ncpa.py -H myhost -t mytoken -P 5693 -M agent/plugin/check_drbd -a '-d All' -v
./check_ncpa.py -H myhost -t mytoken -P 5693 -M agent/plugin/check_drbd -a '--help' -v
On the remote box:

Code: Select all

grep plugin_path /usr/local/ncpa/etc/ncpa.cfg
updatedb
locate check_drdb
BTW, I was not able to recreate the issue. Passing arguments (with "-a") seems to be working for me.

Code: Select all

[root@localhost libexec]# ./check_ncpa.py -H x.x.x.x -t mytoken -P 5693 -M agent/plugin/check_drdb -a '--help'
check_drdb 0.5.3

The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Usage: check_drdb [-d <All|Configured|...>] [-e expect] [-p proc] [-r role] [-o states] [-w states] [-c states] [--debug]
        Options:
        -d STRING [default: 0.  Example: 0,1,2 ]
        -p STRING [default: /proc/drbd.  Use '-' for stdin]
        -e STRING [Must be this connected state. Example: Connected]
        -r STRING [Must be this node state. Example: Primary]
        -o STRING [Change value to OK. Example: StandAlone]
        -w STRING [Change value to WARNING. Example: SyncingAll]
        -c STRING [Change value to CRITICAL. Example: Inconsistent,WFConnection]

Send email to [email protected] if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to [email protected]
...another plugin

Code: Select all

[root@localhost libexec]# ./check_ncpa.py -H x.x.x.x -t mytoken -P 5693 -M agent/plugin/custom_check_mem -a '-w 20 -c 10 -n'
OK - 1018 / 3962 MB (25%) Free Memory, Used: 3237 MB, Shared: 0 MB, Buffers: 158 MB, Cached: 293 MB | total=3962MB free=1018MB used=3237MB shared=0 buffers=158MB cached=293MB
Be sure to check out our Knowledgebase for helpful articles and solutions!
jvestrum
Posts: 46
Joined: Tue Mar 03, 2015 10:45 am

Re: check_ncpa not passing arguments?

Post by jvestrum »

So, I was using an old check_ncpa.py on the XI server. I think it came with the XI install? In any case, I got the latest check_ncpa.py from GitHub and now everything works fine.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_ncpa not passing arguments?

Post by lmiltchev »

Great! I am closing this thread, and marking it as "resolved". If you have any more questions, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked