* usr/lib/byobu/network:

- fix but where /proc/net/dev has so much traffic that integers
    run up against colons with no whitespace
This commit is contained in:
Dustin Kirkland 2011-06-16 12:28:55 -05:00
commit 8be11ec0f2
2 changed files with 8 additions and 2 deletions

5
debian/changelog vendored
View file

@ -1,6 +1,9 @@
byobu (4.13) unreleased; urgency=low byobu (4.13) unreleased; urgency=low
* UNRELEASED [ Scott Moser ]
* usr/lib/byobu/network:
- fix but where /proc/net/dev has so much traffic that integers
run up against colons with no whitespace
-- Dustin Kirkland <kirkland@ubuntu.com> Thu, 16 Jun 2011 11:37:56 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Thu, 16 Jun 2011 11:37:56 -0500

View file

@ -42,6 +42,7 @@ fi
[ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$DATA" [ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$DATA"
t2=`date +%s` t2=`date +%s`
OIFS=$IFS
for i in up down; do for i in up down; do
unit="kbps" unit="kbps"
case $i in case $i in
@ -54,12 +55,14 @@ for i in up down; do
rate=0 rate=0
else else
[ -r "$cache" ] && read x1 < "$cache" || tx1=0 [ -r "$cache" ] && read x1 < "$cache" || tx1=0
IFS="$OIFS:"
while read iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed; do 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
[ "$i" = "up" ] && x2=${tbytes} || x2=${rbytes} [ "$i" = "up" ] && x2=${tbytes} || x2=${rbytes}
break; break;
fi fi
done < /proc/net/dev done < /proc/net/dev
IFS=$OIFS
echo "$x2" > "$cache" echo "$x2" > "$cache"
rate=$((8*($x2 - $x1) / ($t2 - $t1) / 1024)) # in kbps rate=$((8*($x2 - $x1) / ($t2 - $t1) / 1024)) # in kbps
[ "$rate" -lt 0 ] && rate=0 [ "$rate" -lt 0 ] && rate=0