]> git.pld-linux.org Git - packages/monit.git/blob - monit.init
- use functions
[packages/monit.git] / monit.init
1 #!/bin/sh
2 #
3 # monit         Monitoring daemon
4 #
5 # chkconfig:    345 99 01
6 # description:  Monitoring daemon
7 #
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 # Get service config
13 [ -f /etc/sysconfig/monit ] && . /etc/sysconfig/monit
14
15 start() {
16         # Check if the service is already running?
17         if [ ! -f /var/lock/subsys/monit ]; then
18                 msg_starting monit
19                 daemon monit -c /etc/monitrc -l syslog -d 60
20                 RETVAL=$?
21                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/monit
22         else
23                 msg_already_running monit
24         fi
25 }
26
27 stop() {
28         # Stop daemons.
29         if [ -f /var/lock/subsys/monit ]; then
30                 msg_stopping monit
31                 daemon monit -c /etc/monitrc quit
32                 rm -f /var/lock/subsys/monit > /dev/null 2>&1
33         else
34                 msg_not_running monit
35         fi
36 }
37
38 RETVAL=0
39 # See how we were called.
40 case "$1" in
41   start)
42         start
43         ;;
44   stop)
45         stop
46         ;;
47   restart)
48         stop
49         start
50         ;;
51   reload|force-reload)
52         if [ -f /var/lock/subsys/monit ]; then
53                 msg_reloading monit
54                 daemon monit -c /etc/monitrc reload
55                 RETVAL=$?
56         else
57                 msg_not_running monit
58                 exit 7
59         fi
60         ;;
61   status)
62         status monit
63         monit -c /etc/monitrc status
64         exit $?
65         ;;
66   *)
67         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
68         exit 3
69 esac
70
71 exit $RETVAL
This page took 0.051287 seconds and 3 git commands to generate.