* bin/network: pull network bytes directly from /proc/net/dev, performance

improvement

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
Dustin Kirkland 2009-06-16 20:48:17 -05:00
commit 0bdee971dc
2 changed files with 5 additions and 4 deletions

View file

@ -32,7 +32,6 @@ if [ "$1" = "--detail" ]; then
fi
t2=`date +%s`
ifconfig=`/sbin/ifconfig "$interface" | grep "RX bytes" | sed "s/.*:\(.*\) (.*:\(.*\) (.*/\1\n\2/"`
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
@ -42,11 +41,11 @@ for i in up down; do
else
x1=`cat "$cache"` 2>/dev/null || tx1=0
if [ "$i" = "up" ]; then
x2=`echo "$ifconfig" | tail -n1`
symbol="^"
x2=`grep "$interface:" /proc/net/dev | awk '{print $10}'`
else
x2=`echo "$ifconfig" | head -n1`
symbol="v"
x2=`grep "$interface:" /proc/net/dev | awk '{print $2}'`
fi
echo "$x2" > "$cache"
rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'`

4
debian/changelog vendored
View file

@ -34,8 +34,10 @@ byobu (2.12) unreleased; urgency=low
improvement
* bin/load_average: drop "cat", and just use awk, performance
improvement
* bin/network: pull network bytes directly from /proc/net/dev, performance
improvement
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 16 Jun 2009 20:46:37 -0500
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 16 Jun 2009 20:47:32 -0500
byobu (2.11-0ubuntu1) karmic; urgency=low