blob: 96551aea2bb0274e012ecc448cc997a50c7ed818 (
plain)
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
|
#!/bin/sh
# Start/stop/restart/reload nrpe
# Copyright (c) 2016 Nagios(R) Core(TM) Development Team
NRPE_BIN=@sbindir@/nrpe
NRPE_CFG=@pkgsysconfdir@/nrpe.cfg
PID_DIR=@piddir@
PID_FILE=@piddir@/nrpe.pid
# Start nrpe
nrpe_start() {
echo -n "Starting nrpe daemon: $NRPE_BIN - "
if [ ! -d "$PID_DIR" ]; then
mkdir -p "$PID_DIR"
fi
$NRPE_BIN -c $NRPE_CFG -d
if [ $? = 0 ]; then
echo "started"
else
echo "failed"
fi
}
# Stop nrpe
nrpe_stop() {
echo -n "Stopping nrpe daemon - "
if [ -r "$PID_FILE" ]; then
kill $(cat "$PID_FILE")
else
killall nrpe
fi
if [ $? = 0 ]; then
echo "stopped"
else
echo "failed"
fi
}
# Restart nrpe
nrpe_restart() {
nrpe_stop
sleep 1
nrpe_start
}
# Reload nrpe
nrpe_reload() {
echo -n "Reloading nrpe daemon - "
if [ -r "$PID_FILE" ]; then
kill -HUP $(cat "$PID_FILE")
else
killall -HUP nrpe
fi
if [ $? = 0 ]; then
echo "reloaded"
else
echo "failed"
fi
}
# nrpe status
nrpe_status() {
if ps -C nrpe >/dev/null; then
echo "nrpe is running."
else
echo "nrpe is stopped."
fi
}
case "$1" in
'start')
nrpe_start
;;
'stop')
nrpe_stop
;;
'restart')
nrpe_restart
;;
'reload')
nrpe_reload
;;
'status')
nrpe_status
;;
*)
echo "Usage $0 start|stop|restart|reload|status"
;;
esac
|