Merge lp:~jbernard/byobu/uptime-since-instance-creation into lp:byobu

Proposed by Jon Bernard
Status: Merged
Merged at revision: 1037
Proposed branch: lp:~jbernard/byobu/uptime-since-instance-creation
Merge into: lp:byobu
Diff against target: 28 lines (+2/-6)
2 files modified
usr/lib/byobu/ec2_cost (+1/-3)
usr/lib/byobu/rcs_cost (+1/-3)
To merge this branch: bzr merge lp:~jbernard/byobu/uptime-since-instance-creation
Reviewer Review Type Date Requested Status
Dustin Kirkland  Pending
Review via email: mp+25777@code.launchpad.net

Description of the change

This branch changes ec2_cost and rcs_cost to calculate uptime since instance creation, rather than the last reboot. This is calculated by subtracting the ctime of /etc/crontab from the current time, and using that in subsequent calculations.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'usr/lib/byobu/ec2_cost'
2--- usr/lib/byobu/ec2_cost 2010-05-15 19:38:08 +0000
3+++ usr/lib/byobu/ec2_cost 2010-05-21 14:07:25 +0000
4@@ -71,9 +71,7 @@
5 network_cost=`echo "$tx_gb" "$TX_RATE" "$rx_gb" "$RX_RATE" | awk '{printf "%f %f", $1*$2, $3*$4}' | awk '{printf "%f", $1 + $2}'`
6
7 # Calculate uptime cost
8-# BUG: This will only calculate uptime since boot!
9-# Some additional input will be required to account for reboots!!!
10-hours=`awk '{printf "%f", 1 + $1 / 60 / 60 }' /proc/uptime | sed 's/\..*$//' `
11+hours=$(((`date +%s` - `stat --printf %Z /etc/crontab`) / 60 / 60))
12 uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$RATE" * $hours}"`
13 total_cost=`echo "$network_cost" "$uptime_cost" | awk '{printf "%.2f", $1 + $2}'`
14
15
16=== modified file 'usr/lib/byobu/rcs_cost'
17--- usr/lib/byobu/rcs_cost 2010-05-15 19:38:08 +0000
18+++ usr/lib/byobu/rcs_cost 2010-05-21 14:07:25 +0000
19@@ -74,9 +74,7 @@
20 network_cost=`echo "$tx_gb" "$TX_RATE" "$rx_gb" "$RX_RATE" | awk '{printf "%f %f", $1*$2, $3*$4}' | awk '{printf "%f", $1 + $2}'`
21
22 # Calculate uptime cost
23-# BUG: This will only calculate uptime since boot!
24-# Some additional input will be required to account for reboots!!!
25-hours=`awk '{printf "%f", 1 + $1 / 60 / 60 }' /proc/uptime | sed 's/\..*$//' `
26+hours=$(((`date +%s` - `stat --printf %Z /etc/crontab`) / 60 / 60))
27 uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$MEMORY_RATE" * $hours}"`
28 total_cost=`echo "$network_cost" "$uptime_cost" | awk '{printf "%.2f", $1 + $2}'`
29

Subscribers

People subscribed via source and target branches