* bin/network-*: set rate=0 when rate is negative (ie, on startup)

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
Dustin Kirkland 2009-05-26 21:53:35 +02:00
commit 4a44d0b211
3 changed files with 8 additions and 3 deletions

View file

@ -38,7 +38,9 @@ else
x2=`/sbin/ifconfig "$interface" | grep "RX bytes" | sed "s/^.*RX bytes://" | sed "s/ .*$//"` x2=`/sbin/ifconfig "$interface" | grep "RX bytes" | sed "s/^.*RX bytes://" | sed "s/ .*$//"`
echo "$x2" > "$cache" echo "$x2" > "$cache"
rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'` rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'`
if [ "$rate" -gt 1024 ]; then if [ "$rate" -lt 0 ]; then
rate=0
elif [ "$rate" -gt 1024 ]; then
rate=`echo "$rate" | awk '{printf "%.1f", $1/1024}'` rate=`echo "$rate" | awk '{printf "%.1f", $1/1024}'`
unit="MB/s" unit="MB/s"
fi fi

View file

@ -39,7 +39,9 @@ else
x2=`/sbin/ifconfig "$interface" | grep "TX bytes" | sed "s/^.*TX bytes://" | sed "s/ .*$//"` x2=`/sbin/ifconfig "$interface" | grep "TX bytes" | sed "s/^.*TX bytes://" | sed "s/ .*$//"`
echo "$x2" > "$cache" echo "$x2" > "$cache"
rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'` rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'`
if [ "$rate" -gt 1024 ]; then if [ "$rate" -lt 0 ]; then
rate=0
elif [ "$rate" -gt 1024 ]; then
rate=`echo "$rate" | awk '{printf "%.1f", $1/1024}'` rate=`echo "$rate" | awk '{printf "%.1f", $1/1024}'`
unit="MB/s" unit="MB/s"
fi fi

3
debian/changelog vendored
View file

@ -4,8 +4,9 @@ byobu (2.6) unreleased; urgency=low
remove the dpkg diversion on /usr/bin/screen as this has proven remove the dpkg diversion on /usr/bin/screen as this has proven
to be controversial; users will need to call "byobu" to launch to be controversial; users will need to call "byobu" to launch
a byobu-style screen session a byobu-style screen session
* bin/network-*: set rate=0 when rate is negative (ie, on startup)
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 26 May 2009 16:47:40 +0200 -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 26 May 2009 21:52:53 +0200
byobu (2.5-0ubuntu1) karmic; urgency=low byobu (2.5-0ubuntu1) karmic; urgency=low