Page 1 of 1

Nagios not recognising HTTP Header

Posted: Tue Jun 22, 2021 12:24 pm
by apteancloud
I am trying to monitor a HTTPS URL which works from browser, but isnt giving me a output on Nagios.

Browser:
NagiosXIBrowser.JPG
From NagiosXI:

Code: Select all

[nagios@NagiosXIAzDev ~]$ /usr/local/nagios/libexec/check_http -H MYDOMAIN.com -f ok -u '/healthcheck?productName=MYPRODUCT&clientName=MYCLIENT' -S --sni -k 'token:TOKENID' -r 'status...Success'
HTTP CRITICAL: HTTP/1.1 200 OK - pattern not found - 487 bytes in 0.176 second response time |time=0.176352s;;;0.000000 size=487B;;;0

Code: Select all

[nagios@NagiosXIAzDev ~]$ /usr/local/nagios/libexec/check_http -H MYDOMAIN.com -f ok -u '/healthcheck?productName=MYPRODUCT&clientName=MYCLIENT' -S --sni -k 'token:TOKENID' -r 'status...Success' -vvv
SSL initialized
GET /healthcheck?productName=MYPRODUCT&clientName=MYCLIENT HTTP/1.1
User-Agent: check_http/v2.3.3 (nagios-plugins 2.3.3)
Connection: close
Host: MYDOMAIN.com
Accept: */*
token:TOKENID


https://MYDOMAIN.com:443/healthcheck?productName=MYPRODUCT&clientName=MYCLIENT is 490 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Date: Tue, 22 Jun 2021 17:21:06 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Strict-Transport-Security: max-age=15552000
CF-Cache-Status: DYNAMIC
cf-request-id: 0ad656816f00005a4bef29b000000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 663726af1c925a4b-IAD
**** CONTENT ****
{"status":"Success","description":"Tests ran successfully"}
HTTP OK: HTTP/1.1 200 OK - 490 bytes in 0.656 second response time |time=0.655741s;;;0.000000 size=490B;;;0
You can see the Content is correct, yet it is complaining about incorrect pattern.
Also to add, the URL comes as https://MYDOMAIN.com:443, instead of https://MYDOMAIN.com. I dont want the port number to come across.
Not sure what is wrong here.

Re: Nagios not recognising HTTP Header

Posted: Tue Jun 22, 2021 4:30 pm
by dchurch
Those two commands solicited different results from the server each time.

Code: Select all

HTTP CRITICAL: HTTP/1.1 200 OK - pattern not found - 487 bytes in 0.176 second response time |time=0.176352s;;;0.000000 size=487B;;;0

Code: Select all

HTTP OK: HTTP/1.1 200 OK - 490 bytes in 0.656 second response time |time=0.655741s;;;0.000000 size=490B;;;0
The first request returned 487 bytes, and the second one returned 490 bytes.

The reason it would say "pattern not found" is if the -r status...Success wasn't found in the response body. Such as if it returned {"status":"Error"}

Does it fail every time you run it, or is it intermittent?

Re: Nagios not recognising HTTP Header

Posted: Mon Jul 19, 2021 10:18 am
by apteancloud
I think this thread can be archived. No one chased me for this from my org, so I guess I have nothing to chase after either... :lol: :lol:

Re: Nagios not recognising HTTP Header

Posted: Mon Jul 19, 2021 1:46 pm
by dchurch
Glad to hear you resolved it! Locking thread.

If you have any additional issues, feel free to make a new thread.