diff --git a/debian/changelog b/debian/changelog index c9df66b4..f273eadc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ byobu (5.3) unreleased; urgency=low - use READLINK * usr/share/byobu/profiles/tmux: - add some comments + * usr/lib/byobu/ec2_cost, usr/lib/byobu/network: LP: #914098 + - fix regression from r1839, add colon to IFS -- Dustin Kirkland Sun, 08 Jan 2012 20:28:08 -0600 diff --git a/usr/lib/byobu/ec2_cost b/usr/lib/byobu/ec2_cost index b14a53c2..0ea18d1d 100755 --- a/usr/lib/byobu/ec2_cost +++ b/usr/lib/byobu/ec2_cost @@ -33,6 +33,7 @@ __ec2_cost_detail() { __ec2_cost() { local zone type file_to_stat cpu mem rate hours tx_gb rx_gb network_cost uptime_cost total_cost interface cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/ec2_cost" + OIFS="$IFS" # Try to use metadata service if metadata_available; then [ -s "$cache.zone" ] || wget -q -O "$cache.zone" http://169.254.169.254/latest/meta-data/placement/availability-zone 2>/dev/null & @@ -75,13 +76,15 @@ __ec2_cost() { # Auto detect network interface interface=`tail -n1 /proc/net/route | awk '{print $1}'` local iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed + IFS="$OIFS:" while read iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed; do - if [ "$iface" = "${interface}:" ]; then + if [ "$iface" = "${interface}:" ]; then tx_gb=${tbytes} rx_gb=${rbytes} - break; - fi + break + fi done < /proc/net/dev + IFS="$OIFS" tx_gb=$(echo ${tx_gb} | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }') 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}'` diff --git a/usr/lib/byobu/network b/usr/lib/byobu/network index 5655a7d6..1910d5a4 100755 --- a/usr/lib/byobu/network +++ b/usr/lib/byobu/network @@ -42,12 +42,14 @@ __network() { cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/network.$i" [ -r "$cache" ] && read x1 < "$cache" || tx1=0 local iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed + IFS="$OIFS:" while read iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed; do if [ "$iface" = "${interface}:" ]; then [ "$i" = "up" ] && x2=${tbytes} || x2=${rbytes} break; fi done < /proc/net/dev + IFS="$OIFS" echo "$x2" > "$cache" rate=$((8*($x2 - $x1) / $t / 1024)) # in kbps [ "$rate" -lt 0 ] && rate=0