summaryrefslogtreecommitdiffstats
path: root/startup/bsd-init.in
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:20:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:20:09 +0000
commit018433a6da60c6395baaaa0833d5c50ac6645552 (patch)
tree2012deeff2f98b267c0c10425c1d4a054190b73f /startup/bsd-init.in
parentInitial commit. (diff)
downloadnagios-nrpe-018433a6da60c6395baaaa0833d5c50ac6645552.tar.xz
nagios-nrpe-018433a6da60c6395baaaa0833d5c50ac6645552.zip
Adding upstream version 3.2.1.upstream/3.2.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'startup/bsd-init.in')
-rw-r--r--startup/bsd-init.in90
1 files changed, 90 insertions, 0 deletions
diff --git a/startup/bsd-init.in b/startup/bsd-init.in
new file mode 100644
index 0000000..96551ae
--- /dev/null
+++ b/startup/bsd-init.in
@@ -0,0 +1,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