* usr/lib/byobu/network: LP: #1203601

- fix issue where /proc/net/dev isn't read correctly; use an
    intermediate cache file
This commit is contained in:
Dustin Kirkland 2013-08-16 15:50:38 -05:00
commit 80471d9440
2 changed files with 5 additions and 1 deletions

3
debian/changelog vendored
View file

@ -3,6 +3,9 @@ byobu (5.56) unreleased; urgency=low
* usr/lib/byobu/battery: * usr/lib/byobu/battery:
- fix battery status caching issues when battery is full, or - fix battery status caching issues when battery is full, or
plugged into AC plugged into AC
* usr/lib/byobu/network: LP: #1203601
- fix issue where /proc/net/dev isn't read correctly; use an
intermediate cache file
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 10 Aug 2013 09:23:04 +0100 -- Dustin Kirkland <kirkland@ubuntu.com> Sat, 10 Aug 2013 09:23:04 +0100

View file

@ -41,6 +41,7 @@ __network() {
cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/network.$i" cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/network.$i"
[ -r "$cache" ] && read x1 < "$cache" || tx1=0 [ -r "$cache" ] && read x1 < "$cache" || tx1=0
local iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed local iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed
cat /proc/net/dev > "$cache".dev
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
case "$iface" in case "$iface" in
${interface}:) ${interface}:)
@ -53,7 +54,7 @@ __network() {
break; break;
;; ;;
esac esac
done < /proc/net/dev done < "$cache".dev
printf "%s" "$x2" > "$cache" printf "%s" "$x2" > "$cache"
rate=$((8*($x2 - $x1) / $t / 1024)) # in kbps rate=$((8*($x2 - $x1) / $t / 1024)) # in kbps
[ "$rate" -lt 0 ] && rate=0 [ "$rate" -lt 0 ] && rate=0