mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 14:24:39 -07:00
ec2_cost, rcs_cost: calculate uptime from instance creation
This commit is contained in:
parent
f96b980d56
commit
920dfb8735
2 changed files with 2 additions and 6 deletions
|
@ -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}'`
|
||||
|
||||
|
|
|
@ -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}'`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue