How to Monitor Remote Linux Host using Nagios and NRPE

Channel: Linux
Abstract: Lets restart NRPE service as per your system # service nrpe restart # On CentOS/RHEL/Fedorawhich command definition is stored on NRPE service. NR

Nagios is the most popular infrastructure monitoring server on internet. You can use our tutorial to install Nagios on RHEL based systems or Debian systems. You need to install NRPE on all remote Linux systems to monitor with Nagios.

NRPE is known as Nagios Remote Plugin Executor. The NRPE add-on is designed to execute plugins on remote Nix systems. In this setup, NRPE daemon is installed on the remote system to which services need to monitor through Nagios server. NRPE runs as a daemon on remote systems and waits for Nagios requests. When Nagios server needs to check the status of any resources or applications to that remote host, sends and commands signal, which command definition is stored on NRPE service. NRPE takes Nagios server request and execute the command on the local system and sends the result back to Nagios.

This article will help you to install NRPE service on your Linux system and add a host in Nagios server for monitoring.

Step 1 – Configure NRPE on Linux Host

Follow the below steps to install and configure NRPE on client machine and check connectivity with Nagios server.

Step 1.1 – Install NRPE

Firstly we would require installing nrpe service on remote Linux system, which we need to monitor through Nagios server.

On CentOS/RHEL/Fedora

# yum install nrpe nagios-plugins*

On Debian/Ubuntu/LinuxMint

$ sudo apt-get install nagios-nrpe-server nagios-plugins
Step 1.2 – Configure NRPE

After successfully installing NRPE service, Edit nrpe configuration file /etc/nagios/nrpe.cfg in your favorite editor and add your nagios service ip in allowed hosts.

# vim /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1, 192.168.1.100

Where 192.168.1.100 is your Nagios server ip address.

After making above changes in nrpe configuration file, Lets restart NRPE service as per your system

# service nrpe restart      # On CentOS/RHEL/Fedora 
$ sudo /etc/init.d/nagios-nrpe-server restart  # On Debian/Ubuntu/LinuxMint
Step 1.3 – Verify Connectivity from Nagios

Now run the below command from Nagios server to make sure your nagios is able to connect nrpe client on remote Linux system. Here 192.168.1.11 is your remote Linux system ip.

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

NRPE v2.15
Step 2 – Add Linux Host in Nagios

We recommend using NagiosQL3 web interface for managing configuration of Nagios server. Below steps is for CLI lovers. To add a host in your Nagios server from command line.

First create a configuration file /usr/local/nagios/etc/servers/MyLinuxHost001.cfg using below values. for example you Linux hosts ip is 192.168.1.11. We also need to define a service with host. So add a ping check service, which will continuously check that host is up or not.

# vim /usr/local/nagios/etc/servers/MyLinuxHost001.cfg
#########################################################
# Linux Host 001 configuration file
#########################################################

define host {
        use                          linux-server
        host_name                    Linux_Host_001
        alias                        Linux Host 001
        address                      192.168.1.11
        register                     1
}
define service{
      host_name                       Linux_Host_001
      service_description             PING
      check_command                   check_ping!100.0,20%!500.0,60%
      max_check_attempts              2
      check_interval                  2
      retry_interval                  2
      check_period                    24x7
      check_freshness                 1
      contact_groups                  admins
      notification_interval           2
      notification_period             24x7
      notifications_enabled           1
      register                        1
}


#########################################################
# END OF FILE
#########################################################

Now verify configuration files using following command. If there are no errors found in configuration, restart nagios service.

# nagios -v /usr/local/nagios/etc/nagios.cfg
# service nagios restart
Step 3 – Check Host in Nagios Web Interface

Open your Nagios web interface and check for new Linux hosts added in Nagios core service. In my case, it looks like below.

Ref From: tecadmin

Related articles