One thing I wanted to use when I installed Nagios NRPE, was the Solaris Service Management Facility (SMF). Doing this makes NRPE easy to start, stop, restart and keep running. Luckily it’s easy to set this up on the Solaris host. Find more information about Nagios NRPE here.

NRPE will allow execution of Nagios plugins on remote Solaris hosts, and is a useful addon to Nagios. It allows you to check the metrics of remote machines. You can have full control of disk usage, CPU load and memory usage, to mention a few. NRPE can also communicate with some of the Windows agents for Nagios. That way, you can execute scripts and check metrics on Windows machines as well.

Write a manifest for the Nagios NRPE SMF

The first thing you need to do is to write a manifest. An SMF manifest is a file that contains the complete set of properties associated with a service. The name of this file also determines what Fault Management Resource Identifier (FMRI) the service will get within SMF, and it’s encoded in XML. I chose to call my manifest nagios-nrpe.xml, and placed it in the network section of SMF.

My SMF manifest now looks like this:

# cat /var/svc/manifest/network/nagios-nrpe.xml

<?xml version="1.0"?>
   <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

   <service_bundle type='manifest' name='nagios-nrpe'>
   <service name='network/nagios/nrpe' version='1' type='service'>

      <create_default_instance enabled='false' />

      <single_instance />

      <dependency name='multi-user' grouping='require_all' restart_on='none' type='service'>
         <service_fmri value='svc:/milestone/multi-user' />
      </dependency>

      <method_context>
         <method_credential user='nagios' group='nagios'/>
         <method_environment>
            <envvar name='BASEDIR' value='/export/home/nagios'/>
            </method_environment>
      </method_context>

      <exec_method type='method' name='start' exec='$BASEDIR/bin/nrpe -c $BASEDIR/etc/nrpe.cfg -d' timeout_seconds='60'/>
      <exec_method type='method' name='stop' exec=':kill' timeout_seconds='60'/>

      <property_group name='general' type='framework'>
         <propval name='enabled' type='boolean' value='false'/>
         <propval name='action_authorization' type='astring' value='solaris.smf.manage.nagios-nrpe'/>
         <propval name='value_authorization' type='astring' value='solaris.smf.manage.nagios-nrpe'/>
      </property_group>

      <property_group name='startd' type='framework'>
         <propval name='ignore_error' type='astring' value='core,signal' />
      </property_group>
      <stability value='Unstable' />
   </service>
</service_bundle>

Important changes for your system

For this to work for your system, you most likely need to change the BASEDIR to where you have installed NRPE. If you run with non-standard username and group name, you also have to change this in the file. After you have created the file with the correct properties, import it into SMF with this command:

# svccfg import /var/svc/manifest/network/nagios-nrpe.xml

The resulting FMRI looks like this:

# svcs -a | grep nrpe
disabled         1:36:33  svc:/network/nagios/nrpe:default

Start the service

To finish the job, start the service and check that it’s running:

# svcadm enable nrpe
# svcs -a | grep nrpe
online          1:36:39 svc:/network/nagios/nrpe:default

If NRPE was correctly installed, it should change state to online after enabling the service. You should also be able to use the different SMF commands to  control the state of the service.

Espen Acklam Solberg

Espen Acklam Solberg is a system administrator with over 20 years of experience. He has worked in the telecom industry, in the aviation industry and for the government, managing critical infrastructure. His expertise lies in linux systems, virtualization, storage, backup, scripting and automation.He also runs his own print shop, producing branded merchandise for businesses and individuals, and is fond of gadgets and new technology.

Leave a Reply