Installing NRPE For Icinga on Ubuntu 10.10 & CentOS 5.5

I currently have Icigna 1.2 (classic, web, and mobile) running on Ubuntu 10.10. I have a few other Linux servers that I would like to monitor as well. There is a good amount of information on installing Nagios and things to accompany it but Icigna documentation and blogs are fewer.

The goal of this post is to document how to install NRPE on a Icinga server (Ubuntu 10.10 x64) and monitor a remote host (CentOS 5.5 x64).

I also want to give credit to two other blog posts I used to get my systems functional and for this post.

fishfood: http://www.fishfood.co.nz/2010/03/howto-install-nagios-nrpe-for-use-with.html

The Geek Stuff: http://www.thegeekstuff.com/2008/06/how-to-monitor-remote-linux-host-using-nagios-30/

Remote Host

Install Dependencies:

yum install openssl-devel.x86_64 xinetd

Create user and assign password

useradd icinga && passwd icinga

Install Nagios plugins

cd /usr/src
wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
tar xzvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/icinga --with-nagios-user=icinga --with-openssl=/usr/bin/openssl
make && make install

Change permissions on the plugin directories

chown icinga.icinga /usr/local/icinga

chown -R icinga.icinga /usr/local/icinga/libexec

Now we move to installing NRPE. Change directories to /usr/src (or wherever you want to store your download) and download the archive.

cd /usr/src
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

Extract the files and enter directory

tar -zxvf nrpe-2.12.tar.gz && cd nrpe-2.12

Compile & install

./configure --with-nrpe-user=icinga --with-nrpe-group=icinga --with-nagios-user=icinga --with-nagios-group=icinga --enable-ssl --libexecdir=/usr/local/icinga/libexec/ --bindir=/usr/local/icinga/bin/

make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

On the 2nd to last line where it says "only_from = 127.0.0.1" add the IP of your Icinga server so that it would look like "only_from = 127.0.0.1 192.168.0.200" where 192.168.0.200 is your Icinga server.

nano /etc/xinetd.d/nrpe

Edit services file

nano /etc/services

Then press CTRL+W then CTRL+V to jump to the last line and add the following line above # Local services

nrpe 5666/tcp # NRPE

Enable Xinetd to boot at startup, start, and restart the service

chkconfig xinetd on

service xinetd start && service xinetd restart

Check to see if the port is open, the output should be "tcp 0 0 *:nrpe *.* LISTEN"

netstat -at |grep nrpe

Check if NRPE is functioning locally, the output should be "NRPE v2.12"

/usr/local/icinga/libexec/check_nrpe -H localhost

If you are running iptables on this remote host you will need to open port 5666 from your Icinga server.

iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 5666 -j ACCEPT

Save your iptables configuration

iptables-save

Edit NRPE Config File

nano /usr/local/nagios/etc/nrpe.cfg

Add the following lines under the existing command[] lines. This will allow you to monitor the sda1 partition and / partition in a LVM environment.

command[check_sda1]=/usr/local/icinga/libexec//check_disk -w 20% -c 10% -p /dev/sda1

command[check_part1]=/usr/local/icinga/libexec/check_disk -w 20 -c 10 -p /

Host Setup

This is for an Ubuntu/Debian based server. Start by installing the following dependcy.

sudo apt-get install libssl-dev

Download and extract NRPE

cd /usr/src
sudo wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz
sudo tar zxvf nrpe-2.12.tar.gz && cd nrpe-2.12

Compile & Install

sudo ./configure --with-nrpe-user=icinga --with-nrpe-group=icinga --with-nagios-user=icinga --with-nagios-group=icinga --enable-ssl --libexecdir=/usr/local/icinga/libexec/ --bindir=/usr/local/icinga/bin/

sudo make all && sudo make install

Check to see if you can contact the remote host you just setup.

sudo /usr/local/icinga/libexec/check_nrpe -H 192.168.0.100

Create A Host

I use individual files for my hosts, below is a template that I used to monitor a remote host. It is pretty basic at the moment and I would like to add more in the future but that will have to be another article.

###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation

define host{
use       corp-servers     ; Inherit default values from a template
host_name YourHostName    ; The name we're giving to this server
alias     YourHostName ; A longer name for the server
address   192.168.0.100   ; IP address of the server
}

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

define service{
use                 generic-service
host_name           YourHostName
service_description CPU Load
check_command       check_nrpe!check_load
}
define service{
use                 generic-service
host_name           YourHostName
service_description Current Users
check_command       check_nrpe!check_users
}
define service{
use                 generic-service
host_name           YourHostName
service_description / Free Space
check_command       check_nrpe!check_part1
}
define service{
use                 generic-service
host_name           YourHostName
service_description /boot Free Space
check_command       check_nrpe!check_sda1
}
define service{
use                 generic-service
host_name           YourHostName
service_description Total Processes
check_command       check_nrpe!check_total_procs
}
define service{
use                 generic-service
host_name           YourHostName
service_description Zombie Processes
check_command       check_nrpe!check_zombie_procs
}

Once you have this file on your server, restart run a sanity check on your configurations and restart the service and you should have a functional host in Icinga now.

sudo /usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg

sudo /etc/init.d/icinga restart

Src: http://www.deobfuscate.net/?p=680

Share