]> git.pld-linux.org Git - packages/monit.git/blob - monit.init
- 5.2.4
[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 checkconfig() {
16         local out
17         out=$(/usr/sbin/monit -c /etc/monitrc -t 2>&1)
18         ret=$?
19         if [ $ret != 0 ]; then
20                 echo >&2 "$out"
21                 exit 1
22         fi
23 }
24
25 start() {
26         # Check if the service is already running?
27         if [ ! -f /var/lock/subsys/monit ]; then
28                 checkconfig
29                 msg_starting monit
30                 daemon --pidfile /var/run/monit.pid /usr/sbin/monit -c /etc/monitrc -s /var/run/monit.state $OPTIONS
31                 RETVAL=$?
32                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/monit
33         else
34                 msg_already_running monit
35         fi
36 }
37
38 stop() {
39         # Stop daemons.
40         if [ -f /var/lock/subsys/monit ]; then
41                 msg_stopping monit
42                 busy
43                 /usr/sbin/monit -c /etc/monitrc quit
44                 RETVAL=$?
45                 [ $RETVAL -eq 0 ] && ok || fail
46                 rm -f /var/lock/subsys/monit > /dev/null 2>&1
47         else
48                 msg_not_running monit
49         fi
50 }
51
52 RETVAL=0
53 # See how we were called.
54 case "$1" in
55   start)
56         start
57         ;;
58   stop)
59         stop
60         ;;
61   restart)
62         checkconfig
63         stop
64         start
65         ;;
66   reload|force-reload)
67         if [ -f /var/lock/subsys/monit ]; then
68                 checkconfig
69                 msg_reloading monit
70                 busy
71                 /usr/sbin/monit -c /etc/monitrc reload
72                 RETVAL=$?
73                 [ $RETVAL -eq 0 ] && ok || fail
74         else
75                 msg_not_running monit
76                 exit 7
77         fi
78         ;;
79   checkconfig)
80         checkconfig
81         echo "Config check OK"
82         ;;
83   status)
84         status monit
85         monit -c /etc/monitrc status
86         exit $?
87         ;;
88   *)
89         msg_usage "$0 {start|stop|restart|reload|force-reload|checkconfig|status}"
90         exit 3
91 esac
92
93 exit $RETVAL
This page took 0.034935 seconds and 3 git commands to generate.