This repository has been archived by the owner on May 23, 2024. It is now read-only.
forked from ripienaar/mnrpes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmnrpes-receiver.init
executable file
·136 lines (121 loc) · 2.84 KB
/
mnrpes-receiver.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
#
# mnrpes-receiver MCollective based receiver to scale NRPE checks
#
# chkconfig: - 24 76
#
# description:Use the MCollective framework to scale NRPE checks in an async manner
#
### BEGIN INIT INFO
# Provides: mnrpes
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
command="mnrpes-receiver"
binfile="/usr/bin/${command}"
pidfile="/var/run/mnrpes/${command}.pid"
configfile="/etc/mnrpes/${command}.cfg"
user="nagios"
if [ -d /var/lock/subsys ]; then
# RedHat/CentOS/etc who use subsys
lockfile="/var/lock/subsys/${command}"
else
# The rest of them
lockfile="/var/lock/${command}"
fi
# Check that binary exists
if ! [ -f $binfile ]; then
echo "${binfile} binary not found"
exit 5
fi
# Source function library.
. /etc/init.d/functions
if [ -f /etc/sysconfig/${command} ]; then
. /etc/sysconfig/${command}
fi
# Determine if we can use the -p option to daemon, killproc, and status.
# RHEL < 5 can't.
if status | grep -q -- '-p' 2>/dev/null; then
daemonopts="--pidfile $pidfile"
pidopts="-p $pidfile"
fi
start() {
echo -n "Starting ${command}: "
# Only try to start if not already started
if ! rh_status_q; then
daemon --user "${user}" ${daemonopts} ${binfile} --pid=${pidfile} --config=${configfile}
fi
# This will be 0 if mcollective is already running
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n "Shutting down ${command}: "
# If running, try to stop it
if rh_status_q; then
killproc ${pidopts} -d 10 ${binfile}
else
# Non-zero status either means lockfile and pidfile need cleanup (1 and 2)
# or the process is already stopped (3), so we can just call true to
# trigger the cleanup that happens below.
true
fi
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
return $RETVAL
}
restart() {
stop
start
}
reload_agents() {
echo -n "Reloading ${command} agents: "
killproc ${pidopts} ${binfile} -USR1
RETVAL=$?
echo
return $RETVAL
}
reload_loglevel() {
echo -n "Cycling ${command} logging level: "
killproc ${pidopts} ${binfile} -USR2
RETVAL=$?
echo
return $RETVAL
}
rh_status() {
status ${pidopts} ${binfile}
RETVAL=$?
return $RETVAL
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
rh_status_q || exit 0
restart
;;
status)
rh_status
;;
*)
echo "Usage: ${command} {start|stop|restart|condrestart|status}"
RETVAL=2
;;
esac
exit $RETVAL