Compiling NRPE and nagios-plugins for Solaris 11.2

I have some Solaris 11.2 storage servers which run a number of ZFS pools, I wanted to monitor these through NRPE via Nagios. To do this I needed to compile NRPE and nagios-plugins from source, this article covers how this was done.

Install time

First we’ll start with nagios-plugins, we need to download it and compile it from source. As shown below I get a copy of this with the wget command, unzip it and untar it.

gunzip nagios-plugins-2.0.3.tar.gz
tar -xvf nagios-plugins-2.0.3.tar

This will extract the contents into a newly created nagios-plugins-2.0.3 directory, enter this directory and try to run the configure script.

# ./configure
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/gmkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to disable maintainer-specific portions of Makefiles... yes
checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/nagios-plugins-2.0.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

It’s not working because in this example we don’t have GCC installed on our server yet, install it with the command below.

pkg install gcc-3

Once this completes you may still receive the same error, or you may also receive the same error if you already had GCC installed. Run the below to add the GCC to $PATH.

export $PATH

In my instance my $PATH was already /usr/bin:/usr/sbin and I wanted to add /usr/sfw/bin/ as this is where GCC was located in my installation. You can confirm your path by running “echo $PATH”.

Now that you have GCC and the $PATH has been set correctly, run the below to configure, make, and install nagios-plugins.

make install

You should be able to test by running the below command, if nagios-plugins is working correctly it should return a result of your servers disk space.

/usr/local/nagios/libexec/check_disk -w 10 -c 5 -p /

To correctly make use of this, run the below commands to create a nagios user and group which will be used later.

useradd -d /usr/local/nagios -m nagios
groupadd nagios
chown nagios:nagios /usr/local/nagios/
chown -R nagios:nagios /usr/local/nagios/libexec/

Now that nagios-plugins is compiled and ready to use, we’ll do the same for NRPE, download and extract it as below.

gunzip nrpe-2.15.tar.gz
tar -xvf nrpe-2.15.tar

This will create an nrpe-2.15 directory, enter it and run the below configure command. The configure command specifies to make use of SSL, without this I found that Nagios would return handshake errors regarding SSL.

./configure --enable-ssl --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib
make install
cd ./src/; make ; cd ..
make install-daemon-config

Now that NRPE is installed we need to configure it, this mainly involved editing the /usr/local/nagios/etc/nrpe.cfg file and setting the allowed_hosts variable to include the IP address of your nagios server so that it is allowed to check NRPE.

Next edit /etc/services and add the below to the file.

nrpe            5666/tcp                        # NRPE

Now edit /etc/inet/inetd.conf and add the below to the file. Your location of tcpd may vary.

nrpe stream tcp nowait nagios /usr/sbin/tcpd /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -i

Next run these commands.

inetconv -e

Confirm the service is running with this command, it also shows the output in this instance nrpe has been running since it started on the 20th of March.

svcs svc:/network/nrpe/tcp:default
STATE          STIME    FMRI
online         Mar_20   svc:/network/nrpe/tcp:default

Confirm that NRPE is correctly listening on port 5666.

netstat -a | grep nrpe
      *.nrpe               *.*                0      0 128000      0 LISTEN

Run this to enable tcp_wrappers.

inetadm -m svc:/network/nrpe/tcp:default tcp_wrappers=TRUE

You can then confirm that it has set correctly with this command.

inetadm -l svc:/network/nrpe/tcp:default


That’s it, you should now be able to monitor this server from Nagios. If you have any problems things to check are the logs on the nagios server to see what the problem may be. Ensure that you have checked the NRPE service on the Solaris server is running and listening on TCP 5666, also check any firewalls between the Nagios server and Solaris server.

  1. Thanks for the doc.

    As I pass arguments ‘configure’ command was executed as follow:

    ./configure –enable-ssl –enable-command-args –with-ssl=/usr/bin/openssl –with-ssl-lib=/usr/lib

    …and works as expected.

  2. Amazing guide, thank you.

  3. Thanks for posting this guide. Very helpful! Much Appreciated.

  4. Very helpful post for Solaris 10 and 11 hosts.


  5. I don’t know if the “chown -R nagios:nagios /usr/local/nagios/libexec/” step you mention breaks pst3, or if it was initially installed with the wrong username anyway, so it would not work regardless. However, for at least Nagios plugins 2.3.1 in order for check_procs to check the number of process and zombie processes on a system /usr/local/nagios/libexec/pst3 must owned by root and not the nagios user. (Note, sudo can’t compensate for this.)

    To fix check_procs ability to run, run
    chown root /usr/local/nagios/libexec/pst3

    I don’t use these but based on setuid bits being set and the errors I see why trying to run them with the owner being set to nagios, that the same chown -R command sets the wrong uid for the suid’s on check_check_dhcp and check_icmp. They can easily be fixed with
    chown root /usr/local/nagios/libexec/check_icmp
    chown root /usr/local/nagios/libexec/check_dhcp
    I suspect you might also be able to correct this by removing the setuid bits and adding nagios to sudoers for those commands and sudoing them in the nrpe configues.

    It may be possible that if you change the order of installation or if at the onset you run “groupadd nagios” and “useradd -g nagios -d /usr/local/nagios -s /bin/bash -c “Nagios admin” -m nagios” to manually create a nagios user and group before you do any installs that you may be able to eliminate chowning the libexec folder completely. My companies generic build from source instructions have us manually add the account and group at the onset, so that they always have the same uid and gid number. The current Nagios support site Solaris installation instructions, have you install nrpe before Nagios-plugins with a “gmake install-groups-users command.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>