From a100720b1d7720b58337186ddd057710cb42b460 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sun, 21 Jun 2009 12:44:57 -0500 Subject: [PATCH] * bin/network: read bytes sent/received straight from /proc; more efficient Signed-off-by: Dustin Kirkland --- bin/network | 5 ++--- debian/changelog | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/network b/bin/network index 3c9404e6..f9347757 100755 --- a/bin/network +++ b/bin/network @@ -32,7 +32,6 @@ if [ "$1" = "--detail" ]; then fi t2=`date +%s` -ifconfig=`ifconfig "$interface" | grep "RX bytes:"` for i in up down; do cache="/var/run/screen/S-$USER/$PKG.network_$i" t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0 @@ -43,10 +42,10 @@ for i in up down; do x1=`cat "$cache"` 2>/dev/null || tx1=0 if [ "$i" = "up" ]; then symbol="^" - x2=`echo "$ifconfig" | sed "s/^.*TX bytes://" | awk '{print $1}'` + x2=`grep -m1 "$interface:" /proc/net/dev | sed "s/^.*://" | awk '{print $9}'` else symbol="v" - x2=`echo "$ifconfig" | sed "s/^.*RX bytes://" | awk '{print $1}'` + x2=`grep -m1 "$interface:" /proc/net/dev | sed "s/^.*://" | awk '{print $1}'` fi echo "$x2" > "$cache" rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'` diff --git a/debian/changelog b/debian/changelog index f6940660..45462590 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,11 +31,13 @@ byobu (2.13) unreleased; urgency=low panel * bin/ec2_cost, bin/ip_address, bin/network: get default interface from /proc/net/route, much more efficient + * bin/network: read bytes sent/received straight from /proc; more + efficient [ Ciemon Dunville ] * byobu.1: reflect the keybinding toggle change to Ctrl-a-! - -- Dustin Kirkland Sun, 21 Jun 2009 12:31:52 -0500 + -- Dustin Kirkland Sun, 21 Jun 2009 12:44:19 -0500 byobu (2.12-0ubuntu1) karmic; urgency=low