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

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
pratikmehta003
Posts: 105
Joined: Thu Apr 09, 2020 7:35 am

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

Post 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)
pratikmehta003
Posts: 105
Joined: Thu Apr 09, 2020 7:35 am

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

Post by pratikmehta003 »

any suggestions?
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

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

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

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

Post 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
...
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked