[Nagiosplug-help] check_http

Andy Shellam andy-lists at networkmail.eu
Tue Jan 27 18:43:41 CET 2009


Hi Kaushal,

Kaushal Shriyan wrote:
> Hi
>
> I have a situation whenever my website www.example.com 
> <http://www.example.com> gets redirected to error.example.com 
> <http://error.example.com>
> Nagios should send an Critical Alert. Can it be done using check_http ?
>
> check_http --onredirect=critical error.example.com 
> <http://error.example.com>. Not sure

I'm not quite sure what you're asking here.  If you're asking "can 
check_http throw a critical error if www.example.com is re-directed to 
error.example.com" then the answer is possibly.  check_http can throw a 
critical error if the webpage is re-directed.  See this simple test 
using www.google.com - this will try to redirect me to www.google.co.uk:

root /usr/local/nagios/libexec # ./check_http -H www.google.com
HTTP OK - HTTP/1.0 302 Found - 0.226 second response time 
|time=0.226112s;;;0.000000 size=585B;;;0
root /usr/local/nagios/libexec # ./check_http -H www.google.com 
--onredirect=critical
HTTP CRITICAL - HTTP/1.0 302 Found - 0.031 second response time 
|time=0.031338s;;;0.000000 size=585B;;;0
root /usr/local/nagios/libexec # ./check_http -H www.google.co.uk 
--onredirect=critical -u /
HTTP OK HTTP/1.0 200 OK - 7243 bytes in 0.069 seconds 
|time=0.068552s;;;0.000000 size=7243B;;;0

However I don't believe you can use check_http to return CRITICAL if 
www.example.com is redirected to error.example.com, but OK if 
www.example.com is redirected to ok.example.com.

The best option in this scenario would be to use check_http to check the 
text of the website returned, to see if your "error" page is returned 
instead of an OK:

root /usr/local/nagios/libexec # ./check_http -H www.google.co.uk -u / 
-s Google
HTTP OK HTTP/1.0 200 OK - 0.081 second response time 
|time=0.081373s;;;0.000000 size=7245B;;;0
root /usr/local/nagios/libexec # ./check_http -H www.google.co.uk -u / 
-s Google2
HTTP CRITICAL - string not found|time=0.063015s;;;0.000000 size=7245B;;;0

HTH,

Andy




More information about the Help mailing list