Nagios is the most popular monitoring server for infrastructure monitoring. In the series of Nagios monitoring tutorials, this tutorial will help you to monitor Memory, CPU, and Disk on a remote Linux system using Nagios and NRPE. I assume you have a running Nagios server on your network.

Advertisement

Prerequisites

You have installed the NRPE client on your Linux system. Use the following commands to install NRPE on your system or visit our tutorials for the NRPE installation on Debian based systems and Redhat based systems.

  • Ubuntu and Debian based systems:
    sudo apt install nagios-nrpe-server 
    
  • Redhat, CentOS systems:
    sudo dnf install nrpe nagios-plugins
    

NRPE default configuration file is /etc/nagios/nrpe.cfg. You need to edit this file for making changes as per the next instructions.

Monitor CPU Load

A Nagios plugin check_load is available to check current CPU load on the system. Edit the NRPE configuration file and check for the following entry. This should be default available there. You don’t need to make any changes.

Let’s verify the configuration by running the check_nrpe command from the Nagios server

As per the above screenshot, the Nagios server sent NRPE requests to the defined host (192.168.1.15) to execute command check_load and send results back. The requests go to the remote host and the NRPE server checks for the command defined as check_load and execute it.

Monitor Memory Uses

A Nagios plugin is available to monitor memory uses on Linux systems. You can download the check_mem.pl and configure with NRPE daemon. Download check_mem.pl using the following command and copy it to the Nagios plugins directory. On CentOS/RHEL 64-bit systems this local will be /usr/lib64/nagios/plugins.

cd /usr/lib/nagios/plugins/
wget https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl
chmod +x check_mem.pl

Edit NRPE configuration file and add a command to check memory uses like below. This will not calculate the swap memory in results.

  • -w 20 – Send a warning message if free memory is less 20% of the total memory.
  • -c 10 – Send a critical message if free memory is less 10% of the total memory.

Now verify the configuration by running the check_nrpe command from the Nagios server

Monitor Disk Uses

A Nagios plugin check_disk is available to check disk status. Edit the NRPE configuration file and add the following entry to check disk /dev/sda1.

  • -w 20% – Sent a warning message if the free disk is less than 20% of the total disk.
  • -c 10% – Sent a critical message if the free disk is less than 10% of the total disk.
  • -p /dev/sda1 – Defines disk to be checked.

You can also define the mount point instead of the disk name to monitor. For example, monitoring the root (/) disk or other mounts like (/mnt)

Let’s verify the configuration by running the check_nrpe command from the Nagios server

Share.

13 Comments

  1. Hi Rahul, i have successfully installed the nagios server. but i am not able to add hosts in nagios monitoring tool. please help me.

  2. Hello,

    I’m having trouble adding the rule to monitor the memory usage on a linux machine. On my Nagios machine the error it’s “NRPE: Command ‘check_mem.pl’ not defined”. Can you help me, please?

Exit mobile version