initial commit from code.google.com

This commit is contained in:
Colin Johnson
2012-06-17 22:46:53 +00:00
commit 52dcc5c58e
24 changed files with 1764 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
# Introduction:
ec2-write-storage-used was created to extend Amazon's default metrics for EC2 instances to include a metric for the amount of storage space used on an individual EC2 instance.
# Directions For Use:
#
ec2-write-storage-used.sh
## Example of Use:
#
The most valuable use of this application is to be run through cron on a regular basis.
#
# Additional Information:
#
Author: Colin Johnson / colin@cloudavail.com
Date: 2011-11-14
Version 0.1
License Type: GNU GENERAL PUBLIC LICENSE, Version 3

View File

@@ -0,0 +1,17 @@
#!/bin/bash -
#get instance id - used for putting metric
INSTANCE_ID=`GET http://169.254.169.254/latest/meta-data/instance-id`
INSTANCE_AZ=`curl -s curl http://169.254.169.254/latest/meta-data/placement/availability-zone/`
INSTANCE_REGION=${INSTANCE_AZ%?}
#belowshould be changed to grep - get only everything after % space slash
filesystemlist=`df -l | grep -i \/ | cut -c57-100` #add -l to restrict to local file systems
for filesystemmountpoint in $filesystemlist
do
storageused=`df | grep %\ *$filesystemmountpoint$ | grep -o [0-9]*% | tr -d %` #need to error check and possibly remove leading white space
mon-put-data --region $INSTANCE_REGION --metric-name StorageUsed --namespace EC2/Storage --value $storageused --unit Percent --dimensions FileSystem=$filesystemmountpoint,InstanceId=$INSTANCE_ID
done
#to run in cron every 5 minutes - note that you must first provide credentials for mon-put-data
#echo "*/5 * * * * ec2-user /usr/local/bin/ec2-write-storage-used.sh" > /etc/cron.d/ec2-write-storage-used