Create a gist now

Instantly share code, notes, and snippets.

Using blitz.io and Tropo for easy Application Monitoring
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