Monitoring Amazon EC2 Instances
July 03, 2008 by Charles
Amazon’s Elastic Compute Cloud (Amazon EC2) Service is changing how we approach computing infrastructure. Scout is an ideal monitoring solution for Ruby on Rails application servers on EC2 instances.
Why use Scout for monitoring your EC2 instances?
- Just a single line of code to add the client
- No complicated scripts to configure – choose what you want to monitor through the Scout web interface
- Easy to re-use or view statistical data once an instance has terminated
Overview
The basic process for EC2 monitoring works like this: You create a new client that you want to use as a template . You can then clone this client (and all of its plugins) using the scout clone command, which can be added to the boot/startup script on your AMI.
Read on for the Step-by-Step.
Step-by-Step
Create a new client using the Scout Web Interface:

Install plugins on this client:

Grab the client key of your newly created “template” from the Client Settings tab:

Now, you can easily create a brand new client from your template using the scout clone command:
scout clone [client-key] `hostname`
The output of the line above is a line for your crontab file, so you could simply add this to the bottom of the crontab:
scout clone [client-key] `hostname` >> /etc/crontab
You’re just one step away from automating the entire process by adding the scout gem dependency to your AMI, and even adding the scout clone line above to your startup scripts.
Here’s my first version of our Scout install script to be run on boot of our Rails AMI:
#!/bin/bash
# Scout Install / Setup Script
/usr/bin/gem install scout
CLONE_CLIENT_KEY = 6ecad312-0a17-3db1-9x2c-a12c45493fg # replace with your template client key
INTERVAL = 10
NEW_CLIENT_KEY = /usr/bin/scout clone $CLONE_CLIENT_KEY
# add to crontab:
echo "*/$INTERVAL * * * * root /usr/bin/scout $NEW_CLIENT_KEY" >> /etc/crontab
When your AMIs boot up, they’ll be on the cloud, and under the watch of Scout.
