#!/usr/bin/sh
#
# rrdcollect	Start/Stop Round-Robin Database Collecting Daemon
#
# chkconfig: - 05 95
# description:	RRDcollect is a daemon which polls ceratin files in /proc/ \
#		directory, gathering data and storing it inside RRDtool's \
#		database files.
# processname: rrdcollect
# pidfile: /var/run/rrdcollect.pid
# config: /etc/rrdcollect.conf
#
### BEGIN INIT INFO
# Provides: rrdcollect
# Default-Start: 3 4 5
# Short-Description: Round-Robin Database Collecting Daemon
# Description: Round-Robin Database Collecting Daemon
### END INIT INFO

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

# Get identd config

[ -f /etc/sysconfig/rrdcollect ] && . /etc/sysconfig/rrdcollect

[ -x /usr/sbin/rrdcollect ] || exit 0

RETVAL=0
prog="rrdcollect"

start() {
        gprintf "Starting %s: " "$prog"
        daemon rrdcollect $RRDCOLLECTOPTS
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rrdcollect
	return $RETVAL
}

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

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status rrdcollect
	;;
  restart|reload)
	stop
	sleep 2
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/rrdcollect ]; then
            stop
            start
        fi
	;;
  *)
	gprintf "Usage: %s {start|stop|status|restart|reload|condrestart}\n" "$0"
	exit 1
esac

exit $RETVAL
