Page 1 of 1

JSON String and check_http

Posted: Mon Apr 27, 2020 10:18 am
by NCATmax
I am attempting to monitor a service that returns a JSON string to HTTP requests. Ideally, I would check if a certain string is in the response, but I could settle for just checking that a response is received.

The problem I'm having is that the check_http plugin returns "CRITICAL - Socket timeout" no matter what I do.

The JSON is displayed correctly in a web browser.

The JSON is displayed when using curl.

Code: Select all

$ curl http://<service_ip_address>/api
< JSON_string >
However, check_http is returning an error:

Code: Select all

$ /usr/local/nagios/libexec/check_http -H <service_ip_address> -u "/api"
CRITICAL - Socket timeout
I have tried using using the -v flag, I did not see anything useful.

Code: Select all

$ /usr/local/nagios/libexec/check_http -H <service_ip_address> -u "/api" -v
GET /api HTTP/1.1
User-Agent: check_http/v2.2.1 (nagios-plugins 2.2.1)
Connection: close
Host: <service_ip_address>
Accept: */*


CRITICAL - Socket timeout

I have also tried the "-N" flag. Interestingly, this adds the number of characters to the output, as well as confirming that a 200 HTTP response is received. However, the error is still thrown.

Code: Select all

$ /usr/local/nagios/libexec/check_http -H <service_ip_address> -u "/api" -N -v
GET /api HTTP/1.1
User-Agent: check_http/v2.2.1 (nagios-plugins 2.2.1)
Connection: close
Host: <service_ip_address>
Accept: */*


http://<service_ip_address>:80/api is 1033 characters
STATUS: HTTP/1.1 200 OK
CRITICAL - Socket timeout
Do you have any ideas on why this is not working or how I could go about monitoring this service?



I'm pretty sure I could solve this by making a bash script with the working curl command, and then create a command in Nagios that runs the bash script. While that is definitely possible, I thought the check_http plugin would be able to do this.

Re: JSON String and check_http

Posted: Mon Apr 27, 2020 3:39 pm
by benjaminsmith
Hi @NCatMax,

There is a plugin called check_json available on the Nagios Exchange, take a look at the following page and let me know if this would work for you.

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

Also, the following guide will help you install, test configure a plugin in Nagios XI. Just let me know if you need any assistance.

Managing Plugins In Nagios XI

Re: JSON String and check_http

Posted: Mon Apr 27, 2020 3:48 pm
by cdienger
Your check_http is old as well. Test the latest:

Code: Select all

cd /tmp/
wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
tar zxf nagios-plugins-2.3.3.tar.gz
cd /tmp/nagios-plugins-release-2.3.3/
./tools/setup
./configure
make
cd /tmp/nagios-plugins-2.3.3/plugins
./check_http -H <service_ip_address> -u "/api" -v
./check_http -H <service_ip_address> -u "/api" -v -N

Re: JSON String and check_http

Posted: Mon Apr 27, 2020 4:49 pm
by NCATmax
Thank you both for your responses.

I tried using version 2.3.3 of the nagios plugins and that version worked perfectly.

Without the -v and -N flags, I get the expected "HTTP OK" output. The -v flag correctly shows the JSON string, and the -N flag correctly returns "HTTP OK" while skipping getting the string.

So it seems that this was an issue with version 2.2.1 of the Nagios plugins, which has since been fixed.

One follow-up question, I have been updating Nagios XI using the "Quick" method described here: https://assets.nagios.com/downloads/nag ... ctions.pdf

Does that process not update the plugins? And if not, is that something I need to do separately?

Re: JSON String and check_http

Posted: Tue Apr 28, 2020 9:39 am
by cdienger
Upgrading XI doesn't always upgrade the plugins. I believe the last plugin upgrade that XI triggered was with 5.5 with the 2.2.1 plugins and I believe the 5.7 release of XI will upgrade the plugins to the current version.