Created
April 23, 2013 13:22
-
-
Save rixth/5443497 to your computer and use it in GitHub Desktop.
WWDC ticket monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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