What's the easiest method to produce a "Is my website lower?" in Ruby? How must i get it done to check on it using HTTP(s) and Ping?
Essentially only use a http library to try to get (really, HEADing could be better) the page they are pointing to. If you achieve an answer then your server expires, otherwise (it does not respond or occasions out) it's lower and also you alert the consumer accordingly.
This is not the cleanest method of doing the work, but essentially:
require 'net/http' require 'uri' def isUp( url ) uri = URI.parse( url ) begin Timeout::timeout(5) Internet::HTTP.start( uri.host, uri.port ) httpmind( uri.path ) save Timeout::Error return false finish return true finish
You are able to most likely have it not to wait for a timeout, and/or boost the timeout to prevent the timeout to prevent false positive, but this can be a simple example.
require 'uri' require 'open-uri' site = "http://stackoverflow.com/" open("http://downforeveryoneorjustme.com/#")f["It's not only you!"]