Nagios is the most popular monitoring server for the 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.
You have installed 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.
apt-get install nagios-nrpe-server
sudo yum 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 NRPE configuration file and check for the following entry. This should be default available there. You don’t need to make any changes.
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
Let’s verify configuration by running the check_nrpe command from the Nagios server.
As per the above screenshot, Nagios server sent NRPE requests to defined host ( IP ) to execute command check_load and send results back. The requests go to remote host and 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 system. You can download the check_mem.pl and configure with NRPE daemon. Download check_mem.pl using the following command and copy it to 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.
command[check_mem]=/usr/lib/nagios/plugins/check_mem.pl -f -w 20 -c 10
-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.
Let’s verify configuration by running a check_nrpe command from the Nagios server.
Monitor Disk Uses
A Nagios plugin check_disk is available to check disk status. Edit NRPE configuration file and add the following entry to check disk /dev/sda1.
command[check_sda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /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 disk name to monitor. For example, monitoring the root (/) disk or other mounts like (/mnt)
command[check_root_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p / command[check_mnt_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /mnt
Let’s verify configuration by running check_nrpe command from the Nagios server.