mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
* bin/network, profiles/common, profiles/profile.skel: merge network_down
and network_up to a single status script; too much duplication of code, causes performance problems Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
parent
db090a72b1
commit
6acdb68e59
5 changed files with 7 additions and 113 deletions
|
@ -1,54 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# network_down: calculate the network receive rate
|
||||
# Copyright (C) 2008 Canonical Ltd.
|
||||
#
|
||||
# Authors: Dustin Kirkland <kirkland@canonical.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
PKG="byobu"
|
||||
|
||||
cache="/var/run/screen/S-$USER/$PKG.network_down"
|
||||
unit="kB/s"
|
||||
|
||||
# Allow interface overrides in configuration directory
|
||||
if [ -r "$HOME/.$PKG/network" ]; then
|
||||
interface=`cat "$HOME/.$PKG/network"`
|
||||
else
|
||||
interface=`/sbin/route -n | tail -n 1 | sed "s/^.* //"`
|
||||
fi
|
||||
|
||||
if [ "$1" = "--detail" ]; then
|
||||
/sbin/ifconfig "$interface" | sed 's/\s*$//'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0
|
||||
t2=`date +%s`
|
||||
|
||||
if [ $t2 -le $t1 ]; then
|
||||
rate=0
|
||||
else
|
||||
x1=`cat "$cache"` 2>/dev/null || tx1=0
|
||||
x2=`/sbin/ifconfig "$interface" | grep "RX bytes" | sed "s/^.*RX bytes://" | sed "s/ .*$//"`
|
||||
echo "$x2" > "$cache"
|
||||
rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'`
|
||||
if [ "$rate" -lt 0 ]; then
|
||||
rate=0
|
||||
elif [ "$rate" -gt 1024 ]; then
|
||||
rate=`echo "$rate" | awk '{printf "%.1f", $1/1024}'`
|
||||
unit="MB/s"
|
||||
fi
|
||||
fi
|
||||
printf "v\005{=b mw}$rate\005{-}\005{= mw}$unit\005{-} "
|
|
@ -1,55 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# network_up: calculate the network transmit rate
|
||||
# Copyright (C) 2008 Canonical Ltd.
|
||||
#
|
||||
# Authors: Dustin Kirkland <kirkland@canonical.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
PKG="byobu"
|
||||
|
||||
cache="/var/run/screen/S-$USER/$PKG.network_up"
|
||||
unit="kB/s"
|
||||
|
||||
# Allow interface overrides in configuration directory
|
||||
if [ -r "$HOME/.$PKG/network" ]; then
|
||||
interface=`cat "$HOME/.$PKG/network"`
|
||||
else
|
||||
interface=`/sbin/route -n | tail -n 1 | sed "s/^.* //"`
|
||||
fi
|
||||
|
||||
|
||||
if [ "$1" = "--detail" ]; then
|
||||
/sbin/ifconfig "$interface" | sed 's/\s*$//'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0
|
||||
t2=`date +%s`
|
||||
|
||||
if [ $t2 -le $t1 ]; then
|
||||
rate=0
|
||||
else
|
||||
x1=`cat "$cache"` 2>/dev/null || tx1=0
|
||||
x2=`/sbin/ifconfig "$interface" | grep "TX bytes" | sed "s/^.*TX bytes://" | sed "s/ .*$//"`
|
||||
echo "$x2" > "$cache"
|
||||
rate=`echo "$t1" "$t2" "$x1" "$x2" | awk '{printf "%.0f", ($4 - $3) / ($2 - $1) / 1024 }'`
|
||||
if [ "$rate" -lt 0 ]; then
|
||||
rate=0
|
||||
elif [ "$rate" -gt 1024 ]; then
|
||||
rate=`echo "$rate" | awk '{printf "%.1f", $1/1024}'`
|
||||
unit="MB/s"
|
||||
fi
|
||||
fi
|
||||
printf "^\005{=b mw}$rate\005{-}\005{= mw}$unit\005{-} "
|
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -14,8 +14,11 @@ byobu (2.12) unreleased; urgency=low
|
|||
* bin/wifi_quality: significant performance improvements, remove unneeded
|
||||
route call, cache iwconfig output so that it's only called once
|
||||
* bin/processes: improve performance by listing /proc (doubles the speed)
|
||||
* bin/network, profiles/common, profiles/profile.skel: merge network_down
|
||||
and network_up to a single status script; too much duplication of code,
|
||||
causes performance problems
|
||||
|
||||
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 16 Jun 2009 16:10:36 -0500
|
||||
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 16 Jun 2009 16:35:01 -0500
|
||||
|
||||
byobu (2.11-0ubuntu1) karmic; urgency=low
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ backtick 113 30 30 byobu-status battery
|
|||
backtick 114 10 10 byobu-status users
|
||||
backtick 115 60 60 byobu-status uptime
|
||||
backtick 116 2 2 byobu-status processes
|
||||
backtick 117 2 2 byobu-status network_up
|
||||
backtick 118 2 2 byobu-status network_down
|
||||
backtick 117 2 2 byobu-status network
|
||||
backtick 118 86400 86400 true
|
||||
backtick 119 10 10 byobu-status wifi_quality
|
||||
backtick 120 86400 86400 byobu-status date
|
||||
backtick 121 86400 86400 byobu-status time
|
||||
|
|
|
@ -26,7 +26,7 @@ source /usr/share/byobu/profiles/common
|
|||
caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%? %= %{= Wk}%110`%109`%122`%111`"
|
||||
|
||||
# Status string, last line
|
||||
hardstatus string '%99`%{= Wk} %100`%112`%= %102`%101`%114`%115`%108`%125`%126`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`%123`%124`%120`%121`'
|
||||
hardstatus string '%99`%{= Wk} %100`%112`%= %102`%101`%114`%115`%108`%125`%126`%113`%119`%117``%116`%106`%104`%103`%105`%107`%123`%124`%120`%121`'
|
||||
|
||||
# NOTE: Older version of screen have an arbitrary limit of only being able
|
||||
# to change colors 16 times in this 'hardstatus string'.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue