deprecation of tools that will not be supported.
This commit is contained in:
17
_deprecated/ec2-cost-calculate/README.md
Normal file
17
_deprecated/ec2-cost-calculate/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Introduction:
|
||||
ec2-cost-calculate was created to easily sum the total of instances running in one or all regions. The typical use would be to run the ec2-cost-calculate script and then import into a spreadsheet application for further analysis. Another use would be to run the ec2-cost-calculate script with cron, producing a weekly output file (an example of this: `echo "0 0 * * 0 ec2-user /home/ec2-user/ec2-cost-calculate.sh -p day -r all > /home/ec2-user/ec2-cost-report`date +"%Y%m%d"`.txt" > /etc/cron.d/ec2-cost-calculate.sh`).
|
||||
# Directions For Use:
|
||||
## Example of Use:
|
||||
ec2-cost-calculate.sh -r us-east-1 -p day
|
||||
the above example would provide a list of all instances in the region "us-east-1" along with the daily cost of running each instance.
|
||||
## Required Parameters:
|
||||
ec2-cost-calculate has no parameter requirements. ec2-cost-calculate does, however, default to the region "us-east-1" and hourly cost if no parameters are provided.
|
||||
## Optional Parameters:
|
||||
`-r <region>` - the region you wish to calculate cost for: these arguments include "all" for all regions or us-east-1, us-west-1, us-west-2, eu-west-1, ap-southeast-1, ap-northeast-1 or sa-east-1
|
||||
|
||||
`-p <period>` - the period for which you wish to calculate instance cost. Allowable arguments are hour, day, week, month or year.
|
||||
# Additional Information:
|
||||
- Author: Colin Johnson / colin@cloudavail.com
|
||||
- Date: 2012-12-09
|
||||
- Version 0.5
|
||||
- License Type: GNU GENERAL PUBLIC LICENSE, Version 3
|
||||
115
_deprecated/ec2-cost-calculate/ec2-cost-calculate.sh
Executable file
115
_deprecated/ec2-cost-calculate/ec2-cost-calculate.sh
Executable file
@@ -0,0 +1,115 @@
|
||||
#!/bin/bash -
|
||||
# Author: Colin Johnson / colin@cloudavail.com
|
||||
# Date: 2011-03-07
|
||||
# Version 0.5
|
||||
# License Type: GNU GENERAL PUBLIC LICENSE, Version 3
|
||||
#
|
||||
# Add Features:
|
||||
#multi-region, all-region
|
||||
#handle as-ag with min, mix and "desired cost"
|
||||
#randomize ec2-list temp file, keep from clobbering
|
||||
#####
|
||||
#ec2-cost-calculate start
|
||||
#confirms that executables required for succesful script execution are available
|
||||
prerequisitecheck()
|
||||
{
|
||||
for prerequisite in basename awk ec2-describe-instances
|
||||
do
|
||||
#use of "hash" chosen as it is a shell builtin and will add programs to hash table, possibly speeding execution. Use of type also considered - open to suggestions.
|
||||
hash $prerequisite &> /dev/null
|
||||
if [[ $? == 1 ]] #has exits with exit status of 70, executable was not found
|
||||
then echo "In order to use `basename $0`, the executable \"$prerequisite\" must be installed." 1>&2 ; exit 70
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#calls prerequisitecheck function to ensure that all executables required for script execution are available
|
||||
prerequisitecheck
|
||||
|
||||
#handles options processing
|
||||
while getopts :r:p:o: opt
|
||||
do
|
||||
case $opt in
|
||||
p) period="$OPTARG";;
|
||||
r) region="$OPTARG";;
|
||||
o) output="$OPTARG";; #as of 2011-11-27 not implemented
|
||||
*) echo "Error with Options Input. Cause of failure is most likely that an unsupported parameter was passed or a parameter was passed without a corresponding option." 1>&2 ; exit 64;;
|
||||
esac
|
||||
done
|
||||
|
||||
# period validator and cost multiplier
|
||||
case $period in
|
||||
"") multiple=1; period=hour ;;
|
||||
hour|Hour) multiple=1; ;;
|
||||
day|Day) multiple=24;;
|
||||
week|Week) multiple=168;;
|
||||
month|Month) multiple=720;;
|
||||
year|Year) multiple=8760;;
|
||||
*) echo "The \"$period\" period does not exist. You must specify a valid period for which to calculate AWS cost (example: -p hour or -p day)." 1>&2 ; exit 64;;
|
||||
esac
|
||||
|
||||
# cost matrix
|
||||
|
||||
# region validator
|
||||
case $region in
|
||||
us-east-1|"") regionselected=(us-east-1);;
|
||||
us-west-1) regionselected=(us-west-1);;
|
||||
us-west-2) regionselected=(us-west-2);;
|
||||
eu-west-1) regionselected=(eu-west-1);;
|
||||
ap-southeast-1) regionselected=(ap-southeast-1);;
|
||||
ap-northeast-1) regionselected=(ap-northeast-1);;
|
||||
sa-east-1) regionselected=(sa-east-1);;
|
||||
all) regionselected=(us-east-1 us-west-1 us-west-2 eu-west-1 ap-southeast-1 ap-northeast-1 sa-east-1);;
|
||||
*) echo "The \"$region\" region does not exist. You must specify a valid region for which to calculate AWS cost (example: -r us-east-1 or -r us-west-1)." 1>&2 ; exit 64;;
|
||||
esac
|
||||
#ensures that headers are only printed on the first run
|
||||
runnumber=0
|
||||
# loops through a single region or all regions
|
||||
for currentregion in ${regionselected[@]}
|
||||
do
|
||||
ec2-describe-instances --region $currentregion --show-empty-fields --filter instance-state-name=running | awk -v currentregion=$currentregion -v period=$period -v multiple=$multiple -v runnumber=$runnumber '
|
||||
BEGIN {
|
||||
instancecount=0
|
||||
#sets cost for region us-east-1
|
||||
if ( currentregion == "us-east-1" ) {
|
||||
cost["m1.small"]="0.08" ; cost["m1.medium"]="0.16" ; cost["m1.large"]="0.32" ; cost["m1.xlarge"]="0.64" ; cost["t1.micro"]="0.02" ; cost["m2.xlarge"]="0.45" ; cost["m2.2xlarge"]="0.9" ; cost["m2.4xlarge"]="1.8" ; cost["c1.medium"]="0.165" ; cost["c1.xlarge"]="0.66" ; cost["cc1.4xlarge"]="1.3" ; cost["cc2.8xlarge"]="2.4" ; cost["cg1.4xlarge"]="2.1" ; cost["hi1.4xlarge"]="3.1" }
|
||||
#sets cost for region us-west-2
|
||||
if ( currentregion == "us-west-2" ) {
|
||||
cost["m1.small"]="0.08" ; cost["m1.medium"]="0.16" ; cost["m1.large"]="0.32" ; cost["m1.xlarge"]="0.64" ; cost["t1.micro"]="0.02" ; cost["m2.xlarge"]="0.45" ; cost["m2.2xlarge"]="0.9" ; cost["m2.4xlarge"]="1.8" ; cost["c1.medium"]="0.165" ; cost["c1.xlarge"]="0.66" ; cost["cc1.4xlarge"]="" ; cost["cc2.8xlarge"]="" ; cost["cg1.4xlarge"]="" ; cost["hi1.4xlarge"]="" }
|
||||
#sets cost for region us-west-1
|
||||
if ( currentregion == "us-west-1" ) {
|
||||
cost["m1.small"]="0.09" ; cost["m1.medium"]="0.18" ; cost["m1.large"]="0.36" ; cost["m1.xlarge"]="0.72" ; cost["t1.micro"]="0.025" ; cost["m2.xlarge"]="0.506" ; cost["m2.2xlarge"]="1.012" ; cost["m2.4xlarge"]="2.024" ; cost["c1.medium"]="0.186" ; cost["c1.xlarge"]="0.744" ; cost["cc1.4xlarge"]="" ; cost["cc2.8xlarge"]="" ; cost["cg1.4xlarge"]="" ; cost["hi1.4xlarge"]="" }
|
||||
#sets cost for region eu-east-1
|
||||
if ( currentregion == "eu-west-1" ) {
|
||||
cost["m1.small"]="0.85" ; cost["m1.medium"]="0.17" ; cost["m1.large"]="0.34" ; cost["m1.xlarge"]="0.68" ; cost["t1.micro"]="0.02" ; cost["m2.xlarge"]="0.506" ; cost["m2.2xlarge"]="1.012" ; cost["m2.4xlarge"]="2.024" ; cost["c1.medium"]="0.186" ; cost["c1.xlarge"]="0.744" ; cost["cc1.4xlarge"]="" ; cost["cc2.8xlarge"]="2.7" ; cost["cg1.4xlarge"]="" ; cost["hi1.4xlarge"]="" }
|
||||
#sets cost for region ap-southeast-1
|
||||
if ( currentregion == "ap-southeast-1" ) {
|
||||
cost["m1.small"]="0.85" ; cost["m1.medium"]="0.17" ; cost["m1.large"]="0.34" ; cost["m1.xlarge"]="0.68" ; cost["t1.micro"]="0.02" ; cost["m2.xlarge"]="0.506" ; cost["m2.2xlarge"]="1.012" ; cost["m2.4xlarge"]="2.024" ; cost["c1.medium"]="0.186" ; cost["c1.xlarge"]="0.744" ; cost["cc1.4xlarge"]="" ; cost["cc2.8xlarge"]="" ; cost["cg1.4xlarge"]="" ; cost["hi1.4xlarge"]="" }
|
||||
#sets cost for region ap-northeast-1
|
||||
if ( currentregion == "ap-northeast-1" ) {
|
||||
cost["m1.small"]="0.092" ; cost["m1.medium"]="0.184" ; cost["m1.large"]="0.368" ; cost["m1.xlarge"]="0.736" ; cost["t1.micro"]="0.027" ; cost["m2.xlarge"]="0.518" ; cost["m2.2xlarge"]="1.036" ; cost["m2.4xlarge"]="2.072" ; cost["c1.medium"]="0.19" ; cost["c1.xlarge"]="0.76" ; cost["cc1.4xlarge"]="" ; cost["cc2.8xlarge"]="" ; cost["cg1.4xlarge"]="" ; cost["hi1.4xlarge"]="" }
|
||||
#sets cost for region sa-east-1
|
||||
if ( currentregion == "sa-east-1" ) {
|
||||
cost["m1.small"]="0.115" ; cost["m1.large"]="0.23" ; cost["m1.large"]="0.46" ; cost["m1.xlarge"]="0.92" ; cost["t1.micro"]="0.027" ; cost["m2.xlarge"]="0.68" ; cost["m2.2xlarge"]="1.36" ; cost["m2.4xlarge"]="2.72" ; cost["c1.medium"]="0.23" ; cost["c1.xlarge"]="0.92" ; cost["cc1.4xlarge"]="" ; cost["cc2.8xlarge"]="" ; cost["cg1.4xlarge"]="" ; cost["hi1.4xlarge"]="" }
|
||||
|
||||
if ( runnumber == 0 ) {
|
||||
printf ("%s %s %s %s %s %s %s %s\n", "InstanceID", "InstanceSize", "InstanceIP", "InstanceStatus", "InstanceName", "AutoScalingGroup", "Region", "InstanceCost" )
|
||||
}
|
||||
}
|
||||
|
||||
/^INSTANCE/ {
|
||||
if ( instancecount >= 1 ) {
|
||||
printf ("%s %s %s %s %s %s %s %s\n", instanceid, instancesize, instanceip, instancestatus, tag[0], tag[1], currentregion, cost[instancesize]*multiple )
|
||||
}
|
||||
instancecount++
|
||||
instanceid=$2 ; instancesize=$10 ; instanceip=$4 ; instancestatus=$6; tag[0]="Null" ; tag[1]="Null"
|
||||
}
|
||||
/^TAG/ {
|
||||
if ( $4 == "Name" ) tag[0]=$5
|
||||
if ( $4 == "aws:autoscaling:groupName" ) tag[1]=$5
|
||||
}
|
||||
#prints out last instance
|
||||
END { if ( instanceid != "" ) printf ("%s %s %s %s %s %s %s %s\n" , instanceid, instancesize, instanceip, instancestatus, tag[0] , tag[1], currentregion, cost[instancesize]*multiple ) }
|
||||
'
|
||||
runnumber=$((runnumber+1))
|
||||
done
|
||||
11
_deprecated/ec2-write-memory-metrics/README.md
Normal file
11
_deprecated/ec2-write-memory-metrics/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Introduction:
|
||||
ec2-write-memory-metrics was created to extend Amazon's default metrics for EC2 instances to include a metrics for memory usage.
|
||||
# Directions For Use:
|
||||
ec2-write-memory-metrics.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-12-09
|
||||
- Version 0.1
|
||||
- License Type: GNU GENERAL PUBLIC LICENSE, Version 3
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash -
|
||||
#get instance id - used for putting metric
|
||||
INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
|
||||
INSTANCE_AZ=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone/`
|
||||
INSTANCE_REGION=${INSTANCE_AZ%?}
|
||||
|
||||
#could be done using "free" or "vmstat" - use of less and grep is believed to provide widest compatibility - CJ 2011-11-24
|
||||
memfree=`cat /proc/meminfo | grep -i MemFree | grep -o [0-9]*`
|
||||
swaptotal=`cat /proc/meminfo | grep -i SwapTotal | grep -o [0-9]*`
|
||||
swapfree=`cat /proc/meminfo | grep -i SwapFree | grep -o [0-9]*`
|
||||
swapused=$(($swaptotal-$swapfree))
|
||||
|
||||
#mon-put-data to put metrics
|
||||
mon-put-data --region $INSTANCE_REGION --metric-name MemoryFree --namespace EC2/Memory --value $memfree --unit Kilobytes --dimensions "InstanceId=$INSTANCE_ID"
|
||||
mon-put-data --region $INSTANCE_REGION --metric-name SwapUsed --namespace EC2/Memory --value $swapused --unit Kilobytes --dimensions "InstanceId=$INSTANCE_ID"
|
||||
|
||||
#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-memory-metrics.sh" > /etc/cron.d/ec2-write-memory-metrics
|
||||
11
_deprecated/ec2-write-storage-used/README.md
Normal file
11
_deprecated/ec2-write-storage-used/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# 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-12-09
|
||||
- Version 0.1
|
||||
- License Type: GNU GENERAL PUBLIC LICENSE, Version 3
|
||||
17
_deprecated/ec2-write-storage-used/ec2-write-storage-used.sh
Normal file
17
_deprecated/ec2-write-storage-used/ec2-write-storage-used.sh
Normal 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 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
|
||||
Reference in New Issue
Block a user