Installing NRPE and Nagios-Plugins on Centos 6 (64bit) with IPTables

Scenario: We have several remote BSD (NRPE) and Windows servers (NSClient++) that we already actively monitor. We wanted to add a Centos 6 machine to our monitoring list. On the Centos server we also have IPTables installed.

Nagios-Plugins and NRPE arent available via the official Centos repositories so we will need to use a third-party.

1) If you haven’t already then install RPMForge repository. Information from the official Centos website wiki can be found here: RPMforge

# rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Note: Remember I’m using Centos 64bit so the above link wont be valid if you’re running 32bit

Note: Also consider using repository priorities to protect yourself from the danger of upgrading unwanted/untested/unsupported packages. See this link: yum-plugin-priorities 

2) Install Nagios-plugins and NRPE

# yum install nagios-plugins nagios-nrpe

3) Configure NRPE

# vi /etc/xinetd.d/nrpe

# default: off
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
type = UNLISTED
port = 5666
socket_type = stream
wait = no
user = nagios
group = nagios
server = /usr/sbin/nrpe
server_args = -c /etc/nagios/nrpe.cfg –inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1 192.168.0.1
}

From the above example you’ll see we have enabled the service and also allowed  access to 192.168.0.1 (our Nagios server). Note that the service also runs on port 5666 (We’ll need this for step 5).

4) Install & configure xinetd (if not installed already)

# yum install xinetd

# chkconfig xinetd on

 

To check it is all working try a command :

# /usr/lib64/nagios/plugins/check_procs

OUTPUT : PROCS OK: 99 processes

 

5) Allow Nagios server to connect through IPtables firewall

# iptables -A INPUT -p tcp -s 192.168.0.1 –dport 5666 -j ACCEPT

# /sbin/service iptables save

 

There you have it. That should do the job.  Check NRPE is working from the Nagios server:

# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.2

OUTPUT :  NRPE v2.14

 

All good. Now sit back and allow Nagios to monitor your CPU, disk space and anything else you want.