diff --git a/usr/lib/byobu/ec2_cost b/usr/lib/byobu/ec2_cost index bc77aa65..75198e85 100755 --- a/usr/lib/byobu/ec2_cost +++ b/usr/lib/byobu/ec2_cost @@ -71,9 +71,7 @@ rx_gb=`echo "$ifconfig_out" | grep "RX bytes:" | sed "s/^.*RX bytes://" | awk '{ 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 -# 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/\..*$//' ` +hours=$(((`date +%s` - `stat --printf %Z /etc/crontab`) / 60 / 60)) 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 219ec5b7..5a7c7184 100755 --- a/usr/lib/byobu/rcs_cost +++ b/usr/lib/byobu/rcs_cost @@ -74,9 +74,7 @@ rx_gb=`echo "$ifconfig_out" | grep "RX bytes:" | sed "s/^.*RX bytes://" | awk '{ 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 -# 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/\..*$//' ` +hours=$(((`date +%s` - `stat --printf %Z /etc/crontab`) / 60 / 60)) uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$MEMORY_RATE" * $hours}"` total_cost=`echo "$network_cost" "$uptime_cost" | awk '{printf "%.2f", $1 + $2}'`