#!/bin/bash
#
#       /etc/rc.d/init.d/xymon
#
# Starts the xymon monitor daemon
#
## chkconfig: 345 95 5
## description: Runs xymon the monitortool
## processname: hobbitd
### BEGIN INIT INFO
# Provides: xymon
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the xymon monitor server
### END INIT INFO


RETVAL=0

#
#       See how we were called.
#

prog="xymon"

start() {
        # Check if xymon is already running
        echo -n $"Starting $prog: "
        su - xymon -c "/opt/monitor/xymon/server/hobbit.sh start"
        su - xymon -c "/opt/monitor/xymon/client/runclient.sh start"
}

stop() {
        echo -n $"Stopping $prog: "
        su - xymon -c "/opt/monitor/xymon/server/hobbit.sh stop"
        su - xymon -c "/opt/monitor/xymon/client/runclient.sh stop"
}


restart() {
        echo -n $"restarting $prog: "
        su - xymon -c "/opt/monitor/xymon/server/hobbit.sh restart"
        su - xymon -c "/opt/monitor/xymon/client/runclient.sh restart"

}

status() {
        echo -n $"status $prog: "
        su - xymon -c "/opt/monitor/xymon/server/hobbit.sh status"
        su - xymon -c "/opt/monitor/xymon/client/runclient.sh status"
}


reload() {
        restart
}

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload|restart)
        restart
        ;;
status)
        status
        ;;
*)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit $?
exit $RETVAL
