From 31f0d4966791d2986f23de7ee8ecbd8755dde5fd Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 24 Jun 2010 12:02:32 -0500 Subject: [PATCH] usr/lib/ec2_cost, usr/lib/rcs_cost --- debian/changelog | 1 + usr/lib/byobu/ec2_cost | 6 ++++-- usr/lib/byobu/rcs_cost | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index aa522030..75048bcc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ byobu (2.81) unreleased; urgency=low * Save some forks: - usr/bin/byobu-status - usr/lib/byobu/custom + - usr/lib/ec2_cost, usr/lib/rcs_cost - usr/lib/byobu/ip_address - usr/lib/byobu/release - usr/lib/services diff --git a/usr/lib/byobu/ec2_cost b/usr/lib/byobu/ec2_cost index 75198e85..9b6ec6f8 100755 --- a/usr/lib/byobu/ec2_cost +++ b/usr/lib/byobu/ec2_cost @@ -66,8 +66,10 @@ IF=`tail -n1 /proc/net/route | awk '{print $1}'` ifconfig_out=`LC_ALL=C /sbin/ifconfig "$IF"` # Calculate bandwidth cost -tx_gb=`echo "$ifconfig_out" | grep "TX bytes:" | sed "s/^.*TX bytes://" | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }'` -rx_gb=`echo "$ifconfig_out" | grep "RX bytes:" | sed "s/^.*RX bytes://" | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }'` +tx_gb=${ifconfig_out#*RX bytes:} +tx_gb=$(echo ${tx_gb%% *} | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }') +rx_gb=${ifconfig_out#*TX bytes:} +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 diff --git a/usr/lib/byobu/rcs_cost b/usr/lib/byobu/rcs_cost index 5a7c7184..c20c7c5c 100755 --- a/usr/lib/byobu/rcs_cost +++ b/usr/lib/byobu/rcs_cost @@ -69,8 +69,10 @@ IF=`tail -n1 /proc/net/route | awk '{print $1}'` ifconfig_out=`LC_ALL=C /sbin/ifconfig "$IF"` # Calculate bandwidth cost -tx_gb=`echo "$ifconfig_out" | grep "TX bytes:" | sed "s/^.*TX bytes://" | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }'` -rx_gb=`echo "$ifconfig_out" | grep "RX bytes:" | sed "s/^.*RX bytes://" | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }'` +tx_gb=${ifconfig_out#*RX bytes:} +tx_gb=$(echo ${tx_gb%% *} | awk '{ printf "%f", $1 / 1024 / 1024 / 1024 }') +rx_gb=${ifconfig_out#*TX bytes:} +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