Monitoring Linux Client Using Nagios (NRPE)

Monitoring Linux Client Using Nagios. We can monitor the remote Linux client using SNMP and NRPE (Nagios Remote Plugin Executor) client. In this article we are going to see how to setup a Linux client monitoring using NRPE.

In-order to monitor the Linux client using NRPE we have to install NRPE in client and Nagios server as well.

NRPE installation process

After completion of NRPE installation in client you have to configure (define) commands in remote client. To define a commands you have to edit the below file.

In Remote Client Side

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

end of nrpe.cfg file you have to define the commands using local plugins (default location is /usr/local/nagios/libexec/) as example shown below

## Example Commands mentioned in Remote Linux Client
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10%
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200 
command[check_mem]=/usr/local/nagios/libexec/check_mem_new.sh -w 80 -c 90

Now ensure below things in remote Linux client

  • Add Nagios server IP address in /etc/xinetd.d/nrpe.cfg
  • Add NRPE port number to allow NRPE service to communicate wit Nagios server in /etc/services
  • Check whether NRPE port is listening state using #netstat -at |grep NRPE
  • Add NRPE port (5666/5667/5668) in allow list of your firewall

In NAGIOS Server

First check using check_nrpe command whether remote client is responding to NRPE or not.

# cd /usr/local/nagios/libexec/

# ./check_nrpe -H <Remote Client IP>
# NRPE v2.15

It means NRPE is working.

Now add NRPE commands to commands.cfg

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

# 'check_ssh' command definition
define command{
    command_name    check_ssh
    command_line    $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
    }

## To call All the remote NRPE commands 

define command{
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -n -H $HOSTADDRESS$ -c $ARG1$
    }

## To all all the remote NRPE commands using ssl
define command{
    command_name    check_nrpe_ssl
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
    }

## Check the remote NRPE command using 30seconds time limit
define command{
        command_name    check_nrpe_timeout
        command_line    $USER1$/check_nrpe -n -t 30 -H $HOSTADDRESS$ -c $ARG1$
        }
## Check NRPE without hostname
define command{
    command_name    check_nrpe_without_hostname
    command_line    $USER1$/check_nrpe -n -t 60 -H $ARG1$ -c $ARG2$
    }

# 'check_mem' command definition will check memory utilization
define command{
    command_name    check_mem
    command_line    $USER1$/check_nrpe -n -H $HOSTADDRESS$ -c check_mem $ARG1$ $ARG2$
    }

# 'check_mem_ssl' command definition memory utilization using ssl
define command{
    command_name    check_mem_ssl
    command_line    $USER1$/check_nrpe  -H $HOSTADDRESS$ -c check_mem $ARG1$ $ARG2$
    }


# 'check_disk' command definition Disk space utilization
define command{
    command_name    check_disk
    command_line    $USER1$/check_nrpe -n -H $HOSTADDRESS$ -c check_disk
    }

# 'check_disk_ssl' command definition disk space utilization using ssl
define command{
    command_name    check_disk_ssl
    command_line    $USER1$/check_nrpe  -H $HOSTADDRESS$ -c check_disk
    }

:wq << -- Save & Exit

Monitoring Linux Client Using Nagios

Now create a file with Host name in /usr/local/nagios/etc/objects/ARKIT-LINUX.cfg

# touch /usr/local/nagios/etc/objects/ARKIT-LINUX.cfg

# vi /usr/local/nagios/etc/objects/ARKIT-LINUX.cfg
####### HOST DEFINATION: ARKIT.CO.IN #####
define host{
        use                     linux-server       
        host_name               ARKIT.CO.IN
        alias                   Web Server
        contact_groups            admins
        address                 192.168.234.142
        }
####### SERVICE DEFINATION: ARKIT.CO.IN ######
## Check PING ###
define service{
        use                             generic-service
        host_name                       ARKIT.CO.IN
        service_description             PING
    check_command            check_ping!100.0,20%!500.0,60%
        }
## Check disk space utilization
define service{
        use                             generic-service
        host_name                       ARKIT.CO.IN
        service_description             Disk Space Utilization
    check_command            check_disk_ssl
        }
## Check SSH status
define service{
        use                             generic-service
        host_name                       ARKIT.CO.IN
        service_description             SSH
    check_command            check_ssh
        }
## Check Memory utilization
define service{
        use                             generic-service
        host_name                       ARKIT.CO.IN
        service_description             Memory Utilization
    check_command            check_mem_ssl
        }
## Check Login users list
define service{
        use                             generic-service
        host_name                       ARKIT.CO.IN
        service_description             Current Login Users
    check_command            check_nrpe_ssl!check_users
        }
## Chheck Load
define service{
        use                             generic-service
        host_name                       ARKIT.CO.IN
        service_description             Load
    check_command            check_nrpe_ssl!check_load
        }
### END ###

:wq << -- Save & Exit

Above are only sample commands, please modify the template as per your environment and configuration.

Now add above saved file in /usr/local/nagios/etc/nagios.cfg Approx. line number 36

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

cfg_file=/usr/local/nagios/etc/objects/ARKIT-LINUX.cfg

Now reload or restart nagios services

# service nagios reload

OR

# service nagios restart

Below is the status

Nagios Core consoleMonitoring Linux Client using Nagios Monitoring Linux Client using Nagios Monitoring Linux Client using Nagios Monitoring Linux Client using Nagios

That’s it your Remote Linux Client is configured Successfully.

Your Feedback is More Valuable to US.. Please provide your Valuable comments below.

Related Posts

Installing and configuring Linux Nagios Client (NRPE)

Nagios Installation Guide Step by Step

Thanks for your wonderful Support and Encouragement

Ankam Ravi Kumar

Working as Linux / Storage Administrator L3. Interested in sharing the knowledge.

Leave a Reply

Your email address will not be published. Required fields are marked *