-
Notifications
You must be signed in to change notification settings - Fork 0
/
monit.init
86 lines (76 loc) · 1.31 KB
/
monit.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
# Init file for Monit system monitor
# Written by Stewart Adam <[email protected]>
# based on script by Dag Wieers <[email protected]>.
#
# chkconfig: 345 98 02
# description: Utility for monitoring services on a Unix system
#
# processname: monit
# config: /etc/monit.conf
# pidfile: /var/run/monit.pid
# Short-Description: Monit is a system monitor
# Source function library.
. /etc/init.d/functions
### Default variables
CONFIG="/etc/monitrc"
pidfile="/var/run/monit.pid"
prog="monit"
# Check if requirements are met
[ -x /usr/bin/monit ] || exit 1
[ -r "$CONFIG" ] || exit 1
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $"Shutting down $prog: "
killproc -p ${pidfile}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $prog: "
monit -c "$CONFIG" reload
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
RETVAL=1
esac
exit $RETVAL