1. Intruduction
Nagios is installed on our servers in order to actively monitor by specific scripts all of our services.
Nagios is an enterprise solution for monitoring an array of servers with complex network architecture. In this blog we will see how to configure a linux machine (in this case openSuse) to hold the listener service which will help the Nagios server to retrieve information from the linux machine.

2. Design
(taken from NRPE.pdf)
 

Nagios NRPE design


As you can see our Monitoring how will connect through the check_nrpe script on it to the remote linux host. The remote machine will run an NRPE service that will listen and wait for the Monitoring host requests. The remote machine runs xinetd in order for the listener to work.
This is a direct check as where the resource is local. There is also an indirect way, where the remote host will check another physically different server however we won't discuss it here.

3. Install NRPE daemon and Nagios Plugins
Connect as root to the remote machine where you'd like to install the NRPE service.


 

Create nagios user 

# useradd nagios
# passwd nagios
 

 

Create nagios group
# groupadd nagios
 

Make sure you have a suitable compiler like gcc installed
# zypper install gcc make
 

 

Download nagios-plugins from www.nagios.org/download (currently 1.4.15)

# cd /var/tmp
# mkdir nagios
# cd nagios
 

# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
asking libproxy about url 'http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz'
libproxy suggest to use 'direct://'
--2011-12-22 22:20:09--  http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
Resolving prdownloads.sourceforge.net (prdownloads.sourceforge.net)... 216.34.181.59
Connecting to prdownloads.sourceforge.net (prdownloads.sourceforge.net)|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz [following]
asking libproxy about url 'http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz'
libproxy suggest to use 'direct://'
--2011-12-22 22:20:10--  http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Reusing existing connection to prdownloads.sourceforge.net:80.
HTTP request sent, awaiting response... 302 Found
Location: http://garr.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz [following]
asking libproxy about url 'http://garr.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz'
libproxy suggest to use 'direct://'
--2011-12-22 22:20:10--  http://garr.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
Resolving garr.dl.sourceforge.net (garr.dl.sourceforge.net)... 193.206.140.34, 2001:760:ffff:b0::34
Connecting to garr.dl.sourceforge.net (garr.dl.sourceforge.net)|193.206.140.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2095419 (2.0M) [application/x-gzip]
Saving to: `nagios-plugins-1.4.15.tar.gz'

100%[===================================================================================================================>] 2,095,419    695K/s   in 2.9s   

2011-12-22 22:20:13 (695 KB/s) - `nagios-plugins-1.4.15.tar.gz' saved [2095419/2095419]

Untar/gzip it:
# tar zxvf nagios-plugins-1.4.15.tar.gz

Compile the code
# ./configure
# make
# make install

 

Update permissions
# chown nagios:nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec

 

Make sure you have xinetd installed:
# zypper install xinetd

 

 

4. Install NRPE daemon

Download the daemon
# cd /var/tmp/nagios
# wget 
http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz 

 

Unpack it
# tar zxvf nrpe-2.13.tar.gz
# cd nrpe-2.13.tar.gz
# ./configure --disable-ssl
# make all

cd ./src/; make ; cd ..
make[1]: Entering directory `/var/tmp/nagios/nrpe-2.13/src'
gcc -g -O2 -DHAVE_CONFIG_H -o nrpe nrpe.c utils.c acl.c  -lnsl   
gcc -g -O2 -DHAVE_CONFIG_H -o check_nrpe check_nrpe.c utils.c  -lnsl 
make[1]: Leaving directory `/var/tmp/nagios/nrpe-2.13/src'

*** Compile finished ***

If the NRPE daemon and client compiled without any errors, you
can continue with the installation or upgrade process.

Read the PDF documentation (NRPE.pdf) for information on the next
steps you should take to complete the installation or upgrade.

 

Install the plugin

# make install-plugin
cd ./src/ && make install-plugin
make[1]: Entering directory `/var/tmp/nagios/nrpe-2.13/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make[1]: Leaving directory `/var/tmp/nagios/nrpe-2.13/src'

 

Install the daemon

# make install-daemon
cd ./src/ && make install-daemon
make[1]: Entering directory `/var/tmp/nagios/nrpe-2.13/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install -c -m 775 -o nagios -g nagios nrpe /usr/local/nagios/bin
make[1]: Leaving directory `/var/tmp/nagios/nrpe-2.13/src'

 

Install the configuration for the daemon

# make install-daemon-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc
linux-5gec:/var/tmp/nagios/nrpe-2.13 # make install-xinetd
/usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe 


Edit the nrpe service to allow outside addresses
# vi /etc/xinetd.d/nrpe 
From:

       only_from       = 127.0.0.1

To:
       only_from       = 192.168.1.106

 

Add NRPE as a service to the linux machine# vi /etc/services

Add the following

### EDIT NAGIOS START
nrpe            5666/tcp   # NRPE
### EDIT NAGIOS END

 

# service xinetd restart

 

Check NRPE service is running:

# netstat -ta | grep nrpe

tcp        0      0 *:nrpe                  *:*                     LISTEN      

 

Open Nagios configuration at the firewall

# SuSEfirewall2 open EXT TCP nrpe

 

5. Verification

Now NRPE should be up and running. Verify from the Nagios Host that the remote machine is answering:

# ./check_nrpe2 -H 192.168.1.115 -n -c check_load
OK - load average: 0.00, 0.02, 0.07|load1=0.000;15.000;30.000;0; load5=0.020;10.000;25.000;0; load15=0.070;5.000;20.000;0; 

 

 

Enjoy!

 

 

 

Viewed 43945 times.
Share |
How to migrate from o... (Daniel, 16:52 06/04/2013)
How to redirect SNMP ... (Daniel, 18:32 24/08/2012)
How to add httpd.conf... (Daniel, 19:20 24/03/2012)
How to avoid entering... (Daniel, 03:11 27/12/2011)
How to configure SOFT... (Daniel, 23:24 26/12/2011)
Subversion - Tortoise... (21:02 17/01/2010, 119185 views)
How to install Nagios... (01:08 23/12/2011, 43945 views)
Byte Order Mark (BOM)... (17:36 22/02/2010, 28080 views)
How to avoid entering... (03:11 27/12/2011, 23403 views)
Raid Types (17:54 09/02/2010, 20784 views)