Monitoring memory usage is a crucial aspect of system administration, and tools like Nagios and NRPE offer powerful solutions. Nagios is a popular monitoring system that helps administrators keep track of various metrics, but it does not include memory-monitoring plugins out of the box. This is where NRPE, the Nagios Remote Plugin Executor, comes into play. NRPE allows administrators to execute Nagios plugins on remote servers, enabling memory usage monitoring.
NRPE and Nagios together provide a flexible framework for memory usage monitoring, catering to different needs and preferences. While NRPE facilitates remote execution, Nagios Exchange offers a variety of scripts and plugins for memory monitoring, including check_memory and check_mem.pl. These tools empower administrators to define custom commands, set warning and critical thresholds, and seamlessly integrate memory monitoring into their Nagios setup.
In this guide, we will delve into the step-by-step process of configuring NRPE and Nagios to monitor memory usage effectively. We will cover topics such as script installation, command definition, service check configuration, and troubleshooting common issues. By the end, you should be able to harness the power of NRPE and Nagios to keep a watchful eye on memory usage across your infrastructure.
Characteristics | Values |
---|---|
Memory Checks | Memory Free - Percentage, Memory Free - Specific Value, Memory Used - Percentage, Memory Used - Specific Value |
Memory Free - Percentage | linux-nrpe-agent provides custom_check_mem. The thresholds for the plugin are triggered if the free memory is less than the supplied value. |
Memory Free - Specific Value | Nagios Plugins does not include a memory plugin, but the linux-nrpe-agent does provide custom_check_mem. The checks only support percentage values for free memory. |
Memory Used - Percentage | The check_disk plugin is part of Nagios Plugins. Checks on Percentage Used are not possible with the plugin, you will need to perform a memory free check instead. |
Memory Used - Specific Value | The check_disk plugin is part of Nagios Plugins. Checks on Used amount are not possible with the plugin, you will need to perform a memory free check instead. |
Preparing Remote Servers | Download the script in the server that you want to monitor. |
Preparing Nagios Server | Define a custom command for NRPE. The command can be stored in any directory within Nagios. |
What You'll Learn
Download the check_mem.pl script from Nagios Exchange or the creators' GitHub repository
To monitor memory usage with NRPE Nagios, you can download the check_mem.pl script from the Nagios Exchange or the creator's GitHub repository.
The script can be downloaded from the Nagios Exchange here: http://sysadminsjourney.com/content/2009/06/04/new-and-improved-checkmempl-nagios-plugin/ or https://exchange.nagios.org/directory/Plugins/Operating-Systems/Solaris/check_mem-2Epl/details.
Alternatively, you can download it from the creator's GitHub repository: https://github.com/justintime/nagios-plugins/blob/master/check_mem/check_mem.pl.
Once you have downloaded the script, you can follow these steps to prepare your remote servers, as outlined in the Xmodulo tutorial:
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
Or for 64-bit RHEL/CentOS:
Cd /usr/lib64/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
You can then check if the script is generating output properly by running the following command on localhost:
/check_mem -f -w 20 -c 10
If the command is working, you should see output similar to the following:
OK - 34.0% (2735744 kB) free.|TOTAL=8035340KB;;;; USED=5299596KB;6428272;7231806;; FREE=2735744KB;;;; CACHES=2703504KB;;;;
Now that you have downloaded and tested the script, you can continue with configuring NRPE to monitor RAM usage by defining the appropriate commands and service checks in the relevant configuration files.
Monitoring Data Usage: Track Device Consumption
You may want to see also
Prepare the remote servers
Preparing the Remote Servers
To prepare the remote servers for monitoring memory usage with Nagios Remote Plugin Executor (NRPE), follow these steps:
- Download the monitoring script: Use the command # cd /usr/lib/nagios/plugins/ to navigate to the plugin directory. Then, use wget https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl to download the script.
- Rename and set permissions: Rename the downloaded script using # mv check_mem.pl check_mem, and set the execution permissions with # chmod +x check_mem.
- Check script functionality: Run the command `./check_mem -f -w 20 -c 10` to ensure the script is working correctly. You should see an output like: 'OK - 34.0% (2735744 kB) free.|TOTAL=8035340KB;;;; USED=5299596KB;6428272;7231806;; FREE=2735744KB;;;; CACHES=2703504KB;;;;'.
- Define the command for NRPE: Open the nagios.cfg file using a text editor and add the following line: # command [check_mem]=/usr/lib/nagios/plugins/check_mem -f -w 20 -c 10. This defines the command to check RAM usage for NRPE.
- Restart the NRPE service: After making the above configuration changes, restart the NRPE service for them to take effect.
By following these steps, you will have prepared your remote servers for memory usage monitoring with NRPE and Nagios.
Inns and Internet Privacy: What You Need to Know
You may want to see also
Check the script output
To check the script output, you can run the following command on localhost:
Bash
/check_mem -f -w 20 -c 10
If the command is working correctly, you should see an output similar to the following:
OK - 34.0% (2735744 kB) free.|TOTAL=8035340KB;;;; USED=5299596KB;6428272;7231806;; FREE=2735744KB;;;; CACHES=2703504KB;;;;
This output indicates that the free memory is above the warning threshold of 20%, resulting in an "OK" status. The output also provides detailed information about the total memory, used memory, free memory, and cache memory.
Another way to check the script output is to use the `check_memory` plugin, which can be found on the Nagios Exchange website. This plugin allows you to specify warning and critical thresholds for free memory. Here is an example command:
Bash
/check_memory -w 100: -c 1%
This command will warn you when the free memory falls below 100 MB and trigger a critical alert when it drops below 1%.
Additionally, you can use the `custom_check_mem` script provided by the `linux-nrpe-agent`. This script allows you to check the free memory as a percentage. For example:
Bash
/custom_check_mem -w 20 -c 10
This command will trigger a warning if the free memory falls below 20% and a critical alert if it drops below 10%.
Monitoring Home Electricity Usage: A UK Guide
You may want to see also
Define the command to check RAM usage for NRPE
To define the command to check RAM usage for NRPE, you can follow these steps:
- Download the script: The script used for monitoring RAM usage is available on Nagios Exchange or the creator's GitHub repository. Download the script to the server you want to monitor.
- Check the script output: Run the following command on localhost to ensure the script is generating output properly:
> # ./check_mem -f -w 20 -c 10
> OK - 34.0% (2735744 kB) free.|TOTAL=8035340KB;;;; USED=5299596KB;6428272;7231806;; FREE=2735744KB;;;; CACHES=2703504KB;;;;
Define the command: Open the NRPE configuration file and define the command to check RAM usage. The command will check free memory, warn when free memory is less than 20%, and generate a critical alarm when free memory is less than 10%. For example:
> # vim /etc/nagios/nrpe.cfg
> command[check_mem]=/usr/lib/nagios/plugins/check_mem -f -w 20 -c 10
Specify the system type: Depending on your system type (32-bit or 64-bit), you may need to specify the command path accordingly. 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
Restart the Nagios service: After defining the command, restart the Nagios service to apply the changes:
> # service nagios3 restart
> # service nagios restart
> # systemctl restart nagios.service
By following these steps, you can define the command to check RAM usage for NRPE in Nagios.
Monitoring Gas Usage: Individual Apartment Solutions
You may want to see also
Prepare the Nagios server
In the Nagios server, you need to define a custom command for NRPE. This command can be stored in any directory within Nagios. For simplicity, we will use the /etc/nagios directory.
Vim /etc/nagios3/conf.d/nrpe_command.cfg
Next, define the command:
Define command{
Command_name check_nrpe
Command_line /usr/lib/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c '$ARG1'
}
For RHEL/CentOS 32-bit:
Vim /etc/nagios/objects/nrpe_command.cfg
Define command{
Command_name check_nrpe
Command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
For RHEL/CentOS 64-bit:
Vim /etc/nagios/objects/nrpe_command.cfg
Define command{
Command_name check_nrpe
Command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Now, define the service check in Nagios:
Vim /etc/nagios3/conf.d/nrpe_service_check.cfg
Define service{
Use local-service
Host_name remote-server
Service_description Check RAM
Check_command check_nrpe!check_mem
}
For RHEL/CentOS:
Vim /etc/nagios/objects/nrpe_service_check.cfg
Define service{
Use local-service
Host_name remote-server
Service_description Check RAM
Check_command check_nrpe!check_mem
}
Finally, restart the Nagios service:
Service nagios3 restart
Service nagios restart
Systemctl restart nagios.service
Nagios should now start checking the RAM usage of the remote server using NRPE.
Monitoring CPU and GPU Usage: Practical Guide to Performance
You may want to see also
Frequently asked questions
Nagios Plugins does not include a memory plugin, but you can use the linux-nrpe-agent's custom_check_mem. The thresholds for the plugin are triggered if the free memory is less than the supplied value.
The command to check memory usage is:
```bash
./custom_check_mem -w 20 -c 10
```
To check memory usage as a percentage, use the following command:
```bash
./custom_check_mem -w 20% -c 10%
```