Nagios: Monitoring Linux

In this sample, Nagios monitors remote Linux host via the plugin named ‘check_nrpe’. And the NRPE package needs to be installed on the remote Linux host, as it works as the Nagios Linux agent.


* The following configurations need to be done on the remote Linux/Unix host:

1) Install prerequisite packages.

yum install -y gcc glibc glibc-common
yum install -y openssl-devel

2) Create nagios account

useradd nagios
passwd nagios

3) Download and install nagios plugins.

tar xvzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
export LDFLAGS=-ldl
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec/

4) Download and install NRPE.

tar xvfz nrpe-2.12.tar.gz
cd nrpe-2.12
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

5) Setup NRPE to run as daemon.

vi /etc/xinetd.d/nrpe
add the nagios server IP here: only_from   =
vi /etc/services
add this line: nrpe            5666/tcp                     #NRPE
service xinetd restart

6) Modify the nrpe.cfg configuration file if you want to customize it.

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

* The following configurations need to be done on the Nagios server:

1) Download and install the NRPE plugin.

tar xvfz nrpe-2.12.tar.gz cd nrpe-2.12
make all
make install-plugin

2) Create host and service for the remote Linux host.

vi /usr/local/nagios/etc/objects/linux.cfg

# host definition
define host{   
    use linux-server
    host_name RHEL02
    alias RHEL02
    address ;remote linux server IP address
    contact_groups admins

# service definition
define service{      
    use generic-service
    host RHEL02
    service_description Root Partition
    contact_groups admins
    check_command check_nrpe!check_local_disk

3) Edit the command.cfg and nagios.cfg files.

vi /usr/local/nagios/etc/objects/commands.cfg

Add the following lines:
# check_nrpe
define command{      
  command_name check_nrpe
  command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

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

Add the following lines:
# Definitions for monitoring a Linux machine

4) Verfiy the nagios configurations.

alias verinagios='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'

* you can make the alias permanent by adding alias verinagios=’/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg’ to your profile ~/.bashrc

4) Reload the nagios service.

service nagios reload

Here we go. The newly added Linux host should be listed in the monitored hosts now:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s