Page 1 of 1

How do i pass a Piped Linux command in ncpa -a argument

Posted: Wed Feb 10, 2021 10:55 am
by pratikmehta003
Nagios XI 5.7.4
Example command : uname -a | grep Linux | wc -l
I am using a custom script which accepts a linux command as argument.

I tried many ways to pass the command as argument, but it fails.
ncpa command is like : check_ncpaXXXXX -a "uname -a | grep Linux | wc -l"
check_ncpaXXXXX -a ' "uname -a | grep Linux | wc -l" '
check_ncpaXXXXX -a " 'uname -a | grep Linux | wc -l' "
nagios passes the argument to script like this:
uname/-a/|grep/Linux /|wc/-l --> which is wrong syntax for a command to execute.
How can i modify the argument to pass the entire argument as 1 string with no modification

However on different nagiosxi 5.8.1 , it works smoothly as below:
[[email protected] ~]$ /usr/local/nagios/libexec/check_ncpa.py -H 192.168.230.150 -t 'AoOcAeHmnMKMPiuR' -P 5693 -M plugins/serviceguardchecks.sh -a ' "uname -a |grep Linux | wc -l" '
OK - Status is UP. (value =1)

Re: How do i pass a Piped Linux command in ncpa -a argument

Posted: Wed Feb 10, 2021 8:58 pm
by pratikmehta003
any suggestions?

Re: How do i pass a Piped Linux command in ncpa -a argument

Posted: Thu Feb 11, 2021 4:34 pm
by benjaminsmith
Hi,

Not sure why it's working one system and not the other? What version of NCPA are you running on the remotes systems and what version of Nagiso XI is the one that's not working running.

Code: Select all

./check_ncpa.py --verbose -H <remote-host-ip> -t 'mytoken' -M '/system/agent_version' -q ''
Also, if you could share that custom script? I'd like to run that on my test system here to try and replicate this.

Re: How do i pass a Piped Linux command in ncpa -a argument

Posted: Thu Feb 11, 2021 4:43 pm
by cdienger
Where are you seeing it fail exactly in the XI interface? 7.5.7 version fixed a problem with the 'Run Check Command' button seen when editing a service in the CCM. This should only impact the 'Run Check Command' and shouldn't prevent the nagios process from running the check as expected.

https://assets.nagios.com/downloads/nag ... NGES-5.TXT:
...
- Fixed issue with command escaping in Test Check Command [TPS#15167] -JO
...