check_http follow redirect error

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sal@coned
Posts: 72
Joined: Thu Jan 21, 2010 4:42 pm

check_http follow redirect error

Post by sal@coned »

I am monitoring web pages which get redirected and search for a string on the final page.
The link starts off at "http://www.conedsolutions.com/sapphire/default.asp" which gets redirected to "http://www.conedsolutions.com/ces_enroll/default.aspx".

The check command is as follows ( $HOSTNAME$ = http://www.conedsolutions.com ):
check_http -H $HOSTNAME$ -f follow -u "/Sapphire/default.asp" -S -w 5 -c 10 -s "Sign up today"
The test always returns an error that the string was not found. From a web browser the links work correctly.

From the command line I see the following:
./check_http -H http://www.conedsolutions.com -f follow -u "/Sapphire/default.asp" -S -w 5 -c 10 -s "Sign up today"
HTTP CRITICAL - string not found|time=0.147702s;5.000000;10.000000;0.000000 size=460B;;;0


If I run it in debug mode, I see the reference to the final location but it never actually goes there.

./check_http -H http://www.conedsolutions.com -f follow -u "/Sapphire/default.asp" -S -w 5 -c 10 -s "Sign up today" -v
GET /Sapphire/default.asp HTTP/1.0
User-Agent: check_http/v2053 (nagios-plugins 1.4.13)
Connection: close
Host: http://www.conedsolutions.com


https://www.conedsolutions.com:443/Sapphire/default.asp is 337 characters
STATUS: HTTP/1.1 302 Object Moved
**** HEADER ****
Location: https://www.conedsolutions.com/CES_Enroll/Sapphire
Server: Microsoft-IIS/5.0
Content-Type: text/html
Content-Length: 173
**** CONTENT ****
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a HREF="https://www.conedsolutions.com/CES_Enro ... </a></body>
Redirection to https://www.conedsolutions.com:443/CES_Enroll/Sapphire
GET /CES_Enroll/Sapphire HTTP/1.0
User-Agent: check_http/v2053 (nagios-plugins 1.4.13)
Connection: close
Host: http://www.conedsolutions.com


https://www.conedsolutions.com:443/CES_Enroll/Sapphire is 339 characters
STATUS: HTTP/1.1 302 Object Moved
**** HEADER ****
Location: https://www.conedsolutions.com/CES_Enroll/Sapphire/
Server: Microsoft-IIS/5.0
Content-Type: text/html
Content-Length: 174
**** CONTENT ****
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a HREF="https://www.conedsolutions.com/CES_Enro ... </a></body>
Redirection to https://www.conedsolutions.com:443/CES_Enroll/Sapphire/
GET /CES_Enroll/Sapphire/ HTTP/1.0
User-Agent: check_http/v2053 (nagios-plugins 1.4.13)
Connection: close
Host: http://www.conedsolutions.com


https://www.conedsolutions.com:443/CES_Enroll/Sapphire/ is 460 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Server: Microsoft-IIS/5.0
Date: Wed, 20 Oct 2010 19:35:49 GMT
X-Powered-By: ASP.NET
X-UA-Compatible: IE=7
Connection: Keep-Alive
Content-Length: 237
Content-Type: text/html
Cache-control: private
**** CONTENT ****
<html>
<head>
</head>
<body>
<form name=t id=t action=/CES_Enroll/Default.aspx method=post ><input type=hidden name=AGENT value=177 ><input type=hidden name=PROMO value= ></form><script>t.submit();</script>
</body>
</html>

HTTP CRITICAL - string not found|time=0.134249s;5.000000;10.000000;0.000000 size=460B;;;0
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: check_http follow redirect error

Post by mmestnik »

This is two requests, so you have to run two check commands. Have one check_http looking for the redirect and another that is not redirected looking for your string.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: check_http follow redirect error

Post by mmestnik »

You can also use Web Transactions. Though I feel that would be overly complex a solution.

The benefit for having this as two checks is that you are directed to what part is acting up, rather then having to decide/discover what request is not happy today.
sal@coned
Posts: 72
Joined: Thu Jan 21, 2010 4:42 pm

Re: check_http follow redirect error

Post by sal@coned »

Not entirely sure I understand the 2 step check described.

The real problem I'm running into is that I am being asked to test that the redirect was performed correctly.

To make a long story short, recently the redirect was edited and pointed to an old web-page so its not enough to test that it is being redirected but need proof that it is landing on the correct page.

Sal
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: check_http follow redirect error

Post by mguthrie »

I would take a look at the Web Transaction feature and see if that can do what you need, here's the doc for it:

http://library.nagios.com/library/produ ... -nagios-xi
sal@coned
Posts: 72
Joined: Thu Jan 21, 2010 4:42 pm

Re: check_http follow redirect error

Post by sal@coned »

Thanks, Ill take a look at the WebTransaction docs.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: check_http follow redirect error

Post by mmestnik »

For the two service check method you would check the redirect, not only would you fail to match if the redirect was missing but you would also send an alert if the URL had ever changed. That is you do a match on the whole string returned from the server.

If you wanted something that would follow the URL wherever it leaded to see if it brings you to a page the contains what you wanted to display, then Web Transaction is the way to go.

I'd believe that you'd want to be notified if the URL ever changed, it's only one more place to update the URL if or when it does change. Splinting it into two checks has the advantage of alerting you to "the problem", instead of alerting you of "a problem".
sal@coned
Posts: 72
Joined: Thu Jan 21, 2010 4:42 pm

Re: check_http follow redirect error

Post by sal@coned »

I used the check_webinject command and it did exactly what I needed.

Thanks for the help.

PS
Not difficult after I read the manual
Locked