Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: df80113464
Fetching contributors…

Cannot retrieve contributors at this time

executable file 49 lines (43 sloc) 1.107 kb
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/shared')
require 'uri'
require 'net/http'
require 'net/https'
def check(web_app)
begin
response = http_get(web_app['url'], web_app['username'], web_app['password'])
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT
notify_down(web_app)
response = nil
end
if response && !response.body.include?(web_app['substring'])
notify_down(web_app)
end
end
def notify_down(web_app)
domain = URI.parse(web_app['url']).host
email(config(:from), config(:to),
sprintf("#{config(:subject)}", domain),
"A web application is down!\n" +
"URL: #{web_app['url']}\n")
end
def http_get(url, username = nil, password = nil)
headers = {}
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
if uri.scheme == 'https'
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
http.start do
req = Net::HTTP::Get.new(uri.path, headers)
req.basic_auth(username, password) if username
http.request(req)
end
end
def start
config(:web_apps).each do |web_app|
check(web_app)
end
end
start
Jump to Line
Something went wrong with that request. Please try again.