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.
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
1 | command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 |
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
Monitor Memory Uses
A Nagios plugin is available to monitor memory uses on Linux systems. You can download the
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.
1 | 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.
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.
1 | 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 the disk name to monitor. For example, monitoring the root (/) disk or other mounts like (/mnt)
1 2 | 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 the configuration by running the check_nrpe command from the Nagios server
13 Comments
Hi , when i create the services on Nagios web servers says: (No output returned from plugin)
Should the plugin be on the remote server or on the Nagios server?
NRPE and plugins needs to install on remote server.
I cant use check_nrpe, i cant find it on my plugins
I can fix that
NRPE: Command ‘check_mem’ not defined
download check_mem.pl from nagios plugin website
https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_mem/details
what system load is different than cpu load.
Hi Rahul, i have successfully installed the nagios server. but i am not able to add hosts in nagios monitoring tool. please help me.
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?
Use check_mem as a command with NRPE.
Ok, but the script will still be called check_mem.pl, right? One more note, this script works on ubuntu 16.04 machines?
You might have to restart the NRPE daemon after you make the change on the nrpe.cfg. Once you restart the daemon or service, NRPE should figure the changes in the cfg.