* usr/bin/byobu-export, usr/lib/byobu/ec2_cost,

usr/share/byobu/ec2/rates.eu_ie, usr/share/byobu/ec2/rates.us_ca,
  usr/share/byobu/ec2/rates.us_va:
  - update ec2 pricing model, allow for local overrides of prices
    via a sourced symlink or bespoke file in $HOME/.byobu/ec2_rates
This commit is contained in:
Dustin Kirkland 2010-03-03 11:52:06 -06:00
commit 8a555b2f91
6 changed files with 70 additions and 16 deletions

6
debian/changelog vendored
View file

@ -1,6 +1,10 @@
byobu (2.60) unreleased; urgency=low
* UNRELEASED
* usr/bin/byobu-export, usr/lib/byobu/ec2_cost,
usr/share/byobu/ec2/rates.eu_ie, usr/share/byobu/ec2/rates.us_ca,
usr/share/byobu/ec2/rates.us_va:
- update ec2 pricing model, allow for local overrides of prices
via a sourced symlink or bespoke file in $HOME/.byobu/ec2_rates
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 26 Feb 2010 10:43:00 -0600

View file

@ -91,6 +91,7 @@ cp /etc/$PKG/statusrc "$DIR/.$PKG/status"
echo "source \$HOME/.$PKG/profile" > "$DIR/.screenrc"
echo "source \$HOME/.$PKG/usr/share/$PKG/keybindings/common" > "$DIR/.$PKG/keybindings"
ln -sf usr/share/$PKG/profiles/common "$DIR/.$PKG/profile"
ln -sf usr/share/$PKG/ec2/rates.us_ca "$DIR/.$PKG/ec2_rates"
# Some gardening; update paths to be $HOME-based
for i in $(ls /usr/bin/$PKG-* | grep -v "install"); do

View file

@ -29,26 +29,36 @@ for arg in $@; do
esac
done
# Approximate Instance Cost Basis
# US Europe
# Small (1cpu, 32bit) $0.10/h $0.11/h
# Medium (2cpu, 32bit) $0.20/h $0.22/h
# Large (4cpu, 64bit) $0.40/h $0.44/h
# XLarge (8cpu, 64bit) $0.80/h $0.88/h
# Get the going rates
[ -r "$HOME/.$PKG/ec2_rates" ] || ln -s /usr/share/$PKG/ec2/rates.us_ca "$HOME/.$PKG/ec2_rates"
. "$HOME/.$PKG/ec2_rates" || exit 1
# Count CPUs
cpu_count=`grep -c "^processor.*:" /proc/cpuinfo`
[ -z "$cpu_count" ] && cpu_count=1
# Apply the going rate
CPU_RATE=`echo "$cpu_count" | awk '{printf "%f", 0.10*$1}'`
# BUG: Some logic needed here to add 10% cost for Europe instances?
# Count CPUs, Memory, Architecture
cpu=$(grep -c "^processor.*:" /proc/cpuinfo) || cpu=1
mem=$(grep ^MemTotal /proc/meminfo | awk '{print $2}')
# Guess this system's going rate, based on mem available (m* types)
if [ $mem -gt 64000000 ]; then
RATE=$M2_4XLARGE
elif [ $mem -gt 32000000 ]; then
RATE=$M2_2XLARGE
elif [ $mem -gt 16000000 ]; then
RATE=$M2_XLARGE
elif [ $mem -gt 14000000 ]; then
RATE=$M1_XLARGE
elif [ $mem -gt 7000000 ]; then
RATE=$M1_LARGE
else
# Otherwise, scale based on number of cpu's (c* types)
RATE=$(echo "$cpu" "$M1_SMALL" | awk '{printf "%f", $1*$2}')
fi
# Data Transfer Cost Basis
# Incoming $0.10/GB
# Outgoing $0.17/GB
# (This gets more complex if you use >1TB/mo)
RX_RATE="0.10"
TX_RATE="0.17"
TX_RATE="0.15"
# Auto detect network interface
IF=`tail -n1 /proc/net/route | awk '{print $1}'`
@ -64,7 +74,7 @@ network_cost=`echo "$tx_gb" "$TX_RATE" "$rx_gb" "$RX_RATE" | awk '{printf "%f %f
# BUG: This will only calculate uptime since boot!
# Some additional input will be required to account for reboots!!!
hours=`awk '{printf "%f", 1 + $1 / 60 / 60 }' /proc/uptime | sed 's/\..*$//' `
uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$CPU_RATE" * $hours}"`
uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$RATE" * $hours}"`
total_cost=`echo "$network_cost" "$uptime_cost" | awk '{printf "%.2f", $1 + $2}'`
if [ "$DETAIL" = "1" ]; then
@ -75,7 +85,7 @@ if [ "$DETAIL" = "1" ]; then
echo " Network recv: $rx_gb GB @ \$$TX_RATE/GB"
echo " Network cost: \$$network_cost"
echo "------------------------------------------------"
echo " Uptime: $hours hr @ \$$CPU_RATE/hr"
echo " Uptime: $hours hr @ \$$RATE/hr"
echo " Uptime cost: \$$uptime_cost"
echo "------------------------------------------------"
echo "Total cost: ~\$$total_cost"

View file

@ -0,0 +1,13 @@
# 2010-03-03: Approximate Instance Cost Basis per hour from
# http://aws.amazon.com/ec2/instance-types/
# http://aws.amazon.com/ec2/#pricing
# for EU - Ireland
M1_SMALL="0.095"
M1_LARGE="0.38"
M1_XLARGE="0.76"
M2_XLARGE="0.57"
M2_2XLARGE="1.34"
M2_4XLARGE="2.68"
C1_MEDIUM="0.19"
C1_XLARGE="0.76"

View file

@ -0,0 +1,13 @@
# 2010-03-03: Approximate Instance Cost Basis per hour from
# http://aws.amazon.com/ec2/instance-types/
# http://aws.amazon.com/ec2/#pricing
# for US - N. California
M1_SMALL="0.095"
M1_LARGE="0.38"
M1_XLARGE="0.76"
M2_XLARGE="0.57"
M2_2XLARGE="1.34"
M2_4XLARGE="2.68"
C1_MEDIUM="0.19"
C1_XLARGE="0.76"

View file

@ -0,0 +1,13 @@
# 2010-03-03: Approximate Instance Cost Basis per hour from
# http://aws.amazon.com/ec2/instance-types/
# http://aws.amazon.com/ec2/#pricing
# for US - N. Virginia
M1_SMALL="0.085"
M1_LARGE="0.34"
M1_XLARGE="0.68"
M2_XLARGE="0.50"
M2_2XLARGE="1.20"
M2_4XLARGE="2.40"
C1_MEDIUM="0.17"
C1_XLARGE="0.68"