[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [hobbit] Hobbit startup script.
- To: <hobbit (at) hswn.dk>
- Subject: RE: [hobbit] Hobbit startup script.
- From: "Cleaver, Japheth" <jcleaver (at) soe.sony.com>
- Date: Mon, 8 Jun 2009 09:01:45 -0700
- References: <CB3A73A76BED47AB9B6360CF73095F8A (at) behemoth> <200906051229.57919.bgmilne (at) staff.telkomsa.net> <FC43D3D2FDA44AB3AF2C290E7F9F0BB7 (at) behemoth> <200906051615.40009.bgmilne (at) staff.telkomsa.net> <490959CC9BC540819187FF99F48B7C2E (at) behemoth>
- Thread-index: Acnl6Ld3hJTvlFjlTlSXRzzYJDRjfwASHFcAAIgiBoA=
- Thread-topic: [hobbit] Hobbit startup script.
> -----Original Message-----
> From: David Peters [mailto:davidp (at) electronf.com]
> Sent: Friday, June 05, 2009 4:02 PM
> To: hobbit (at) hswn.dk
> Subject: RE: [hobbit] Hobbit startup script.
>
> Sorry, I am referring to the server startup script. All I do atm is
copy
> the
> /home/xymon/server/hobbit.sh script and make the modifications as per
> below.
> I just wonder however why the script requires to be run as hobbit. I
have
> changed the script as per my instructions and it has been running fine
for
> a
> couple of years now.
Attached is a version of the hobbit/xymon init script I use. The package
we have performs a bunch of substitutions on this to get it to conform
to other changes, so it may not work out of the box for you. This should
give you at least an idea of one way to do it, though.
Regards,
Japheth Cleaver
#!/bin/sh
#
# /etc/rc.d/init.d/hobbit
#
# A monitoring tool that reports system statistics from Hobbit clients.
# This shell script takes care of starting and stopping
# the hobbit monitor.
#
# Combines prior hobbit.initd and hobbit.sh files, written to
# Fedora specs -- Copyright 2006 Japheth Cleaver <cleaver (at) rohan.sdsu.edu>
#
# Copyright (C) 2005-2006 Henrik Storner <henrik (at) hswn.dk>
# "status" section (C) Scott Smith 2006
#
# This program is released under the GNU General Public License (GPL),
# version 2. See the file "COPYING" for details.
#
#
# description: hobbit is a network monitoring tool that allows \
# you to monitor hosts and services. This monitor status is
# made available via a web page.
# chkconfig: 2345 90 10
# processname: hobbitlaunch
# config: /etc/hobbit/hobbitlaunch.cfg autoreload
# config: /etc/hobbit/hobbitserver.cfg
# pidfile: /var/run/hobbit/hobbitlaunch.pid
# Source function library.
. /etc/rc.d/init.d/functions || exit 1
# Edited at install time
HOBBITHOME="/usr/share/hobbit/server"
PATH="$PATH"
export HOBBITHOME PATH
# Values used in the initscript (could be rewritten at install also)
logdir="$HOBBITHOME/logs"
tmpdir="$HOBBITHOME/tmp"
pidfile="$HOBBITHOME/logs/hobbitlaunch.pid"
config="$HOBBITHOME/etc/hobbitlaunch.cfg"
runtimefile="$HOBBITHOME/logs/client-runtime.cfg"
envconfig="$HOBBITHOME/etc/hobbitserver.cfg"
prog="hobbit"
user="hobbit"
# Source config file
if [ -f /etc/default/hobbit-client ] ; then
. /etc/default/hobbit-client
fi
if [ -f /etc/default/hobbit ] ; then
. /etc/default/hobbit
fi
# Check for RHEL or Fedora Core 5+, which have more robust initscript functions
HASRECENTFUNCTS="1"
# Check to make sure our pidfile's directory exists
PIDFILEDIR=`dirname $pidfile`
[ -d "$PIDFILEDIR" ] || install -d -o "$user" "$PIDFILEDIR" || exit 1
RETVAL=0
checkruntime() {
# Do we have servers to report back to?
if [ -z "$BBDISPLAYS" -a -z "$HOBBITSERVERS" ]; then
# Empty is ok on servers at this point -- it will just use $BBSERVERIP
:
fi
# Remove any duplicate
test x"$BBDISPLAYS" = x"$HOBBITSERVERS" && HOBBITSERVERS=""
# Prevent warnings later on
test -z "$BBDISPLAYS" && BBDISPLAYS=""
rm -f "$runtimefile"
}
#
# See how we were called.
#
start() {
# Check if it is already running
if [ ! -e /var/lock/subsys/$prog ]; then
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1 # No core dumps
checkruntime
SUCMD=su
[ -x /sbin/runuser ] && SUCMD=/sbin/runuser
$SUCMD -m -s /bin/sh "$user" -c \
"$HOBBITHOME/bin/hobbitlaunch \
--config=$config --env=$envconfig --log=$logdir/hobbitlaunch.log --pidfile=$pidfile" >/dev/null 2>&1
RETVAL=$?
[ "$RETVAL" -eq 0 ] && success && touch /var/lock/subsys/$prog || failure
echo
fi
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
if [ -n "$HASRECENTFUNCTS" ]; then
killproc -p "$pidfile" hobbitlaunch
RETVAL=$?
else
killall -g hobbitlaunch
RETVAL=$?
[ "$RETVAL" -eq 0 ] && success $"$prog shutdown" || failure $"$prog shutdown"
fi
# Kill any vmstat or other hobbit processes lying around
ps -u "$user" -o pid= | xargs -r kill -TERM
rm -f $tmpdir/*vmstat* || :
rm -f "$PIDFILEDIR"/*.pid "/var/lock/subsys/$prog" "$runtimefile"
echo
return $RETVAL
}
reload() {
echo -n $"Reloading $prog configuration files: "
if [ -n "$HASRECENTFUNCTS" ]; then
killproc -p "$pidfile" hobbitlaunch -HUP
RETVAL=$?
else
killall -g hobbitlaunch -HUP
RETVAL=$?
[ "$RETVAL" -eq 0 ] && success $"$prog reloaded" || failure $"$prog reloaded"
fi
echo
return $RETVAL
}
rotate() {
echo -n $"Rotating logs for $prog: "
cat "$PIDFILEDIR"/*.pid 2>/dev/null | xargs -r kill -HUP
RETVAL=$?
[ "$RETVAL" -eq 0 ] && success || failure
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
rotate)
rotate
;;
restart)
stop
start
RETVAL=$?
;;
condrestart)
if [ -e /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
if [ -n "$HASRECENTFUNCTS" ]; then
status -p "$pidfile" hobbitlaunch
else
status hobbitlaunch
fi
RETVAL=$?
;;
*)
echo "Usage: $prog {start|stop|restart|condrestart|status|reload|rotate}"
exit 1
;;
esac
exit $RETVAL