#!/bin/sh # # Copyright (c) 2016 Nagios(R) Core(TM) Development Team # # chkconfig: - 80 30 # description: Starts and stops the Nagios Remote Plugin Executor \ # so a remote nagios server can run plugins on this host # ### BEGIN INIT INFO # Provides: nrpe # Required-Start: $local_fs $remote_fs $syslog $network $time # Required-Stop: $local_fs $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts and stops the Nagios Remote Plugin Executor # Description: Starts and stops the Nagios Remote Plugin Executor # so a remote nagios server can run plugins on this host ### END INIT INFO NRPE_BIN=@sbindir@/nrpe NRPE_CFG=@pkgsysconfdir@/nrpe.cfg LOCK_DIR=@subsyslockdir@ LOCK_FILE=@subsyslockfile@ PID_FILE=@piddir@/nrpe.pid test -x $NRPE_BIN || exit 5 RETVAL=0 # Default these commands/functions to RedHat/CentOS etc. values START_CMD="daemon --pidfile $PID_FILE" STAT_CMD="status nrpe" QSTAT_CMD="status nrpe >/dev/null 2>&1" TERM_CMD="killproc -p $PID_FILE $NRPE_BIN -TERM" HUP_CMD="killproc -p $PID_FILE $NRPE_BIN -HUP" PRT_STAT="echo" EXIT_CMD="exit" # Source the function library if [ -f /etc/rc.status ]; then . /etc/rc.status # Set these commands/functions to SuSE etc. values START_CMD="startproc -p $PID_FILE" STAT_CMD="checkproc" QSTAT_CMD="rc_status" TERM_CMD="killproc -p $PID_FILE -TERM $NRPE_BIN" HUP_CMD="killproc -p $PID_FILE -HUP $NRPE_BIN" PRT_STAT="rc_status -v -r" EXIT_CMD="rc_exit" rc_reset elif [ -f /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions elif [ -f /etc/init.d/functions ]; then . /etc/init.d/functions elif [ -f /lib/lsb/init-functions ]; then . /lib/lsb/init-functions START_CMD="start_daemon -p $PID_FILE" QSTAT_CMD="pidofproc -p $PID_FILE $NRPE_BIN" PRT_STAT="status_of_proc -p $PID_FILE $NRPE_BIN nrpe" elif [ -f /etc/rc.d/functions ]; then . /etc/rc.d/functions fi # See how we were called. case "$1" in start) # Start daemons. echo -n "Starting nrpe: " $START_CMD $NRPE_BIN -c $NRPE_CFG -d RETVAL=$? $PRT_STAT if [ $RETVAL = 0 ]; then [ -d $LOCK_DIR ] && touch $LOCK_FILE fi ;; stop) # Stop daemons. echo -n "Shutting down nrpe: " $TERM_CMD RETVAL=$? $PRT_STAT if [ $RETVAL = 0 ]; then [ -d $LOCK_DIR ] && rm -f $LOCK_FILE fi ;; restart|force-reload) $0 stop $0 start $QSTAT_CMD ;; reload) echo -n "Reloading nrpe: " $HUP_CMD RETVAL=$? $PRT_STAT ;; try-restart|condrestart) $QSTAT_CMD || exit 0 $0 stop $0 start $QSTAT_CMD ;; status) $STAT_CMD RETVAL=$? ;; *) echo "Usage: nrpe {start|stop|restart|reload|try-restart|condrestart|status}" exit 1 esac $EXIT_CMD $RETVAL