[mythtv-users] Status check/monitoring of mythbackend
Henrik Ostergaard Madsen
Henrik at ostergaard.net
Thu Dec 6 16:39:07 UTC 2007
My monit-conf for monitoring myth-backend is:
check process mythbackend with pidfile /var/run/mythtv/mythbackend.pid
every 3 cycles
start program = "/etc/init.d/mythtv-backend start"
stop program = "/etc/init.d/mythtv-backend stop"
if failed host Mythserver port 6543 3 times within 10 cycles then restart
if 5 restarts within 15 cycles then timeout
This has been working fine for half a year. It has to incorporate a delay
before restarting it, as it can be rather long to startup after a restart.
/Henrik
And my startupscript in /etc/init.d is:
#! /bin/sh
### BEGIN INIT INFO
# Provides: mythtv-backend
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 24
# Default-Stop: S
# Short-Description: Start/Stop the MythTV server.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/mythbackend
NAME="mythbackend"
DESC="MythTV server"
test -x $DAEMON || exit 0
set -e
USER=mythtv
RUNDIR=/var/run/mythtv
ARGS="--daemon --logfile /var/log/mythtv/mythbackend.log --pidfile
$RUNDIR/$NAME.pid --noupnp"
EXTRA_ARGS=""
NICE=0
if [ -f /etc/default/mythtv-backend ]; then
. /etc/default/mythtv-backend
fi
ARGS="$ARGS $EXTRA_ARGS"
mkdir -p $RUNDIR
chown -R $USER $RUNDIR
case "$1" in
start)
if test -e $RUNDIR/$NAME.pid ; then
# echo "mythbackend already running, use restart instead."
$0 restart
else
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
--chuid $USER --nicelevel $NICE --exec $DAEMON --
$ARGS
echo "."
fi
;;
stop)
echo -n "Stopping $DESC: $NAME "
start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
--chuid $USER --exec $DAEMON -- $ARGS
test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
--chuid $USER --exec $DAEMON -- $ARGS
echo "."
sleep 3
start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
--chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
echo "."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
More information about the mythtv-users
mailing list