I was chatting yesterday with Jeff Barr, AWS evangelist extraordinaire and all-around great guy yesterday.
He had the idea of building an Amazon Web Services Status hotline, allowing AWS customers to call in and instantly get the status of S3, EC2, etc. Cool idea! AWS already maintains a status dashboard (with RSS feeds!) at: http://status.aws.amazon.com
About 10 minutes later, we had a finished status hotline! Try it out, give a call to:
Building the AWS Status Hotline
Building it was quite simple. First, I grabbed a Seattle (206) phone number from Twilio:
and pointed it toward my application URL:
Feel free to click that link, you’ll see the TwiML
in your browser!
When you call, that initial page reads a list of AWS Services to you, asking you to pick which one you’d like status for. I use the <Say>
verb to read the names of the services, and the <Gather>
verb to let the caller pick which service they want to hear status for.
When a digit is pressed, it submits to handleStatus2.php
. This script fetches HTML from status.aws.amazon.com and parses the file using a regular expression to find the status for the desired service.
This script first looks at the digit that was pressed, and figures out which service it represents, or redirects back to the initial page (index.php) with an error flag set, telling the caller that the digit was not valid. Because I’m using Amazon’s HTML page, I set a regular expression to match in finding each service’s status. Amazon returns an HTML table with the services’ statuses, so I can just match on a <td> containing the name of the service, and the next <td> contains the service status:
At this point, you may be screaming… just use the RSS feeds! I couldn’t get Amazon’s RSS feeds to work, I’ll tell you why in a bit.
So once we have the regex set, the script fetches HTML from http://status.aws.amazon.com, and uses preg_match to find the service status line based on the regex:
One we have the service and status strings, let’s output some TwiML to read the status to the caller:
Note that if no status was found, because the regex failed, then I read an error message. After the status is read, I use the <Redirect>
verb to send the caller back to the main menu at index.php.
What about AWS RSS Feeds?
You may have noticed handleStatus2.php? What happened to handleStatus.php? Good question, that was my initial attempt to use Amazon’s RSS feeds to get the current status.
On the status.aws.amazon.com page, you’ll see a list of RSS feeds, one for each service:
When I open those feeds in my reader, I get a single <item> entry reporting the status:
But when I request the same feed URL in PHP, I don’t get the <item> block!
Here’s what I get back:
So it seems we have a case of a missing <item> block?!?
I don’t know if RSS readers send some double-secret HTTP headers or what, but hopefully AWS can figure out why their RSS feeds don’t return the <item> status when fetched via PHP.