Hey, I need a better way of checking if a webserver is online and
operational. The following code
works ok, but it sometimes returns the wrong result. Does anyone have a
better approach?
//Walle
def check_http(server)
Timeout::timeout(10.0) do
if(Net::HTTP.get_response(URI.parse(“http://#{server}.something.com”)).code
== “200”)
return true
end
return false
end
rescue Timeout::Error
return false
rescue
return false
end
I need the timeout timer for servers that have crashed, running
extremely slow.
OK, whatever. You originally said you were checking “if a webserver
is online and operational” – I wouldn’t consider one that’s crashed or
can’t respond to that request as “operational”
Regardless, you still didn’t describe the circumstances under which
your script gives inaccurate results.
Hehe, sometimes the timer kicks in, 10 seconds, even if the webserver is
running and is operational.
So, I’m confused – why do you have a 10-second timer if you know
that some of your servers respond more slowly than that, and that’s
OK by your definition of “operational” ?