* etc/byobu/statusrc, usr/lib/byobu/disk_io, usr/lib/byobu/network,

usr/share/man/man1/byobu.1:
    ignore network traffic less than threshold, less busy status
  - add support for a disk threshold setting; set to 50kB/s by default,
    ignore disk traffic less than threshold, less busy status
This commit is contained in:
Dustin Kirkland 2011-05-25 17:00:53 -05:00
commit 26e3f0c46e
5 changed files with 25 additions and 11 deletions

7
debian/changelog vendored
View file

@ -10,9 +10,12 @@ byobu (4.3) unreleased; urgency=low
- fix the motd display at auto launch, which was broken recently - fix the motd display at auto launch, which was broken recently
* usr/lib/byobu/mem_available: * usr/lib/byobu/mem_available:
- fix MB display bug - fix MB display bug
* etc/byobu/statusrc, usr/lib/byobu/network: * etc/byobu/statusrc, usr/lib/byobu/disk_io, usr/lib/byobu/network,
usr/share/man/man1/byobu.1:
- add support for a network threshold setting; set to 20kbps by default, - add support for a network threshold setting; set to 20kbps by default,
ignore network traffic less than 20kbps; less busy status ignore network traffic less than threshold, less busy status
- add support for a disk threshold setting; set to 50kB/s by default,
ignore disk traffic less than threshold, less busy status
[ Scott Moser ] [ Scott Moser ]
* usr/lib/byobu/.shutil: fix rounding across a decimal point in fpdiv() * usr/lib/byobu/.shutil: fix rounding across a decimal point in fpdiv()

View file

@ -62,6 +62,7 @@ wifi_quality=1
# Byobu will auto-detect them. # Byobu will auto-detect them.
#LOGO="\o/" #LOGO="\o/"
#MONITORED_DISK=/ #MONITORED_DISK=/
#DISK_IO_THRESHOLD=50
#MONITORED_INTERFACE=eth0 #MONITORED_INTERFACE=eth0
#NETWORK_THRESHOLD=20 #NETWORK_THRESHOLD=20
#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature #MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature

View file

@ -29,7 +29,7 @@ getdisk() {
t="$1" t="$1"
fi fi
t="${t##*/}"; t="${t##*/}";
rtrim "$t" "0-9" [ -h "/sys/block/$t" ] && _RET="$t" || rtrim "$t" "0-9"
} }
[ "$UTF8" = "1" ] && ICON_RD="◀" || ICON_RD="<" [ "$UTF8" = "1" ] && ICON_RD="◀" || ICON_RD="<"
@ -38,6 +38,10 @@ getdisk() {
# Default to disk providing /, but let users override with MONITORED_DISK # Default to disk providing /, but let users override with MONITORED_DISK
[ -z "$MONITORED_DISK" ] && MP="/" || MP="$MONITORED_DISK" [ -z "$MONITORED_DISK" ] && MP="/" || MP="$MONITORED_DISK"
# By default, we won't bug the user with the display of network traffic
# below DISK_IO_THRESHOLD in kB/s; override in $DATA/status
[ -n "$DISK_IO_THRESHOLD" ] || DISK_IO_THRESHOLD=50
if [ "$1" = "--detail" ]; then if [ "$1" = "--detail" ]; then
if command -v iostat >/dev/null; then if command -v iostat >/dev/null; then
iostat -d -m -h iostat -d -m -h
@ -74,7 +78,10 @@ for i in "read" "write"; do
fi fi
echo "$x2" > "$cache" echo "$x2" > "$cache"
rate=$((($x2 - $x1) / ($t2 - $t1) * 512 / 1024)) rate=$((($x2 - $x1) / ($t2 - $t1) * 512 / 1024))
if [ "$rate" -lt 0 ]; then if [ $rate -lt $DISK_IO_THRESHOLD ]; then
# Below threshold, exit immediately!
exit 0
elif [ "$rate" -lt 0 ]; then
rate=0 rate=0
elif [ "$rate" -gt 1048576 ]; then elif [ "$rate" -gt 1048576 ]; then
unit="GB/s" unit="GB/s"

View file

@ -61,12 +61,16 @@ for i in up down; do
fi fi
done < /proc/net/dev done < /proc/net/dev
echo "$x2" > "$cache" echo "$x2" > "$cache"
rate=$((($x2 - $x1) / ($t2 - $t1) / 1024)) rate=$(8 * (($x2 - $x1) / ($t2 - $t1) / 1024)) # in kbps
if [ "$rate" -lt 0 ]; then [ "$rate" -lt 0 ] && rate=0
rate=0 fi
if [ $rate -lt $NETWORK_THRESHOLD ];
# Below threshold, exit immediately!
exit 0
fi fi
case "$NETWORK_UNITS" in case "$NETWORK_UNITS" in
bytes) bytes)
rate=$(($rate/8))
if [ "$rate" -gt 1048576 ]; then if [ "$rate" -gt 1048576 ]; then
fpdiv "$rate" 1048576 1 fpdiv "$rate" 1048576 1
rate=${_RET} rate=${_RET}
@ -81,7 +85,6 @@ for i in up down; do
;; ;;
*) *)
# Default to bps # Default to bps
rate=$(($rate*8))
# Why 1000 and not 1024? http://en.wikipedia.org/wiki/Data_rate_units # Why 1000 and not 1024? http://en.wikipedia.org/wiki/Data_rate_units
if [ "$rate" -gt 1000000 ]; then if [ "$rate" -gt 1000000 ]; then
fpdiv "$rate" 1000000 1 fpdiv "$rate" 1000000 1
@ -95,7 +98,7 @@ for i in up down; do
;; ;;
esac esac
fi fi
if [ "$rate" -gt $NETWORK_THRESHOLD ]; then if [ "$rate" -gt 0 ]; then
color b m w; printf "%s%s" "$symbol" "$rate"; color -; color m w; printf "%s" "$unit"; color -- color b m w; printf "%s%s" "$symbol" "$rate"; color -; color m w; printf "%s" "$unit"; color --
fi fi
done done

View file

@ -37,7 +37,7 @@ Note that DATA=\fI$HOME/.byobu\fP.
\fBdisk\fP \- total disk space available and total used on / directory; displayed in the lower bar on the far right in white text on a light purple background; override the default directory by specifying an alternate mount point with MONITORED_DISK=/wherever in \fI$DATA/statusrc\fP \fBdisk\fP \- total disk space available and total used on / directory; displayed in the lower bar on the far right in white text on a light purple background; override the default directory by specifying an alternate mount point with MONITORED_DISK=/wherever in \fI$DATA/statusrc\fP
\fBdisk_io\fP \- instantaneous read/write througput in kB/s or MB/s over the last 3 seconds; displayed in the lower bar toward the right in white text on a light purple background with a leading '<' sign indicating 'read speed' and '>' sign indicating 'write speed'; override the default monitored disk by specifying an alternate device with MONITORED_DISK=/dev/sdb in \fI$DATA/statusrc\fP \fBdisk_io\fP \- instantaneous read/write througput in kB/s or MB/s over the last 3 seconds; displayed in the lower bar toward the right in white text on a light purple background with a leading '<' sign indicating 'read speed' and '>' sign indicating 'write speed'; override the default monitored disk by specifying an alternate device with MONITORED_DISK=/dev/sdb, and override the default DISK_IO_THRESHOLD=50 (kB/s) in \fI$DATA/statusrc\fP
\fBec2_cost\fP \- an estimation of the cost of the current boot of the system in terms of the Amazon EC2 billing model; displayed in the lower bar toward the right in green text on a black background; there is a leading '~' to indicate that this is an estimation, and the monetary units are US Dollars '$' \fBec2_cost\fP \- an estimation of the cost of the current boot of the system in terms of the Amazon EC2 billing model; displayed in the lower bar toward the right in green text on a black background; there is a leading '~' to indicate that this is an estimation, and the monetary units are US Dollars '$'
@ -63,7 +63,7 @@ Note that DATA=\fI$HOME/.byobu\fP.
\fBmenu\fP \- a simple indicator directing new users to use the F9 keybinding to access the byobu menu \fBmenu\fP \- a simple indicator directing new users to use the F9 keybinding to access the byobu menu
\fBnetwork\fP \- instantaneous upload/download bandwidth in [GMk]bps over the last 3 seconds; nothing is displayed if traffic is 0; displayed in the lower bar toward the left in white text on a purple background with a leading '^' sign indicating 'up' and 'v' sign indicating 'down'; override the default interface by specifying an alternate interface with MONITORED_NETWORK=eth1, and override the default units (bits) with NETWORK_UNITS=bytes in \fI$DATA/statusrc\fP \fBnetwork\fP \- instantaneous upload/download bandwidth in [GMk]bps over the last 3 seconds; nothing is displayed if traffic is 0; displayed in the lower bar toward the left in white text on a purple background with a leading '^' sign indicating 'up' and 'v' sign indicating 'down'; override the default interface by specifying an alternate interface with MONITORED_NETWORK=eth1, and override the default units (bits) with NETWORK_UNITS=bytes, and override the default NETWORK_THRESHOLD=20 (kbps) in \fI$DATA/statusrc\fP
\fBnotify_osd\fP \- Send on-screen notification messages to screen's notification buffer \fBnotify_osd\fP \- Send on-screen notification messages to screen's notification buffer