Puzzling problem with check_http

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Cloudmaster
Posts: 6
Joined: Wed Dec 12, 2012 7:11 pm

Puzzling problem with check_http

Post by Cloudmaster »

Hi all,

For a while I've been checking a website with check_http, today I moved the site to a different IP, changed the DNS etc. and everything still works as it should, except that Nagios is showing CRITICAL / Connection refused on the web interface, though when I run check_http manually it checks out ok

[root@gbp libexec]# ./check_http -H http://www.mysite.com
HTTP OK: HTTP/1.1 200 OK - 1093 bytes in 0.176 second response time |time=0.175845s;;;0.000000 size=1093B;;;0

Anyone see any obvious problems? I should add that I've tried restarting Nagios & DNS lookups from the Nagios server give the correct IP
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Puzzling problem with check_http

Post by sreinhardt »

I could understand this, if the nagios machine had not yet updated dns, however since you are able to run it manually, that should not be the issue. Could you verify, if you have not already, that the check you are using within nagios is configured the same as the check-http you used manually? No additional parameters or anything.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Cloudmaster
Posts: 6
Joined: Wed Dec 12, 2012 7:11 pm

Re: Puzzling problem with check_http

Post by Cloudmaster »

No additional parameters -

check_http!www.mysite.com

I should add that as I've changed the website IP, that now differs from the IP set as the host address at the top of the relevant host.cfg file, though as the given hostname resolves correctly I can't see that making any difference, hope that makes sense

Edit: I've found the problem, it seems all checked services do have to be listening on the same IP as that defined in the 'define host' section of the host.cfg. If that's the case how can I monitor services running on different IP's and have them viewable in the same host block on the web interface?
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Puzzling problem with check_http

Post by sreinhardt »

Within that individual check command, please try changing from the dns name or $HOSTADDRESS$ to the direct IP address. You may end up needing to define an additional command something like below, to use instead.

Code: Select all

Old Command:
Define command {
command_name check-http
command_line $USER1$/check-http –H $HOSTADDRESS$ -w 10.0 -c 30
}


New Command:
Define command {
command_name check-http-ip
command_line $USER1$/check_http –H 1.2.3.4 -w 10.0 -c 30
}
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Cloudmaster
Posts: 6
Joined: Wed Dec 12, 2012 7:11 pm

Re: Puzzling problem with check_http

Post by Cloudmaster »

Correct me if I'm wrong, but I don't think that'll work since there are a number of sites listening on the same IP (also, check_http already allows you to define an IP address)
Cloudmaster
Posts: 6
Joined: Wed Dec 12, 2012 7:11 pm

Re: Puzzling problem with check_http

Post by Cloudmaster »

Not an ideal solution but I've cracked it

In the host.cfg I created another 'define host' block with the website's IP and a different host_name / alias. This now works but I see it as a different host under Services in the web interface where I wanted all service on the same host to be in the same block.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Puzzling problem with check_http

Post by sreinhardt »

You are correct, I did not see the -I flag on check_http. If there are a number of sites listening on that same machine, you may also run into an issue as you imagined. I do not believe, check_http really verifies that the site you state is actually where it is pointing. For instance, I checked microsoft.com, then checked it again with google's IP and came back with different results.

Code: Select all

[root@CentOS-X86-64-Base libexec]# ./check_http -H microsoft.com
HTTP OK - HTTP/1.1 301 Moved Permanently - 0.182 second response time |time=0.181808s;;;0.000000 size=484B;;;0
[root@CentOS-X86-64-Base libexec]# ./check_http -H microsoft.com -I 74.125.227.37
HTTP OK - HTTP/1.0 302 Found - 0.117 second response time |time=0.116674s;;;0.000000 size=477B;;;0
So I believe unless you are actually telling it to check for a specific string, it seems it only verifies that the port is open and sending valid http data. You should be fine by modifying your command with the -I [IP] flag to keep it within the same host and correctly monitor your web server. I would also suggest using the -s -r or -u, commands to check for a string or regex within the page, or check a specific uri aside from /.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Cloudmaster
Posts: 6
Joined: Wed Dec 12, 2012 7:11 pm

Re: Puzzling problem with check_http

Post by Cloudmaster »

Thanks for your input, I'll try some of the other check_http options & see what I can come up with
Cloudmaster
Posts: 6
Joined: Wed Dec 12, 2012 7:11 pm

Re: Puzzling problem with check_http

Post by Cloudmaster »

Finally got it working in the same host block as all the other checks, here's the old and new check_http configurations -

# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}

# 'check_http_new' command definition
define command{
command_name check_http_new
command_line $USER1$/check_http -I $ARG1$ -H $ARG2$ -u $ARG3$
}

Thanks for the help sreinhardt
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Puzzling problem with check_http

Post by slansing »

Thank's for sharing your solution, that may be valuable to someone with the same issue :)
Locked