How to Use the Nagios remote execution plug-in (NRPE) to detect server memory usage
In the previous tutorial (), we have seen how to set the Nagios remote execution plug-in (NRPE) in Nagios settings ). However, the scripts and plug-ins that monitor memory usage are not in native Nagios. In this article, we will see how to configure NRPE to monitor the memory usage on the remote server.
The memory monitoring script we use is available in the Nagios market and can be found in the Creator's Github repository.
Assuming that NRPE has been installed, we first download the script on the server we want to monitor.
Network Monitor Nagios Overview
Nagios construction and Configuration
Build a Nagios monitoring platform in the Nginx Environment
Configure the basic Nagios System on RHEL5.3 (using Nagios-3.1.2)
CentOS 5.5 + Nginx + Nagios monitoring and control terminal installation and Configuration Guide
Install Nagios Core for Ubuntu 13.10 Server
Prepare the remote server in Debain/Ubuntu:
- # Cd/usr/lib/nagios/plugins/
- # Wget https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl
- # Mv check_mem.pl check_mem
- # Chmod + x check_mem
In RHEL/CentOS:
- # Cd/usr/lib64/nagios/plugins/(or/usr/lib/nagios/plugins/for 32-bit)
- # Wget https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl
- # Mv check_mem.pl check_mem
- # Chmod + x check_mem
You can manually run the following command locally to check whether the Script output is normal. When NRPE is used, this command should detect idle memory. When the available memory is less than 20%, a warning will be issued and a severe warning will be generated when the available memory is less than 10%.
- #./Check_mem-f-w 20-c 10
- OK-34.0% (2735744 kB) free. | TOTAL = 801000040kb; USED = 5299596KB; 6428272; 7231806; FREE = 2735744KB; CACHES = 2703504KB ;;;;
If you see the output as above, it means the command works normally.
Now that the script is ready, we need to define the NRPE command to check the memory usage. As described above, the command checks available memory, generates an alarm when the availability is less than 20%, and generates a severe warning when the availability is less than 10%.
- # Vim/etc/nagios/nrpe. cfg
For Debian/Ubuntu:
- Command [check_mem] =/usr/lib/nagios/plugins/check_mem-f-w 20-c 10
For RHEL/CentOS 32 bit:
- Command [check_mem] =/usr/lib/nagios/plugins/check_mem-f-w 20-c 10
For RHEL/CentOS 64 bit:
- Command [check_mem] =/usr/lib64/nagios/plugins/check_mem-f-w 20-c 10
For more details, please continue to read the highlights on the next page: