* bin/disk_available, bin/disk_used, bin/hostname, bin/ip_address,

bin/mem_available, byobu-status: drop grepping of status config file,
    source it instead, should improve performance


Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
Dustin Kirkland 2009-06-16 17:20:52 -05:00
commit 71b2160207
7 changed files with 18 additions and 26 deletions

View file

@ -24,13 +24,8 @@ if [ "$1" = "--detail" ]; then
exit 0
fi
comma=
whitespace=
if [ -r "$HOME/.$PKG/status" ]; then
grep -qs "^disk_used=1$" "$HOME/.$PKG/status" && comma="," || whitespace=" "
else
comma=","
fi
. "$HOME/.$PKG/status" 2>/dev/null || true
[ "$disk_used" = "1" ] && comma="," || whitespace=" "
# Default to /, but let users override
[ -r "$HOME/.$PKG/disk" ] && MP=`cat "$HOME/.$PKG/disk"` || MP="/"

View file

@ -24,13 +24,11 @@ if [ "$1" = "--detail" ]; then
exit 0
fi
whitespace=
if [ -r "$HOME/.$PKG/status" ]; then
grep -qs "^date=1$" "$HOME/.$PKG/status" && whitespace=" "
fi
. "$HOME/.$PKG/status" 2>/dev/null || true
[ "$date" = "1" ] && trailer=" "
# Default to /, but let users override
[ -r "$HOME/.$PKG/disk" ] && MP=`cat "$HOME/.$PKG/disk"` || MP="/"
used=`df -h -P "$MP" | tail -n 1 | sed "s/%.*$/%/" | sed "s/^.* //"`
printf "\005{= MW}%s\005{-}%s" "$used" "$whitespace"
printf "\005{= MW}%s\005{-}%s" "$used" "$trailer"

View file

@ -24,7 +24,7 @@ if [ "$1" = "--detail" ]; then
exit 0
fi
at=
grep -qs "^whoami=1$" "$HOME/.$PKG/status" && at="@"
. "$HOME/.$PKG/status" 2>/dev/null || true
[ "$whoami" = "1" ] && at="@"
printf "\005{+b }%s%s\005{-}" "$at" $(hostname -s 2>/dev/null || hostname)

View file

@ -24,9 +24,9 @@ if [ "$1" = "--detail" ]; then
exit 0
fi
space=
grep -qs "^hostname=1$" "$HOME/.$PKG/status" && space=" "
grep -qs "^whoami=1$" "$HOME/.$PKG/status" && space=" "
. "$HOME/.$PKG/status" 2>/dev/null || true
[ "$hostname" = "1" ] && space=" "
[ "$whoami" = "1" ] && space=" "
interface=`/sbin/route -n | tail -n 1 | sed "s/^.* //"`
ipaddr=`/sbin/ifconfig "$interface" | grep "inet addr:" | sed "s/^.*inet addr://" | sed "s/ .*$//"`

View file

@ -24,13 +24,8 @@ if [ "$1" = "--detail" ]; then
exit 0
fi
comma=
whitespace=
if [ -r "$HOME/.$PKG/status" ]; then
grep -qs "^mem_used=1$" "$HOME/.$PKG/status" && comma="," || whitespace=" "
else
comma=","
fi
. "$HOME/.$PKG/status" 2>/dev/null || true
[ "$mem_used" = "1" ] && comma="," || whitespace=" "
mem=`free | grep -m 1 "^Mem:" | awk '{print $2}'`
if [ $mem -ge 1048576 ]; then
@ -43,4 +38,4 @@ else
mem="$mem"
unit="KB"
fi
printf "\005{= gW}%s$unit$comma\005{-}%s" "$mem" "$whitespace"
printf "\005{= gW}%s$unit%s\005{-}%s" "$mem" "$comma" "$whitespace"

View file

@ -66,6 +66,7 @@ fi
P="$1"
eval x=\$$P
export $P
case "$P" in
# default = on, user must override to turn off

5
debian/changelog vendored
View file

@ -18,8 +18,11 @@ byobu (2.12) unreleased; urgency=low
byobu-status, byobu.1, rpm/byobu.spec: merge network_down and
network_up to a single status script; too much duplication of code,
causes performance problems
* bin/disk_available, bin/disk_used, bin/hostname, bin/ip_address,
bin/mem_available, byobu-status: drop grepping of status config file,
source it instead, should improve performance
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 16 Jun 2009 16:40:12 -0500
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 16 Jun 2009 17:20:46 -0500
byobu (2.11-0ubuntu1) karmic; urgency=low