Easy Application Monitoring with blitz.io and Tropo

Been chatting with @chrismatthieu about getting a Tropo app going and especially with the EC2 outage, thought might be interesting to combine the Ruby Gem for blitz.io with the Tropo API to create a dead simple application monitor that I can run anywhere with any frequency.

Tropo Apps

Took me a little while to get past the fact that a Tropo application is not just a client app, but a server side app that can invoke various Tropo API’s to send SMS, IM’s on Skype, XMPP as well as make phone calls. After getting the free account, I created a scripting application with what Tropo calls a Hosted File.

tropo-scripting-app.png

The hosted file itself looks like this:

call(blitzPhoneNumber, {network:"SMS"});
say(blitzMessage);

Which is a simple JavaScript 2-liner with the blitzPhoneNumber and the blitzMessage being parameters that you can pass into the API invocation (below). Personally I would’ve preferred a namespace like params.phoneNumber so it’s explicit from a readability perspective. One interesting thing is because this 2-line snippet is wrapped in the rest of the code, using message as the parameter name ended up texting the JavaScript function().toString() to my phone! :)

tropo-text.png

Creating a phone number

Totally got busted the first time on this one. You have to create a phone number before you can invoke your API. I know in retrospect this seems obvious, but took me a few times and some help from @chrismatthieu to figure it out. The built-in debugger was so full of acronyms that this was lost on me. BTW, lived through the acronyms and VoIP in general is a really complex domain. So having a JSON-friendly API from Tropo is awesome.

tropo-add-phone.png

So, the monitoring bit

At this point, we have Tropo all set up to send an SMS to the blitzPhoneNumber with the appropriate blitzMessage. First things first, install the Ruby Gem:

gem install blitz

Now it’s super easy to setup a script that either runs a Sprint or a Rush (load test) on a periodic basis and sends you an SMS when something goes wrong.

Since the blitz.io has full support for various request methods, custom headers, authentication as well as being able to run from different regions worldwide, you can easily setup scripts that monitor authenticated API’s and URL’s, including multipart form POST’s, this gives you the freedom and the scriptability of doing this on a continuous basis. All Sprint results include the entire web page or the response payload so you can use things like Nokogiri to look for specific strings or elements in the response. Part of the reason for doing this, is sometimes your app might return 200 Okay, but doesn’t quite contain the actual payload that you are expecting it to have.

Better yet, you can also run scheduled load tests as part of this script and if there are errors or timeouts, use the Tropo API to send you an alert on Skype, XMPP, Phone, etc. As simple as it gets.

BTW, we just pushed out docs.blitz.io so you can find out more about how blitz works.

Bookmark and Share