Skip to content

Instantly share code, notes, and snippets.

@jrgifford
Created November 30, 2011 12:33
Show Gist options
  • Save jrgifford/1408915 to your computer and use it in GitHub Desktop.
Save jrgifford/1408915 to your computer and use it in GitHub Desktop.
isitup.rb
require 'rubygems'
require 'net/http'
require 'uri'
require 'boxcar_api'
url = URI.parse('http://bjmdw.dyndns.org:88/up.txt')
def up?(url)
begin
Net::HTTP.get_response(url).body == "yes"
true
rescue Errno::ECONNREFUSED
false
puts "Down"
end
end
def notify
provider = BoxcarAPI::Provider.new('c1dQjjKHm0pXIrGQmWEb', 'Oo7gJ18sYVVQOAMzoDahzAmYxo8dfqDJ31cUKdJQ')
provider.subscribe "james@jamesrgifford.com"
provider.notify("james@jamesrgifford.com", "Its down")
end
until up?(url)
notify
sleep 20
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment