aboutsummaryrefslogtreecommitdiff
path: root/system/collectd/rc.collectd
blob: 098c01656caffb5f1032033daedd1bd2cb9ffcc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/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 $?