Starting NRPE via launchd | arfore dot com

Last week I posted on how to setup NRPE on Mac OS X Server.  Here is what you need to do to make it start up at system boot.

On a Linux or Solaris machine you can just include the call to the daemon in an init script like rc.local and it will be started when the OS boots.  Unfortunately, Apple has made this a little more difficult on Mac OS X with Tiger and Leopard.  The standard startup processes (cron, inetd, xinetd, etc.) have been rolled into a single process known as launchd.

The first step is to create a symbolic link to the NRPE config file from the default location to the root of the NRPE directory.

  1. cd /usr/local/nagios/
  2. ln -s etc/nrpe.cfg nrpe.cfg

The next setp is to ensure that the NRPE daemon will be able to connect with Nagios server.  There are two ways to do this.  One way is to add a line to the

file to allow for an open port for NRPE.  The second way is to open the port as part of the launchd process.

Method One – edit the /etc/services file

  1. cd /etc/
  2. sudo vi /etc/services
  3. add the following line to the end of the file:
    5666/tcp # Nagios NRPE client

Method Two – use the launchd process

This method involves including a dictionary key into the launchd plist file that sets the socket type and port number for the NRPE service to use for listening.  The plist code is shown below:

Sockets Listeners SockServiceName 5666 SockType stream SockFamily IPv4