4 |
# |
# |
5 |
# Author: Clinton Work, <work@scripty.com> |
# Author: Clinton Work, <work@scripty.com> |
6 |
# |
# |
7 |
# chkconfig: 345 98 02 |
# chkconfig: 2345 98 02 |
8 |
# description: Monit is a utility for managing and monitoring processes, |
# description: Monit is a utility for managing and monitoring processes, |
9 |
# files, directories and devices on a Unix system. |
# files, directories and devices on a Unix system. |
10 |
# processname: monit |
# processname: monit |
12 |
# config: /etc/monitrc |
# config: /etc/monitrc |
13 |
|
|
14 |
# Source function library. |
# Source function library. |
15 |
. /etc/init.d/functions |
. /etc/rc.d/init.d/functions |
16 |
|
|
17 |
|
# Source networking configuration. |
18 |
|
. /etc/sysconfig/network |
19 |
|
|
20 |
MONIT=/usr/bin/monit |
MONIT=/usr/bin/monit |
21 |
MONITRC=/etc/monitrc |
|
22 |
|
# Source monit configuration. |
23 |
|
if [ -f /etc/sysconfig/monit ] ; then |
24 |
|
. /etc/sysconfig/monit |
25 |
|
fi |
26 |
|
|
27 |
[ -f $MONIT ] || exit 0 |
[ -f $MONIT ] || exit 0 |
28 |
|
|
31 |
# See how we were called. |
# See how we were called. |
32 |
case "$1" in |
case "$1" in |
33 |
start) |
start) |
34 |
echo -n "Starting monit: " |
echo -n "Starting monit: " |
35 |
daemon --force $MONIT -c $MONITRC |
daemon $NICELEVEL $MONIT |
36 |
RETVAL=$? |
RETVAL=$? |
37 |
echo |
echo |
38 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/monit |
[ $RETVAL = 0 ] && touch /var/lock/subsys/monit |
39 |
;; |
;; |
40 |
stop) |
stop) |
41 |
echo -n "Stopping monit: " |
echo -n "Stopping monit: " |
42 |
daemon --force $MONIT -c $MONITRC quit |
killproc monit |
43 |
RETVAL=$? |
RETVAL=$? |
44 |
echo |
echo |
45 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/monit |
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/monit |
46 |
;; |
;; |
47 |
restart) |
restart) |
48 |
$0 stop |
$0 stop |
49 |
$0 start |
$0 start |
50 |
RETVAL=$? |
RETVAL=$? |
51 |
;; |
;; |
52 |
reload) |
condrestart) |
53 |
echo -n "Reloading monit: " |
[ -e /var/lock/subsys/monit ] && $0 restart |
54 |
daemon --force $MONIT -c $MONITRC reload |
;; |
|
RETVAL=$? |
|
|
echo |
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/monit |
|
|
;; |
|
55 |
status) |
status) |
56 |
$MONIT -c $MONITRC status |
status monit |
57 |
RETVAL=$? |
RETVAL=$? |
58 |
;; |
;; |
59 |
*) |
*) |
60 |
echo "Usage: $0 {start|stop|restart|reload|status}" |
echo "Usage: $0 {start|stop|restart|condrestart|status}" |
61 |
exit 1 |
exit 1 |
62 |
esac |
esac |
63 |
|
|