mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 14:24:39 -07:00
* usr/lib/byobu/network:
- fix shell comparator bug when number has decimal
This commit is contained in:
parent
cb4db8701b
commit
7c3683fa33
2 changed files with 34 additions and 34 deletions
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -1,6 +1,7 @@
|
|||
byobu (4.7) unreleased; urgency=low
|
||||
|
||||
* UNRELEASED
|
||||
* usr/lib/byobu/network:
|
||||
- fix shell comparator bug when number has decimal
|
||||
|
||||
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 28 May 2011 12:58:05 -0500
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ DATA="$HOME/.$PKG"
|
|||
color 2>/dev/null || color() { true; }
|
||||
[ "$UTF8" = "1" ] && ICON_UP="▲" || ICON_UP="^"
|
||||
[ "$UTF8" = "1" ] && ICON_DN="▼" || ICON_DN="v"
|
||||
. /usr/lib/byobu/.shutil
|
||||
|
||||
# Allow interface overrides in $DATA/status
|
||||
if [ -n "$MONITORED_NETWORK" ]; then
|
||||
|
@ -63,41 +64,39 @@ for i in up down; do
|
|||
echo "$x2" > "$cache"
|
||||
rate=$((8*($x2 - $x1) / ($t2 - $t1) / 1024)) # in kbps
|
||||
[ "$rate" -lt 0 ] && rate=0
|
||||
if [ $rate -lt $NETWORK_THRESHOLD ]; then
|
||||
# Below threshold, exit immediately!
|
||||
exit 0
|
||||
if [ $rate -gt $NETWORK_THRESHOLD ]; then
|
||||
case "$NETWORK_UNITS" in
|
||||
bytes)
|
||||
rate=$(($rate/8))
|
||||
if [ "$rate" -gt 1048576 ]; then
|
||||
fpdiv "$rate" 1048576 1
|
||||
rate=${_RET}
|
||||
unit="GB/s"
|
||||
elif [ "$rate" -gt 1024 ]; then
|
||||
fpdiv "$rate" 1024 1
|
||||
rate=${_RET}
|
||||
unit="MB/s"
|
||||
else
|
||||
unit="kB/s"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Default to bps
|
||||
# Why 1000 and not 1024? http://en.wikipedia.org/wiki/Data_rate_units
|
||||
if [ "$rate" -gt 1000000 ]; then
|
||||
fpdiv "$rate" 1000000 1
|
||||
rate=${_RET}
|
||||
unit="Gbps"
|
||||
elif [ "$rate" -gt 1000 ]; then
|
||||
fpdiv "$rate" 1000 1
|
||||
rate=${_RET}
|
||||
unit="Mbps"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case "$NETWORK_UNITS" in
|
||||
bytes)
|
||||
rate=$(($rate/8))
|
||||
if [ "$rate" -gt 1048576 ]; then
|
||||
fpdiv "$rate" 1048576 1
|
||||
rate=${_RET}
|
||||
unit="GB/s"
|
||||
elif [ "$rate" -gt 1024 ]; then
|
||||
fpdiv "$rate" 1024 1
|
||||
rate=${_RET}
|
||||
unit="MB/s"
|
||||
else
|
||||
unit="kB/s"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Default to bps
|
||||
# Why 1000 and not 1024? http://en.wikipedia.org/wiki/Data_rate_units
|
||||
if [ "$rate" -gt 1000000 ]; then
|
||||
fpdiv "$rate" 1000000 1
|
||||
rate=${_RET}
|
||||
unit="Gbps"
|
||||
elif [ "$rate" -gt 1000 ]; then
|
||||
fpdiv "$rate" 1000 1
|
||||
rate=${_RET}
|
||||
unit="Mbps"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ "$rate" -gt 0 ]; then
|
||||
if [ "$rate" != "0" ]; then
|
||||
color b m w; printf "%s%s" "$symbol" "$rate"; color -; color m w; printf "%s" "$unit"; color --
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue