search by tags

for the user

adventures into the land of the command line

adding additional cloudwatch metrics for your ec2 hosts

by default, amazon provides some sweet monitoring in their cloudfront dashboard, but for your ec2 hosts, you might want to see more. handily you can do this if you want and amazon have even have a way you can set it up for yourself (not sure why they dont include this by default)

the additional metrics you can see are

memory utilised
memory used
memory available
swap space utilised
swap space used
disk space utilised
disk space used
disk space available
memory used including cache buffer

switch to root and start cpan

$ sudo su -
$ cd /
$ perl -MCPAN -e shell

at the cpan[1]> prompt

cpan[1]> install Bundle::LWP5_837 LWP

then exit

cpan[2]> exit

download and install the cloudwatch metrics scripts

$ cd /opt; wget; unzip; rm -rf; cd aws-scripts-mon

if you already have an AWS Identity and Access Management (IAM) role associated with yourinstance, make sure that it has permissions to perform the Amazon CloudWatch PutMetricData operation

to perform a simple test run without posting data to CloudWatch

/opt/aws-scripts-mon/ --mem-util --verify --verbose

to get utilization statistics for the last 12 hours

/opt/aws-scripts-mon/ --recent-hours=12

to collect all available memory metrics and send them to CloudWatch

/opt/aws-scripts-mon/ --mem-util --mem-used --mem-avail --disk-path=/ --disk-space-util --disk-space-used --disk-space-avail --disk-space-units=megabytes

to set a cron schedule for metrics reported to CloudWatch every 5 minutes

$ crontab -e
*/5 * * * * /opt/aws-scripts-mon/ --mem-util --disk-space-util --disk-path=/ --disk-space-util --disk-space-used --disk-space-avail --disk-space-units=megabytes --from-cron

data takes a little while to start appearing in the cloudwatch console after you start sending it, but then once it’s in, you can see your funky graphs.. and stuff