Page 1 of 1

Check command runs on command line but not in Nagios

Posted: Wed Nov 28, 2018 4:34 pm
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

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

Posted: Thu Nov 29, 2018 10:48 am
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\""

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

Posted: Fri Nov 30, 2018 4:13 pm
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.

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

Posted: Mon Dec 03, 2018 5:05 pm
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.