This article shows how to add a couple of Ubuntu box metrics to Amazon AWS ClowdWatch service. The goal is to monitor memory add file systems usage using AWS facilities.

There are lot of resource in internet that shows ClowdWatch integration. This is just another contribute focused on Ubuntu 12.04 LTS server ditribution. Please remember that in Amazon yow will pay a montly fee for each custom metrics collected wit CloudWatch

Start from a clean running ubuntu AMI instance and follow this simple workflow.

Install java runtime

sudo apt-get install openjdk-6-jre

Set JAVE_HOME enviroment variable:

JAVA_HOME=$( dirname $( dirname $( readlink -e /usr/bin/java ) ) )

Load last version of Amazon CloudWatch Command Line Tool in /usr/local/lib a:

wget http://ec2-downloads.s3.amazonaws.com/CloudWatch-2010-08-01.zip -O /tmp/ClowdWatch.zip
cd /usr/local/lib; sudo unzip /tmp/ClowdWatch.zip

Store the name of ClowdWatch library in AWS_CLOUDWATCH_HOME environment variable

AWS_CLOUDWATCH_HOME=/usr/local/lib/CloudWatch-1.0.13.4

N.B. the file name of ClowdWatch library coud change....

Create some config file where to store usefull variables:


AWS_CREDENTIAL_FILE=$CONF_DIR/auth.conf

CONF_DIR=$(dirname $AWS_CREDENTIAL_FILE)
sudo mkdir -p $CONF_DIR

sudo cat << EOT > $AWS_CREDENTIAL_FILE
AWSAccessKeyId=YOURACCESKEY
AWSSecretKey=YOURSECRETKEY
EOT
sudo chmod 600 $AWS_CREDENTIAL_FILE

cat << EOT > $CONF_DIR/env.conf
JAVA_HOME=$JAVA_HOME
AWS_CLOUDWATCH_HOME=$AWS_CLOUDWATCH_HOME
AWS_CREDENTIAL_FILE=$AWS_CREDENTIAL_FILE
EOT

Check that your setup works properly, run the following command:

/usr/local/lib/bin/mon-cmd --help

You should see the usage page for all Monitoring commands.

Now get last version of cw-utils scripts. These are ubuntu patched version of some files in  colinbjohnson / aws-missing-tools project .


svn co http://eautils.googlecode.com/svn/trunk/cw-utils cw-utils
cd cw-utils; sudo sh install.sh

That's it. Now you are collecting disks and memory usage. Take a look to cw-utils scripts to figure how they works.