summaryrefslogtreecommitdiffstats
path: root/system/collectd/rc.collectd
blob: 098c01656caffb5f1032033daedd1bd2cb9ffcc5 (plain)
#!/bin/sh
#
# rc.d script for collectd
#
# Thanks to miklos from slacky.eu

exec=/usr/sbin/collectd
prog=$(basename $exec)
configfile=/etc/collectd.conf
pidfile=/var/run/collectd.pid

start() {
    [ -x $exec ] || exit 5
    if [ -f $pidfile ]; then
        echo "Seems that an active process is up and running with pid $(cat $pidfile)"
        echo "If this is not true try first to remove pidfile $pidfile"
        exit 5
    fi
    echo $"Starting $prog"
    $exec -P $pidfile -C $configfile
}

stop() {
    if [ -e $pidfile ]; then
        echo "Stopping $prog"
        kill -QUIT $(cat $pidfile) 2>/dev/null
        rm $pidfile
    fi
}

status() {
    echo -n "$prog is "
    CHECK=$(ps aux | grep $exec | grep -v grep)
    STATUS=$?
    if [ "$STATUS" == "1" ]; then
        echo "not running"
    else
        echo "running"
    fi

}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

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