Computerglitch

An ongoing adventure

Nagios NRPE on Solaris 8

First off I installed the nagios plugins on the Solaris server so all of the commands I would need to monitor the server with remotely would be available. The package I found worked was nagios-plugins-1.3.1_3-sol8-sparc-local.

Make sure you add the user and group “nagios” to the system before beginning.

With the package in hand I simply issued the following command on the Solaris server:

# pkgadd -d nagios-plugins-1.3.1_3-sol8-sparc-local 

The following packages are available: 1 UVTngsplg nagios-plugins

The package installed all of the plugins to: /usr/local/lib/nagios/plugins

Once the nagios plugins were installed I began the NRPE installation. NRPE allows a remote server to receive commands from a Nagios server for monitoring. This allows you to monitor things like disk, cpu and memory usage remotely and setup alerts as needed. NRPE can be downloaded from the Nagios addon page.

Once the package is downloaded unzip the tarball:

# gzip -dc nrpe-2.12.tar.gz | tar xvf -

Next enter the directory and configure the source. When you configure the code you may get the following the error shown below:

# ./configure
....
checking for SSL headers... SSL headers found in /usr/local/ssl
checking for SSL libraries... configure: error: Cannot find ssl libraries

To fix this you will need to tell figure where to find the ssl libraries. In my case the libraries were located in: /usr/local/ssl/lib The full command can be seen below:

# ./configure --with-ssl=/usr/local/ssl/lib
...
checking for SSL headers... SSL headers found in /usr/local/ssl
checking for SSL libraries... SSL libraries found in /usr/local/ssl/lib

*** Generating DH Parameters for SSL/TLS ***
Generating DH parameters, 512 bit long safe prime, generator 2
This is going to take a long time

Once the configure is complete it’s time to “make”. When I issued “make” I was getting the following error seen below.

# make
nrpe.c: In function `get_log_facility':
nrpe.c:617: error: `LOG_AUTHPRIV' undeclared (first use in this function)
nrpe.c:617: error: (Each undeclared identifier is reported only once
nrpe.c:617: error: for each function it appears in.)
nrpe.c:619: error: `LOG_FTP' undeclared (first use in this function)
*** Error code 1
make: Fatal error: Command failed for target `nrpe'
Current working directory /tmp/nrpe-2.12/src
*** Error code 1
make: Fatal error: Command failed for target `all'

To fix this issue you need to edit the file in src/nrpe.c on lines 616-619 and replace them with the following:

else if(!strcmp(varvalue,"authpriv"))
                log_facility=LOG_AUTH;
        else if(!strcmp(varvalue,"ftp"))
                log_facility=LOG_DAEMON;

Once you make this change you should be able to successfully “make”

# make
cd ./src/; make ; cd ..
gcc -g -O2 -I/usr/local/ssl/include/openssl -I/usr/local/ssl/include -DHAVE_CONFIG_H -o nrpe nrpe.c utils.c -L/usr/local/ssl/lib  -lssl -lcrypto -lnsl -lsocket  ./snprintf.o -liberty
gcc -g -O2 -I/usr/local/ssl/include/openssl -I/usr/local/ssl/include -DHAVE_CONFIG_H -o check_nrpe check_nrpe.c utils.c -L/usr/local/ssl/lib  -lssl -lcrypto -lnsl -lsocket -liberty

*** Compile finished ***

Next, install the included nrpe.cfg sample config file to /usr/local/nagios/etc

# make install-daemon-config
./install-sh -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
./install-sh -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc

I edited the nrpe.cfg file to allow my Nagios server’s IP access. Replace 192.168.0.14 with the IP of your Nagios server. The line edited can be seen below:

# vi /usr/local/nagios/etc/nrpe.cfg

# ALLOWED HOST ADDRESSES
# This is an optional comma-delimited list of IP address or hostnames
# that are allowed to talk to the NRPE daemon.
#
# Note: The daemon only does rudimentary checking of the client's IP
# address.  I would highly recommend adding entries in your /etc/hosts.allow
# file to allow only the specified host to connect to the port
# you are running this daemon on.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd

allowed_hosts=192.168.0.14

Next I copied the src/nrpe binary to the same directory as the ssl libraries /usr/local/ssl/lib. I did this so nrpe would have no problem finding the libraries it needed to start. I’m sure there are many other ways of doing this but this was the easiest for me.

# cp /tmp/nrpe-2.12/src/nrpe /usr/local/ssl/lib

Once the binary was copied I simply fired it from the /usr/local/ssl/lib directory and specified where my config file was:

# cd /usr/local/ssl/lib
# ./nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

Now I have NRPE listening on my Solaris 8 server happily accepting commands from Nagios server for status monitoring. Some of the commands I’m issuing to monitor the status can be seen in the excerpt of my nrpe.cfg file below:

command[check_disk]=/usr/local/lib/nagios/plugins/check_disk -w 30% -c 20% -p /
command[check_disk_usr]=/usr/local/lib/nagios/plugins/check_disk -w 7% -c 6% -p /usr
command[check_disk_var]=/usr/local/lib/nagios/plugins/check_disk -w 20% -c 15% -p /var
command[check_disk_users]=/usr/local/lib/nagios/plugins/check_disk -w 9% -c 6% -p /users
command[check_disk_docs]=/usr/local/lib/nagios/plugins/check_disk -w 10% -c 5% -p /docs
command[check_disk_opt]=/usr/local/lib/nagios/plugins/check_disk -w 20% -c 10% -p /opt
command[check_disk_opt1]=/usr/local/lib/nagios/plugins/check_disk -w 20% -c 10% -p /opt1
command[check_memory]=/usr/local/lib/nagios/plugins/check_memory
command[check_cpu]=/usr/local/lib/nagios/plugins/check_cpu 35 25

Comments