Skip to content

Instantly share code, notes, and snippets.

@rixth
Created April 23, 2013 13:22
Show Gist options
  • Save rixth/5443497 to your computer and use it in GitHub Desktop.
Save rixth/5443497 to your computer and use it in GitHub Desktop.
WWDC ticket monitor
require 'pagerduty'
require 'nokogiri'
require 'open-uri'
URL_TO_MONITOR = 'https://developer.apple.com/wwdc/'
PAGERDUTY_SERVICE_KEY = 'xxx'
pagerduty = Pagerduty.new(PAGERDUTY_SERVICE_KEY)
previous_html = nil
while true;
sleep 5
puts Time.now.to_s
begin
html = open(URL_TO_MONITOR).read
rescue Exception => e
puts "\n\n****\nEXCEPTION FETCHING: #{e}\n****\n\n"
next
end
if previous_html && html != previous_html
begin
puts "\n\n****\nALERT TRIGGERED\n****\n\n"
pagerduty.trigger "The WWDC page changed!"
rescue Exception => e
puts "\n\n****\nEXCEPTION TRIGGERING: #{e}\n****\n\n"
next
end
end
previous_html = html
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment