Book Image

Learning Nagios 3.0

Book Image

Learning Nagios 3.0

Overview of this book

Table of Contents (16 chapters)
Learning Nagios 3.0
Credits
About the Author
About the Reviewer
Preface

Installing NRPE as a System Service


The easiest way to get NRPE up and running is to add it to startup in a standalone mode. In this case, it will handle listening on the specified TCP port and changing the user and group by itself.

To do this, simply run the NRPE binary with the following parameters:

/opt/nagios/bin/nrpe -c /etc/nagios/nrpe.cfg -d

You can also add NPRE to init.d file so that NPRE will start automatically at system start. Usually, this file is located in /etc/init.d/nrpe or /etc/rc.d/init.d/nrpe.

A simple script that starts up and shuts down NRPE is as follows:

#! /bin/sh
case "$1" in
start)
echo -n "Starting NRPE daemon..."
/opt/nagios/bin/nrpe -c /etc/nagios/nrpe.cfg -d
echo " done."
;;
stop)
echo -n "Stopping NRPE daemon..."
pkill -u nagios nrpe
echo " done."
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: $0 start|stop|restart"
;;
esac
exit 0

The next step is to set up a system to stop and start this service when changing to appropriate runlevels. Depending on your...