[collectd] chkconfig compatible init.d-rh7 script

Nathan Hyde nhyde at bigdrift.com
Mon Jan 23 21:27:30 CET 2006


Two minor additions to the init script in the 3.5.2 contrib dir to make it
compatible with chkconfig. (Added initial comments as well as the collectd
var to tell the script where collectd lives.)

Hope this is helpful to someone.

Nathan
---

#!/bin/bash

# chkconfig: 2345 85 60
# description: collectd is a small daemon which collects system
information every 10 seconds and writes the results in an RRD-file.
# processname: collectd

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

RETVAL=0
ARGS=""
prog="collectd"

# change this to the location where collectd is installed
collectd='/opt/collectd/sbin/collectd'

if [ -r /etc/default/$prog ]; then
        . /etc/default/$prog
fi

if [ -n "$DATA_DIR" ]; then
        ARGS="-D $DATA_DIR"
fi

if [ -n "$PING_HOST" ]; then
        for HOST in $PING_HOST
        do
                ARGS="$ARGS -p $HOST"
        done
fi

start () {
        if [ "x$START_SERVER" = "xyes" ]
        then
                echo -n $"Starting $prog (server): "
                daemon $collectd -s $ARGS
                RETVAL=$?
                echo
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        fi
        if [ "x$START_CLIENT" = "xyes" ]
        then
                echo -n $"Starting $prog (client): "
                daemon $collectd -c $ARGS
                RETVAL=$?
                echo
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        fi
        if [ "x$START_SERVER" != "xyes" -a "x$START_CLIENT" != "xyes" ]
        then
                echo -n $"Starting $prog: "
                daemon $collectd -l $ARGS
                RETVAL=$?
                echo
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        fi
}
stop () {
        echo -n $"Stopping $prog: "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
}
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  restart|reload)
        stop
        start
        ;;
  condrestart)
        [ -f /var/lock/subsys/$prog ] && restart || :
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
        exit 1
esac

exit $RETVAL






More information about the Collectd mailing list