-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollectd.init
executable file
·99 lines (90 loc) · 2.02 KB
/
collectd.init
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
#
# collectd Startup script for the Collectd statistics gathering daemon
# chkconfig: - 99 01
# description: Collectd is a statistics gathering daemon used to collect \
# system information ie. cpu, memory, disk, network
# processname: collectd
# config: /etc/collectd.conf
# config: /etc/sysconfig/collectd
# pidfile: /var/run/collectd.pid
# Source function library.
. /etc/init.d/functions
RETVAL=0
ARGS=""
prog="collectdmon"
service="collectd"
CONFIG=/etc/collectd.conf
COLLECTD=/usr/sbin/collectd
COLLECTDMONPIDDIR="/var/run"
COLLECTDMONPID="$COLLECTDMONPIDDIR/collectdmon.pid"
if [ -r /etc/sysconfig/$service ]; then
. /etc/sysconfig/$service
fi
if [[ ! -d $COLLECTDMONPIDDIR ]]; then
mkdir -p $COLLECTDMONPIDDIR
[ -n "${RUNAS}" ] && chown "${RUNAS}:" "$COLLECTDMONPIDDIR"
fi
check_config() {
if test ! -r "$CONFIG"; then
return 2
fi
if ! $COLLECTD -t -C "$CONFIG"; then
return 1
fi
return 0
}
start () {
echo -n $"Starting collectd: "
check_config
rc="$?"
if test "$rc" -ne 0; then
RETVAL=6
echo $"not starting due to configuration error"
failure $"not starting $service due to configuration error"
else
daemon --user "${RUNAS:-root}" $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG" $ARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$service
fi
}
stop () {
echo -n $"Stopping collectd: "
killproc -p $COLLECTDMONPID $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$service
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p $COLLECTDMONPID $prog
;;
restart|reload)
check_config
rc="$?"
if test "$rc" -ne 0; then
RETVAL=6
echo $"not restarting due to configuration error"
failure $"not restarting $service due to configuration error"
else
stop
start
fi
;;
condrestart)
[ -f /var/lock/subsys/$service ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $?
# vim:syntax=sh