#!/bin/sh
#
# Init file for the Job Monitoring Daemon
#
# chkconfig: 2345 20 80
# description: jobmond reports information on batch jobs as Ganglia metrics
#
# processname: jobmond
# config: /etc/jobmond.conf
# config: /etc/sysconfig/jobmond
# pidfile: /var/run/jobmond

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0
name=jobmond
prog=/usr/sbin/jobmond
desc="Job Monitoring Daemon"

OPTIONS=""

if [ -r /etc/sysconfig/$name ]; then
	source /etc/sysconfig/$name
fi

start() {
	echo -n $"Starting $desc: "
	daemon $prog -p /var/run/$name.pid $OPTIONS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$name
	return $RETVAL
}

stop() {
	echo -n $"Stopping $desc: "
	killproc $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$name
	return $RETVAL
}

restart() {
	stop
	start
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	condrestart)
		[ -e /var/lock/subsys/$name ] && restart
		RETVAL=$?
		;;
	status)
		status python
		RETVAL=$?
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
