class Easymon::HttpCheck
Attributes
url[RW]
Public Class Methods
new(url)
click to toggle source
# File lib/easymon/checks/http_check.rb, line 7 def initialize(url) self.url = url end
Public Instance Methods
check()
click to toggle source
# File lib/easymon/checks/http_check.rb, line 11 def check check_status = http_up?(url) if check_status message = "Up" else message = "Down" end [check_status, message] end
Private Instance Methods
http_head(url)
click to toggle source
# File lib/easymon/checks/http_check.rb, line 28 def http_head(url) uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.is_a?(URI::HTTPS) http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.open_timeout = 5 http.read_timeout = 5 http.request Net::HTTP::Head.new(uri.request_uri) end
http_up?(url)
click to toggle source
# File lib/easymon/checks/http_check.rb, line 22 def http_up?(url) http_head(url).is_a?(Net::HTTPSuccess) rescue Exception false end