How to Configure Nagios NRPE Client for System Monitoring (CentOS/RHEL)

Question: How to configure CentOS/RHEL system as Nagios NRPE Client so it can be monitored from Nagios-Server for system health/performance?

Enable EPEL REPO (Fedora Repository) and Install Required Packages

1. Download the epel repository packages for CentOS/RHEL 5 and 6.

FOR CentOS/RHEL 6:

# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

For CentOS/RHEL 5:

# wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

2. Install Epel repostiory

# yum install /path/to/downloaded/rpm/with/wget/epel-release-X-X.noarch.rpm

where X-X is your version eg. CentOS 6 or CentOS 5 rpm file.

3. Enable epel repo and install nrpe and nagios-plugins from it.

# yum --enablerepo=epel install nrpe nagios-plugins

4. After the installation, disable EPEL repo ( just in case ):

# yum-config-manager --disable epel

5. Install below packages which are required later on by NRPE or any 3rd party Nagios Plugin:

# yum install xinetd gcc openssl-devel make lm_sensors net-snmp-utils postresql-libs

Install and configure Xinetd

1. Install xinetd which is necessary for NRPE:

# yum install xinetd

2. Configure xinetd for NRPE by creating xinetd file for NRPE

# vi /etc/xinetd.d/nrpe
### & (Paste below rows)

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 # change
only_from = 127.0.0.1 XXX.XXX.XXX.XXX        ### Replace XXX.XXX.XXX.XXX with actual Nagios Server IP
}

Above entry will allow xinetd access from XXX.XXX.XXX.XXX Nagios Server and localhost 127.0.0.1.

Configuration

1. Add nrpe port to /etc/services – Add NRPE service to /etc/services and make sure port 5666 (default) is open on Firewall:

# echo "nrpe 5666/tcp # NRPE" >> /etc/services

2. Make necessary changes to nrpe.conf – Edit nrpe.cfg and add allowed hosts which can talk to NRPE daemon eg. Nagios Server or any Other NRPE Client (edit allowed_hosts= stanza).

# vi /etc/nagios/nrpe.cfg

allowed_hosts=127.0.0.1, XXX.XXX.XXX.XXX 
### Replace XXX.XXX.XXX.XXX with desired IP addresses

3. Start xinetd/nrpe and enable them at system boot:

# service xinetd start
# service nrpe start
# chkconfig xinetd on
# chkconfig nrpe on

Misc

Nagios NRPE commands can be added in file /etc/nagios/nrpe.cfg.

Example confing:

command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200

To install additional plugins from EPEL:

# yum install nagios-plugins-all

Above yum command will install all additional Nagios Plugins which can be used for system checks. All plugins will be located in /usr/lib64/nagios/plugins – please remember to set proper permissions/user for any 3rd party plugin ( User/group should be: nagios:nagios and permissions: 755 )

Additional plugins can be found here.

Test NRPE Client from Nagios Server

From Nagios Server test new NRPE Client configuration by using check_nrpe plugin:

./check_nrpe -H NEWLY_CONFIGURED_NRPE_CLIENT_IP
nrpe-2.15-2.el6.x86_64

Now proceed with the further configuration on Nagios Server (add client-node-config/commands to check).

Related Post