Possible bug in check_http

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
bomahony
Posts: 133
Joined: Wed Jul 04, 2018 10:46 am

Possible bug in check_http

Post by bomahony »

This was absolutely wrecking my head for the last few hours.

I am checking two things on a swathe of servers with check http:
-p 5229 -u /status -w 0.1 -c 1 -s "UP" -d "Server version"
-p 9090 -u /status -w 0.1 -c 1 -s "UP" -d "Server version"

Second one is failing in XI. Here is what I did to troubleshoot:
Start with CLI, check_http -H: Both worked.
Curl: Both worked.
Removed all options from GUI except -u, 9090 still fails.

I then realised the command string in XI uses -I instead of -H, so I tried that from the CLI:
Used -H, boith worked with all parameters.
Used -I 5229 worked, 9090 failed for all parameters. Stripped down to -u /status, same issue.

Any idea why? We have many many check_http commands, and I dont want to mangle the environments by forcing the command syntax to use -H
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Possible bug in check_http

Post by scottwilkerson »

Can you show the error it is failing on?

Can you run the command with the -vvv flag and show the verbose output?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
bomahony
Posts: 133
Joined: Wed Jul 04, 2018 10:46 am

Re: Possible bug in check_http

Post by bomahony »

Using -I:
user0001@mon01 0 15:26:33 /usr/local/nagios/libexec $ ./check_http -I srv-003 -p 5229 -u /status
HTTP OK: HTTP/1.1 200 OK - 439 bytes in 0.001 second response time |time=0.001450s;;;0.000000 size=439B;;;0
user0001@mon01 0 15:26:36 /usr/local/nagios/libexec $ ./check_http -I srv-003 -p 9090 -u /status
HTTP WARNING: HTTP/1.0 404 Not Found - 482 bytes in 0.001 second response time |time=0.001095s;;;0.000000 size=482B;;;0

Using Hostname:
user0001@mon01 1 15:26:42 /usr/local/nagios/libexec $ ./check_http -H srv-003 -p 5229 -u /status
HTTP OK: HTTP/1.1 200 OK - 439 bytes in 0.002 second response time |time=0.001747s;;;0.000000 size=439B;;;0
user0001@mon01 0 15:26:54 /usr/local/nagios/libexec $ ./check_http -H srv-003 -p 9090 -u /status
HTTP OK: HTTP/1.1 200 OK - 435 bytes in 0.002 second response time |time=0.001700s;;;0.000000 size=435B;;;0
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Possible bug in check_http

Post by scottwilkerson »

From the help

Code: Select all

 -H, --hostname=ADDRESS
    Host name argument for servers using host headers (virtual host)
    Append a port to include it in the header (eg: example.com:5000)
 -I, --IP-address=ADDRESS
    IP address or name (use numeric address if possible to bypass DNS lookup).
It would be my assumption that the service listening on srv-003 port 9090 requires the host headers of "srv-003" to be sent for the response
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
bomahony
Posts: 133
Joined: Wed Jul 04, 2018 10:46 am

Re: Possible bug in check_http

Post by bomahony »

Note. I changed some vars to anonymous the data.
It works from curl with IP or Hostname.
[code]
user0001@mon01 35 14:57:21 ~ $ curl http://srv-003:9090/status
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>Status</TITLE>
</HEAD><BODY>
<p>Server status is: UP<p>
<P>
<HR>
<ADDRESS>Server version 9.5 at srv-003</ADDRESS>
</BODY></HTML>

user0001@mon01 0 14:57:35 ~ $ nslookup srv-003
Server: 10.2.X.X
Address: 10.2.X.X#53

Name: srv-03.domain.com
Address: 10.2.X.X

user0001@mon01 0 14:57:55 ~ $ curl http://10.2.X.X:9090/status
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>Status</TITLE>
</HEAD><BODY>
<p>Server status is: UP<p>
<P>
<HR>
<ADDRESS>Server version 9.5 at 10.2.X.X</ADDRESS>
</BODY></HTML>
[/code]
Using -v it doesnt even find the page:
/usr/local/nagios/libexec/check_http -I srv-003 -p 9090 -u /status -v
GET /status HTTP/1.0
User-Agent: check_http/v2.2.1 (nagios-plugins 2.2.1)
Connection: close
Accept: */*
http://srv-003:9090/status is 482 characters
STATUS: HTTP/1.0 404 Not Found
**** HEADER ****
Content-Type: text/html
Date: Wed, 28 Nov 2018 15:06:05 GMT
Server: Server version 9.5
Content-Length: 300
**** CONTENT ****
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not Found</TITLE>
</HEAD><BODY>
<H1>Not Found</H1>
Requested URL not found on this server
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Possible bug in check_http

Post by scottwilkerson »

When running the wizard in XI it should be using the IP address entered and the hostname

Code: Select all

./check_http -H srv-003 -I 10.2.X.X -p 9090 -u /status
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
bomahony
Posts: 133
Joined: Wed Jul 04, 2018 10:46 am

Re: Possible bug in check_http

Post by bomahony »

Check HTTP is id14, so I dont think I added it:
$USER1$/check_http -I $HOSTADDRESS$ $ARG1$
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Possible bug in check_http

Post by scottwilkerson »

Ahh, then you may need to add -H srv-003 to the $ARG1$ field
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
bomahony
Posts: 133
Joined: Wed Jul 04, 2018 10:46 am

Re: Possible bug in check_http

Post by bomahony »

Sorry it took so long to reply. Was stuck doing other crap :lol:

Two option I have are:
1. Replace -I with -H in the check command
2. Add an extra -H to the $ARG1$

Will an update overwrite the check commands perchance?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Possible bug in check_http

Post by scottwilkerson »

bomahony wrote:Will an update overwrite the check commands perchance?
No, the check commands are part of the configuration which are not overwritten on an update
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked