#!/sbin/sh # # @(#) $Revision: 1.0 $ # # NOTE: This script is designed to automatically start the NRPE # client on an HP-UX workstation. # # # NOTE: The purpose of the NRPE application is to allow the Nagios # server to query the remote client. # # Start Nagios client daemon 'nrpe' # # Allowed exit values: # 0 = success; causes "OK" to show up in checklist. # 1 = failure; causes "FAIL" to show up in checklist. # 2 = skip; causes "N/A" to show up in the checklist. # Use this value if execution of this script is overridden # by the use of a control variable, or if this script is not # appropriate to execute for some other reason. # 3 = reboot; causes the system to be rebooted after execution. # Input and output: # stdin is redirected from /dev/null # # stdout and stderr are redirected to the /etc/rc.log file # during checklist mode, or to the console in raw mode. PATH=/usr/sbin:/usr/bin:/sbin export PATH # NOTE: If your script executes in run state 0 or state 1, then /usr might # not be available. Do not attempt to access commands or files in # /usr unless your script executes in run state 2 or greater. Other # file systems typically not mounted until run state 2 include /var # and /opt. rval=0 # Check the exit value of a command run by this script. If non-zero, the # exit code is echoed to the log file and the return value of this script # is set to indicate failure. set_return() { x=$? if [ $x -ne 0 ]; then echo "EXIT CODE: $x" rval=1 # script FAILed fi } # Kill the named process(es). # $1= killproc() { # Get the pid of the identified process pid=`/usr/bin/ps -e | /usr/bin/grep $1 | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'` if [ "$pid" != "" ]; then if kill "$pid"; then echo "$1 stopped" else rval=1 echo "Unable to stop $1" fi fi } case $1 in 'start_msg') # Emit a _short_ message relating to running this script with # the "start" argument; this message appears as part of the checklist. echo "Starting NRPE Client" ;; 'stop_msg') # Emit a _short_ message relating to running this script with # the "stop" argument; this message appears as part of the checklist. echo "Stopping NRPE Client" ;; 'start') if [ -x /opt/nrpe/bin/nrpe ] then echo "Starting NRPE..." /opt/nrpe/bin/nrpe set_return fi ;; 'stop') # Execute the commands to stop your subsystem echo "Killing NRPE..." killproc nrpe ;; *) esac exit $rval