Letractively / nagios-check-webpage

Automatically exported from code.google.com/p/nagios-check-webpage
0 stars 0 forks source link

critical error with 302 to ?somevar=something #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. check www.mediepanelet.dk

What is the expected output? What do you see instead?
A normal output.

What version of the product are you using? On what operating system?
Using the latest, v0.4.

Please provide any additional information below.
/usr/lib/nagios/plugins/check_webpage.rb -n -u www.mediepanelet.dk -v -v
 * Get main page: http://www.mediepanelet.dk/
   -> 302, main page is now: ?page=forside
Critical: error with [/?page=forside]: undefined method `+' for nil:NilClass

Original issue reported on code.google.com by klavs.Kl...@gmail.com on 6 Oct 2010 at 11:04

GoogleCodeExporter commented 8 years ago
I did several tests and I don't understand the problem for now.

The only thing I see is the website redirect seems not correct:

$ curl -I http://www.mediepanelet.dk
HTTP/1.1 302 Found
Date: Tue, 12 Oct 2010 20:30:28 GMT
Server: Apache/2.2
LOCATION: ?page=forside
ServedBy: vertikal13
Content-Type: text/html

Following http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, Location 
should be an absoluteURI.

With debug the website response seems well handled but the script fails on the 
redirection call:

$ ./check_webpage.rb -u www.mediepanelet.dk -vv

 * ARGS: c=60 w=5 e=0 w2=10 u=www.mediepanelet.dk

 * Get main page: http://www.mediepanelet.dk/
DEBUG 0 [http://www.mediepanelet.dk/]
DEBUG [/] [{"User-Agent"=>"nagios-check-webpage"}]
   -> 302, main page is now: ?page=forside
DEBUG 0 [/?page=forside]
DEBUG 1(/) 2(page=forside)
DEBUG [/?page=forside] [{"User-Agent"=>"nagios-check-webpage", 
"accept-encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"}]
Critical: error with [/?page=forside]: Connection refused - connect(2)

You can use directly the redirected url to bypass the bug: 
http://www.mediepanelet.dk/?page=forside

I will try again later with a debbugger to inspect the objects.

I've also seen some bugs on verbose mode who need to be fixed.

Original comment by toubib....@gmail.com on 12 Oct 2010 at 8:40

GoogleCodeExporter commented 8 years ago
Fair enough - however this (none-RFC compliant) practise, is unfortunately and 
appearently well supported in browsers today :(

IMHO it would be nice if the script tried to handle relative uri's in location 
url's - but I can understand it if you see it as a malpractice.

Original comment by klavs.Kl...@gmail.com on 25 Oct 2010 at 11:51

GoogleCodeExporter commented 8 years ago
Here's a patch for making redirects follow with the host:

diff check_webpage.rb 
345a346
>   lastHost = mainUrl.host
347a349,351
>     if mainUrl.host.nil?
>         mainUrl.host = lastHost
>     end

Original comment by christia...@googlemail.com on 11 Nov 2010 at 2:50

GoogleCodeExporter commented 8 years ago
Patch applied on trunk

Original comment by toubib....@gmail.com on 11 Nov 2010 at 9:22