]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # | |
3 | # collectd collectd (collectd daemon) | |
4 | # | |
5 | # chkconfig: 345 93 11 | |
6 | # | |
7 | # description: utility that colect various system information into rrd files | |
8 | # | |
9 | # $Id$ | |
10 | ||
11 | # Source function library | |
12 | . /etc/rc.d/init.d/functions | |
13 | ||
14 | # Get service config | |
15 | [ -f /etc/sysconfig/collectd ] && . /etc/sysconfig/collectd | |
16 | ||
17 | # Get network config | |
18 | . /etc/sysconfig/network | |
19 | ||
20 | # Check that networking is up. | |
21 | if is_yes "${NETWORKING}"; then | |
22 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
23 | msg_network_down collectd | |
24 | exit 1 | |
25 | fi | |
26 | else | |
27 | exit 0 | |
28 | fi | |
29 | ||
30 | checkconfig() { | |
31 | /usr/sbin/collectd -t || exit 1 | |
32 | } | |
33 | ||
34 | start() { | |
35 | # Check if the service is already running? | |
36 | if [ ! -f /var/lock/subsys/collectd ]; then | |
37 | msg_starting collectd | |
38 | daemon /usr/sbin/collectd | |
39 | RETVAL=$? | |
40 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/collectd | |
41 | else | |
42 | msg_already_running collectd | |
43 | fi | |
44 | } | |
45 | ||
46 | stop() { | |
47 | if [ -f /var/lock/subsys/collectd ]; then | |
48 | msg_stopping collectd | |
49 | killproc collectd | |
50 | rm -f /var/lock/subsys/collectd >/dev/null 2>&1 | |
51 | else | |
52 | msg_not_running collectd | |
53 | fi | |
54 | } | |
55 | ||
56 | condrestart() { | |
57 | if [ -f /var/lock/subsys/collectd ]; then | |
58 | checkconfig | |
59 | stop | |
60 | start | |
61 | else | |
62 | msg_not_running collectd | |
63 | RETVAL=$1 | |
64 | fi | |
65 | } | |
66 | ||
67 | RETVAL=0 | |
68 | case "$1" in | |
69 | start) | |
70 | start | |
71 | ;; | |
72 | stop) | |
73 | stop | |
74 | ;; | |
75 | restart) | |
76 | checkconfig | |
77 | stop | |
78 | start | |
79 | ;; | |
80 | try-restart) | |
81 | condrestart 0 | |
82 | ;; | |
83 | force-reload) | |
84 | condrestart 7 | |
85 | ;; | |
86 | status) | |
87 | checkconfig | |
88 | status collectd | |
89 | exit $? | |
90 | ;; | |
91 | *) | |
92 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" | |
93 | exit 3 | |
94 | esac | |
95 | ||
96 | exit $RETVAL |