From 4381d2f51909312fa08c4bed808df56479bbdbc4 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Tue, 14 Sep 2010 12:45:34 -0600 Subject: [PATCH] [ Jan Klepek ] [ Dustin Kirkland ] usr/lib/byobu/rcs_cost, usr/lib/byobu/ec2_cost: testing crontab creation time is not accurate, seems this happens at image creation rather than instance instantiation; use /var/lib instead; ensure that minimum hours is 1, not 0 --- debian/changelog | 7 +++++++ usr/lib/byobu/ec2_cost | 3 ++- usr/lib/byobu/rcs_cost | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index b0249f53..5e52af1e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,14 @@ byobu (3.5) unreleased; urgency=low + [ Jan Klepek ] * usr/bin/byobu-status: fix libexec path for Fedora, LP: #630054 + [ Dustin Kirkland ] + * usr/lib/byobu/rcs_cost, usr/lib/byobu/ec2_cost: testing crontab + creation time is not accurate, seems this happens at image creation + rather than instance instantiation; use /var/lib instead; ensure + that minimum hours is 1, not 0 + -- Dustin Kirkland Wed, 01 Sep 2010 13:11:34 -0600 byobu (3.4-0ubuntu1) maverick; urgency=low diff --git a/usr/lib/byobu/ec2_cost b/usr/lib/byobu/ec2_cost index e4098c84..836771e3 100755 --- a/usr/lib/byobu/ec2_cost +++ b/usr/lib/byobu/ec2_cost @@ -74,7 +74,8 @@ rx_gb=$(echo ${rx_gb%% *} | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }') network_cost=`echo "$tx_gb" "$TX_RATE" "$rx_gb" "$RX_RATE" | awk '{printf "%f %f", $1*$2, $3*$4}' | awk '{printf "%f", $1 + $2}'` # Calculate uptime cost -hours=$(((`date +%s` - `stat --printf %Z /etc/crontab`) / 60 / 60)) +hours=$(((`date +%s` - `stat --printf %Z /var/lib`) / 60 / 60)) +[ "$hours" = "0" ] && hours=1 uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$RATE" * $hours}"` total_cost=`echo "$network_cost" "$uptime_cost" | awk '{printf "%.2f", $1 + $2}'` diff --git a/usr/lib/byobu/rcs_cost b/usr/lib/byobu/rcs_cost index c20c7c5c..b7dff716 100755 --- a/usr/lib/byobu/rcs_cost +++ b/usr/lib/byobu/rcs_cost @@ -76,7 +76,8 @@ rx_gb=$(echo ${rx_gb%% *} | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }') network_cost=`echo "$tx_gb" "$TX_RATE" "$rx_gb" "$RX_RATE" | awk '{printf "%f %f", $1*$2, $3*$4}' | awk '{printf "%f", $1 + $2}'` # Calculate uptime cost -hours=$(((`date +%s` - `stat --printf %Z /etc/crontab`) / 60 / 60)) +hours=$(((`date +%s` - `stat --printf %Z /var/lib`) / 60 / 60)) +[ "$hours" = "0" ] && hours=1 uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$MEMORY_RATE" * $hours}"` total_cost=`echo "$network_cost" "$uptime_cost" | awk '{printf "%.2f", $1 + $2}'`