byobu-config, byobu.1, profiles/common, rpm/byobu.spec, statusrc,

bin/services: add a service status item to monitor running services
This commit is contained in:
Dustin Kirkland 2010-01-07 18:41:22 -06:00
commit bf78b26ad5
7 changed files with 79 additions and 2 deletions

69
bin/services Executable file
View file

@ -0,0 +1,69 @@
#!/bin/sh -e
#
# services: show what services are running on this server (configurable)
#
# Copyright (C) 2009 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"
color 2>/dev/null || color() { true; }
# Users can define a list of SERVICES to monitor in $HOME/.byobu/status
if [ -z "$SERVICES" ]; then
if [ -f "/etc/eucalyptus/eucalyptus.conf" ]; then
# If the user has not defined any SERVICES, but this system is a
# UEC system, default to the list of Ubuntu Enterprise Cloud Services
SERVICES="eucalyptus-cloud|CLC eucalyptus-walrus|WC eucalyptus-cc|CC eucalyptus-sc|SC eucalyptus-nc|NC"
fi
fi
running() {
if [ -f "/etc/init/$1.conf" ]; then
# Use upstart
status $1 2>/dev/null | grep -qs running && true
elif [ -f "/etc/init.d/$1" ]; then
# Fall back to sysvinit
/etc/init.d/$1 status >/dev/null 2>&1
else
false
fi
}
output=
for i in $SERVICES; do
service=$(echo "$i" | sed "s/|.*//")
nick=$(echo "$i" | sed "s/.*|//")
case "$service" in
eucalyptus-nc)
if running $service; then
# This is a node controller, determine VM usage
. /etc/eucalyptus/eucalyptus.conf
if [ -z "$MAX_CORES" ]; then
max=$(grep -ci "^processor" /proc/cpuinfo)
else
max="$MAX_CORES"
fi
count=$(pgrep -c kvm)
output="$output,NC ($count/$max)"
fi
;;
*)
running $service && output="$output,$nick"
;;
esac
done
printf "$(color w c)$(echo $output | sed 's/^,//')$(color -) "

View file

@ -295,6 +295,7 @@ def readstatus():
status["processes"]=0
status["reboot_required"]=1
status["release"]=1
status["services"]=1
status["temp_c"]=0
status["temp_f"]=0
status["time"]=1

View file

@ -15,6 +15,8 @@ byobu \- wrapper script for seeding a user's byobu configuration and launching s
\fBbattery\fP \- battery information; display on the lower bar toward the right; |\-| indicates discharging, |+| indicates charging, |=| indicates fully charged; when charging or discharging, the current battery capacity as a percentage is displayed; the colours green, yellow, and red are used to give further indication of the battery's charge state
\fBservices\fP \- users can configure a list of services to monitor, define the SERVICES variable in $HOME/.byobu/status, a whitespace separated of services, each service should include the init name of the service, then a pipe, and then an abbreviated name or symbol to display when running; displayed in the lower bar toward the center in cyan on a white background
\fBcpu_count\fP \- the number of cpu's or cores on the system; displayed in the lower bar toward the right in the default text color on the default background, followed by a trailing 'x'
\fBcpu_freq\fP \- the current frequency of the cpu in GHz; displayed in the lower bar toward the right in white text on a light blue background

3
debian/changelog vendored
View file

@ -1,6 +1,7 @@
byobu (2.44) unreleased; urgency=low
* UNRELEASED
* byobu-config, byobu.1, profiles/common, rpm/byobu.spec, statusrc,
bin/services: add a service status item to monitor running services
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 29 Dec 2009 20:32:32 -0600

View file

@ -68,6 +68,7 @@ backtick 127 5 5 byobu-status mail
backtick 128 23 23 byobu-status fan_speed
backtick 129 67 67 byobu-status apport
backtick 130 5 5 byobu-status custom
backtick 131 53 53 byobu-status services
hardstatus alwayslastline
@ -97,7 +98,7 @@ source $HOME/.byobu/keybindings
caption always "%12`%?%-Lw%50L>%?%{=r}%{+u}%n*%f %t%?(%u)%?%{-}%12`%?%+Lw%?%11` %=%12`%110`%109`%122`%111`%10`%<"
# Status string, last line
hardstatus string '%99`%{-}%{=r}%12` %100`%112`%= %130`%102`%101`%129`%127`%114`%115`%108`%128`%125`%126`%113`%119`%117`%116`%106`%104`%103`%105`%107`%123`%120`%121`'
hardstatus string '%99`%{-}%{=r}%12` %100`%112`%= %130`%102`%101`%129`%131`%127`%114`%115`%108`%128`%125`%126`%113`%119`%117`%116`%106`%104`%103`%105`%107`%123`%120`%121`'
# NOTE: Older version of screen have an arbitrary limit of only being able
# to change colors 16 times in this 'hardstatus string'.

View file

@ -103,6 +103,7 @@ rm -rf $RPM_BUILD_ROOT
/usr/lib/byobu/processes
/usr/lib/byobu/reboot_required
/usr/lib/byobu/release
/usr/lib/byobu/services
/usr/lib/byobu/temp_c
/usr/lib/byobu/temp_f
/usr/lib/byobu/time

View file

@ -42,6 +42,7 @@ network=0
processes=0
reboot_required=1
release=1
services=1
temp_c=0
temp_f=0
time=1
@ -58,4 +59,5 @@ wifi_quality=0
#MONITORED_INTERFACE=eth0
#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature
#DISTRO=Ubuntu
#SERVICES="eucalyptus-nc|NC eucalyptus-cloud|CLC eucalyptus-walrus eucalyptus-cc|CC eucalyptus-sc|SC"
# END_CUT_HERE