标签:
In a previous tutorial, we have seen how we can set up Nagios Remote Plugin Executor (NRPE) in an existing Nagios setup. However, the scripts and plugins needed to monitor memory usage do not come with stock Nagios. In this tutorial, we will see how we can configure NRPE to monitor RAM usage of a remote server.
The script that we will use for monitoring RAM is available at Nagios Exchange, as well as the creators‘ Github repository.
Assuming that NRPE has already been set up, we start the process by downloading the script in the server that we want to monitor.
On Debain/Ubuntu:
On RHEL/CentOS:
You can check whether the script generates output properly by manually running the following command on localhost. When used with NRPE, this command is supposed to check free memory, warn when free memory is less than 20%, and generate critical alarm when free memory is less than 10%.
OK - 34.0% (2735744 kB) free.|TOTAL=8035340KB;;;; USED=5299596KB;6428272;7231806;; FREE=2735744KB;;;; CACHES=2703504KB;;;;
If you see something like the above as an output, that means the command is working okay.
Now that the script is ready, we define the command to check RAM usage for NRPE. As mentioned before, the command will check free memory, warn when free memory is less than 20%, and generate critical alarm when free memory is less than 10%.
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
In the Nagios server, we define a custom command for NRPE. The command can be stored in any directory within Nagios. To keep the tutorial simple, we will put the command definition in /etc/nagios directory.
For Debian/Ubuntu:
define command{ command_name check_nrpe command_line /usr/lib/nagios/plugins/check_nrpe -H ‘$HOSTADDRESS$‘ -c ‘$ARG1$‘ }
For RHEL/CentOS 32 bit:
define command{ command_name check_nrpe command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
For RHEL/CentOS 64 bit:
define command{ command_name check_nrpe command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
Now we define the service check in Nagios.
On Debian/Ubuntu:
define service{ use local-service host_name remote-server service_description Check RAM check_command check_nrpe!check_mem }
On RHEL/CentOS:
define service{ use local-service host_name remote-server service_description Check RAM check_command check_nrpe!check_mem }
Finally, we restart the Nagios service.
On Debian/Ubuntu:
On RHEL/CentOS 6:
On RHEL/CentOS 7:
Nagios should start checking RAM usage of a remote-server using NRPE. If you are having any problem, you could check the following.
To sum up, this tutorial demonstrated how we can easily tune NRPE to monitor RAM usage of remote servers. The process is as simple as downloading the script, defining the commands, and restarting the services. Hope this helps.
原文链接:http://xmodulo.com/monitor-server-memory-usage-nagios-remote-plugin-executor.html
Nagios Server通过NRPE监控client memory usage.
标签:
原文地址:http://www.cnblogs.com/torvalds0310/p/4281715.html