b7c085cd0efe562caf0a3212211d8b3584934d76
[collectd.git] / contrib / redhat / init.d-collectd
1 #!/bin/bash
2 #
3 # collectd    Startup script for the Collectd statistics gathering daemon
4 # chkconfig: - 86 15
5 # description: Collectd is a statistics gathering daemon used to collect \
6 #   system information ie. cpu, memory, disk, network
7 # processname: collectd
8 # config: /etc/collectd.conf
9 # config: /etc/sysconfig/collectd
10 # pidfile: /var/run/collectd.pid
11
12 # Source function library.
13 . /etc/init.d/functions
14
15 RETVAL=0
16 ARGS=""
17 prog="collectdmon"
18 CONFIG=/etc/collectd.conf
19 COLLECTD=/usr/sbin/collectd
20 COLLECTDMONPID=/var/run/collectdmon.pid
21
22 if [ -r /etc/default/$prog ]; then
23         . /etc/default/$prog
24 fi
25
26 start () {
27         echo -n $"Starting collectd: "
28         if [ -r "$CONFIG" ]
29         then
30                 daemon $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG"
31                 RETVAL=$?
32                 echo
33                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
34         fi
35 }
36 stop () {
37         echo -n $"Stopping collectd: "
38         killproc $prog
39         RETVAL=$?
40         echo
41         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
42 }
43 # See how we were called.
44 case "$1" in
45   start)
46         start
47         ;;
48   stop)
49         stop
50         ;;
51   status)
52         status $prog
53         ;;
54   restart|reload)
55         stop
56         start
57         ;;
58   condrestart)
59         [ -f /var/lock/subsys/$prog ] && restart || :
60         ;;
61   *)
62         echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
63         exit 1
64 esac
65
66 exit $?
67
68 # vim:syntax=sh