JSON String and check_http
Posted: Mon Apr 27, 2020 10:18 am
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.
However, check_http is returning an error:
I have tried using using the -v flag, I did not see anything useful.
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.
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.
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 >
Code: Select all
$ /usr/local/nagios/libexec/check_http -H <service_ip_address> -u "/api"
CRITICAL - Socket timeout
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
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.