Page 1 of 1

Trying to run a SSH plugin by way of NCPA

Posted: Wed Dec 04, 2019 8:36 am
by jenstar13
Hi,
I'm hoping I just don't have the check formatted correctly and it's an easy fix

The situation :
work wants to basically shut down unnecessary ssh logins to hosts as a security issue
the NCPA cpu/percentage check just does not cut it, if one of the cpus is under load, it alerts and spams everyone even if i set the arguments to 90/95 percent
the old ssh check_load plugin works just fine and doesn't alert all the time
I thought if I dropped the plugin in the /usr/local/ncpa/plugins directory, I could run it by way of ncpa

When I run the check from the nagios instance i get failures, and not sure why
The first is could not parse arguments
/usr/local/nagios/libexec/check_ncpa.py -H hostweb01.example.net -t 'mytoken' -P 5693 -M plugins/check_load -w 30,30,30 -c 50,50,50
check_load: Could not parse arguments
Usage:check_load [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15

So I start using quotes to gather them together and that fails
/usr/local/nagios/libexec/check_ncpa.py -H hostweb01.example.net -t 'mytoken' -P 5693 -M plugins/"check_load -w 30,30,30 -c 50,50,50"
The plugin (check_load -w 30,30,30 -c 50,50,50) requested does not exist. You may be trying to access the 'check_load' node.

No matter where I put the quotes, or if I change them to single ticks it still fails
Can you tell me where I'm screwing up?

Thank you in advance
Jen

Re: Trying to run a SSH plugin by way of NCPA

Posted: Wed Dec 04, 2019 8:55 am
by scottwilkerson
See the "Running Plugins with Arguments" section here
https://www.nagios.org/ncpa/help.php#ac ... the-plugin

Your command would likely need to be something like

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H hostweb01.example.net -t 'mytoken' -P 5693 -M plugins/check_load -q "args=-w '30,30,30',args=-c '50,50,50'"

Re: Trying to run a SSH plugin by way of NCPA

Posted: Wed Dec 04, 2019 9:31 am
by jenstar13
Hi,
it does not like that. I even tried disqualifying the - and same error

/usr/local/nagios/libexec/check_ncpa.py -H myhost.example.net -t 'mytoken' -P 5693 -M plugins/check_load -q "args=-w 30,30,30,args=-c 50,50,50"
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.

I know the check can work with ncpa because i wrote a wrapper, and that executes the check
cat checkload.sh
#!/bin/bash
/usr/lib/nagios/plugins/check_load -r -w 30,30,30 -c 50,50,50

/usr/local/nagios/libexec/check_ncpa.py -H myhost.example.net -t 'mytoken' -P 5693 -M plugins/checkload.sh
OK - load average: 0.11, 0.10, 0.08|load1=0.110;30.000;50.000;0; load5=0.100;30.000;50.000;0; load15=0.083;30.000;50.000;0;

I just do not want to have to write a wrapper for every legacy check that NCPA needs, and then copy that wrapper out to 1000 machines

Re: Trying to run a SSH plugin by way of NCPA

Posted: Wed Dec 04, 2019 9:39 am
by scottwilkerson
you were missing the single quotes I put in there
you ran

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H myhost.example.net -t 'mytoken' -P 5693 -M plugins/check_load -q "args=-w 30,30,30,args=-c 50,50,50"
I suggested

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H hostweb01.example.net -t 'mytoken' -P 5693 -M plugins/check_load -q "args=-w '30,30,30',args=-c '50,50,50'"
On my test machine I got this

Code: Select all

[root@localhost ~]# /usr/local/nagios/libexec/check_ncpa.py -H hostweb01.example.net -t 'mytoken' -P 5693 -M plugins/check_load -q "args=-w '30,30,30',args=-c '50,50,50'"
OK - load average: 0.71, 0.30, 0.22|load1=0.710;30.000;50.000;0; load5=0.300;30.000;50.000;0; load15=0.220;30.000;50.000;0;

Re: Trying to run a SSH plugin by way of NCPA

Posted: Wed Dec 04, 2019 9:55 am
by jenstar13
Sorry, i posted one of my tries instead of what you gave me
/usr/local/nagios/libexec/check_ncpa.py -H hostweb01.example.net -t 'mytoken' -P 5693 -M plugins/check_load -q "args=-w '30,30,30',args=-c '50,50,50'"
This is an exact copy and it fails

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H hostweb01.example.net -t 'mytoken' -P 5693 -M plugins/check_load -q "args=-w '30,30,30',args=-c '50,50,50'" 
check_load: Could not parse arguments
Usage:check_load [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15

ohhhh, this is a 5.9 machine, I just remembered NCPA doesn't like 5.9

I tried it on a redhat 7 box and it works just fine
thank you for your help, you can close this

Re: Trying to run a SSH plugin by way of NCPA

Posted: Wed Dec 04, 2019 10:02 am
by scottwilkerson
jenstar13 wrote:ohhhh, this is a 5.9 machine, I just remembered NCPA doesn't like 5.9

I tried it on a redhat 7 box and it works just fine
thank you for your help, you can close this
Ahhh, glad it is resolved!

Locking thread