Check command runs on command line but not in Nagios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
tjderby1
Posts: 2
Joined: Wed Jul 11, 2018 12:49 pm

Check command runs on command line but not in Nagios

Post by tjderby1 »

I am trying to run check_curl_http to check the status of my CouchBase servers. I am using the command line:

Code: Select all

/usr/local/nagios/libexec/check_curl_http -U http://<couchbase>:8091/indexStatus -a 'user':'password' -F -G "\"status\":\"Ready\",\"bucket\":\"cdr\",\"index\":\"cdr_active_calls-2_401\""
This runs on the command line on my Nagios server when run by Nagios user.

Code: Select all

[root@nagios-03]# su nagios
[nagios@nagios-03]$ /usr/local/nagios/libexec/check_curl_http -U http://<couchbase>:8091/indexStatus -a 'user':'password' -F -G "\"status\":\"Ready\",\"bucket\":\"cdr\",\"index\":\"cdr_active_calls-2_401\""
Page OK: HTTP Status Code 200 - 46126 bytes in 0.292478 seconds |time=0.293 size=46126
It also runs when I test it in the "Run Check Command" button in Nagios XI GUI.

But it gives an error when it runs automatically or when I force an immediate check using the GUI.
Critical String "status":"Ready","bucket":"cdr","index":"cdr_active_calls-2_401"$ not found!

I have never had a command work using "Run Check Command" and still not work when run automatically. The "Run Check Command" box runs your check exactly as the Nagios server will run it, or I thought it did anyway.

If anyone has suggestions or an answer for me, please let me know.
Thanks

Todd
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Check command runs on command line but not in Nagios

Post by npolovenko »

Hello, @tjderby1. I think Nagios may be misinterpreting some inner double quotes as the end of the command.

Can you try replacing inner double quotes with single quotes? In this part:
"\"status\":\"Ready\",\"bucket\":\"cdr\",\"index\":\"cdr_active_calls-2_401\""
Another solution is to put the whole command in a wrapper shell script, put the script in the libexec folder and change the command to use the wrapper script instead.
$USER1$/script.sh

Code: Select all

#script.sh
/usr/local/nagios/libexec/check_curl_http -U http://<couchbase>:8091/indexStatus -a 'user':'password' -F -G "\"status\":\"Ready\",\"bucket\":\"cdr\",\"index\":\"cdr_active_calls-2_401\""
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
tjderby1
Posts: 2
Joined: Wed Jul 11, 2018 12:49 pm

Re: Check command runs on command line but not in Nagios

Post by tjderby1 »

@npolovenko, I tried changing the command in this way:

Code: Select all

/usr/local/nagios/libexec/check_curl_http -U http://<couchbase>:8091/indexStatus -a 'User':'Password' -F -G '"status":"Ready","bucket":"cdr","index":"cdr_active_calls-2_401"'
If it's not clear, I replaced the first and last double quotes with single quotes, and removed all of the switches before the double quotes that I need in the search string.
Unfortunately, I get the same result.
So I dropped that same command line into a script, and it runs fine.
Thanks for your help.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Check command runs on command line but not in Nagios

Post by ssax »

Is this the plugin you are running?

https://exchange.nagios.org/directory/P ... tp/details

Which version? If that's not the plugin, please attach the plugin or link to it so that we can test with the same version.
Locked