Page 1 of 1

check_http -u doesn't work but URL does work on the server

Posted: Wed Jul 02, 2014 12:18 am
by joe.ward
In Nagios XI, creating a service that calls check_xi_http_server which uses check_http

Several tests use check_http -H <host> -u /some/path/page -s string_to_match -f follow and works fine. Nagios sends the URL \\<host>/some/path/page to the server (-H <host>) and returns the page. No problem here.

Now I need server (-H <host>) to check a URL that is not on itself. I try

check_http -H <host> -u http://other.host.com/blah -f follow

and it fails :-(

If I remotely log into the server (-H <host>) and put URL http://other.host.com/blah into the browser, it comes up, no problem. So why can't check_http check the URL?

Re: check_http -u doesn't work but URL does work on the serv

Posted: Wed Jul 02, 2014 1:45 am
by Box293
Here is the tests based on what you've reported:

I'm on the Nagios XI host 192.168.1.142.

Code: Select all

./check_http -H 192.168.1.142 -u /nagiosxi/login.php -s login -f follow
HTTP OK: HTTP/1.1 200 OK - 17387 bytes in 0.093 second response time |time=0.092827s;;;0.000000 size=17387B;;;0
I have another Nagios XI host on 192.168.1.11. I'm still logged onto 192.168.1.142 so lets try 192.168.1.11 testing 192.168.1.142.

Code: Select all

./check_http -H 192.168.1.11 -u http://192.168.1.142/nagiosxi/login.php -s login -f follow
HTTP OK: HTTP/1.1 200 OK - 17169 bytes in 0.134 second response time |time=0.133549s;;;0.000000 size=17169B;;;0
And for one last test I have a third Nagios XI server on 192.168.1.123.
So from 192.168.1.142 I issue a check to 192.168.1.11 to test the url on 192.168.1.123

Code: Select all

./check_http -H 192.168.1.11 -u http://192.168.1.123/nagiosxi/login.php -s login -f follow
HTTP OK: HTTP/1.1 200 OK - 17169 bytes in 0.136 second response time |time=0.136324s;;;0.000000 size=17169B;;;0
Everything seems to be working as expected.

Re: check_http -u doesn't work but URL does work on the serv

Posted: Mon Jul 07, 2014 11:24 pm
by joe.ward
Thank you for the examples and your testing.

I have worked more with the real URL involved and found that if I reduce the URL, then the check succeeds!

For example:

This fails
check_http -u http://server.domain.com/c/s/e/default. ... value&c=us -f follow -s "search key string"

but this works
check_http -u http://server.domain.com/c/s/e -f follow -s "search key string"

The web server must rewrite the URL because when the page displays, the final URL displayed in the web browser is the same as the full URL that was just mentioned as having failed.

By using "-f follow" it seems that the URL would be rewritten until it is finalized, before check_http checks for matching strings.

What am I missing?

Re: check_http -u doesn't work but URL does work on the serv

Posted: Tue Jul 08, 2014 10:02 am
by tmcdonald
The -f options will only follow a redirect that is issued in the HTTP header. check_http has no idea how to handle, say, a javascript redirect. Depending on how the page is being redirected we might have to use different strategies. Any insight into this?