Created
April 22, 2011 17:23
-
-
Save kowsik/937149 to your computer and use it in GitHub Desktop.
Using blitz.io and Tropo for easy Application Monitoring
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 'rubygems' | |
require 'restclient' | |
require 'blitz' | |
require 'pp' | |
TROPO_USER = ENV['TROPO_USER'] | |
TROPO_PASS = ENV['TROPO_PASS'] | |
TROPO_APIK = ENV['TROPO_APIK'] | |
TROPO_CALL = ENV['TROPO_CALL'] | |
tropo = RestClient::Resource.new 'http://api.tropo.com', | |
:user => TROPO_USER, | |
:password => TROPO_PASS | |
loop do | |
begin | |
# Try running a sprint from california. You can also pick virginia, | |
# singapore, japan or ireland! | |
opts = { | |
:region => 'california', | |
:steps => [ | |
{ :url => 'http://www.mudynamics.com' } | |
] | |
} | |
result = Blitz::Curl::Sprint.execute(opts) | |
rescue Blitz::Curl::Error => e | |
# If there's an exception, use Tropo to send an SMS to the indicated | |
# phone number with the reason | |
tropo['1.0/sessions'].get :params => { | |
:action => 'create', | |
:token => TROPO_APIK, | |
:blitzPhoneNumber => TROPO_CALL, | |
:blitzMessage => e.message | |
} | |
end | |
# Wait for 5-minutes and try again | |
sleep 300.0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment