Nagios Server monitors client memory usage through Nrpe.

Source: Internet
Author: User
Tags server memory

How to monitor server memory usage with Nagios Remote Plugin Executor (NRPE)Last updated in September 8, authored by sarmed Rahman 5 Comments

In a previous tutorial, we had 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 does not come with the stock Nagios. In this tutorial, we'll see how we can configure NRPE to monitor RAM usage of a remote server.

The script that we'll use for monitoring RAM are available at Nagios Exchange, as well as the creators ' Github repository .

Assuming that NRPE have already been set up and we start the process by downloading the script in the server so we want to M Onitor.

Preparing Remote Servers

On 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

On 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 check whether the script generates output properly by manually running the following command on localhost. When used with NRPE, the This command was supposed to the check free memory, warn if free memory was less than 20%, and generate C Ritical Alarm when free memory was less than 10%.

#./check_mem-f-W 20-c 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 a output, that means the command is working okay.

Now, the script was ready and we define the command to check RAM usage for NRPE. As mentioned before, the command would check free memory, warn if free memory was less than 20%, and generate critical ala RM when free memory are 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-bit:

Command[check_mem]=/usr/lib/nagios/plugins/check_mem  -f-w 20-c 10

For Rhel/centos-bit:

Command[check_mem]=/usr/lib64/nagios/plugins/check_mem  -f-w 20-c 10
Preparing Nagios Server

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, we'll put the command definition In/etc/nagios directory.

For Debian/ubuntu:

# vim/etc/nagios3/conf.d/nrpe_command.cfg
Define command{        command_name Check_nrpe        command_line/usr/lib/nagios/plugins/check_nrpe-h ' $HOSTADDRESS $ ' -  C ' $ARG 1$ '}

For Rhel/centos-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-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 $ARG 1$         }

Now we define the service check in Nagios.

On Debian/ubuntu:

# 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}

On 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, we restart the Nagios service.

On Debian/ubuntu:

# Service NAGIOS3 Restart

On Rhel/centos 6:

# Service Nagios Restart

On Rhel/centos 7:

# systemctl Restart Nagios.servicetroubleshooting

Nagios should start checking RAM usage of a remote-server using NRPE. If you have any problem, you could check the following.

    1. Make sure this NRPE port is allowed all the same as the remote host. Default NRPE Port is TCP 5666.
    2. you could try manually checking NRPE operation by executing the Check_nrpe command: /usr/lib/nagios/plugi Ns/check_nrpe-h remote-server
    3. could also try to run the check_mem command manually: /usr/ Lib/nagios/plugins/check_nrpe-h remote-server–c check_mem
    4. in the remote server, set debug=1 in/ Etc/nagios/nrpe.cfg. Restart the NRPE service and check the log file/var/log/messages (Rhel/centos) Or/var/log/syslog (Debain/ubuntu). The log files should contain relevant information if there is an any configuration or permission errors. If There is a hits in the log, it's very likely that the requests was not reaching the remote server due to port Filte Ring at some point.

To sum up, this tutorial demonstrated how we can easily tune NRPE to monitor RAM usage of the remote servers. The process is as simple as downloading the script, defining the commands, and restarting the services. Hope this helps.

Original link: http://xmodulo.com/monitor-server-memory-usage-nagios-remote-plugin-executor.html

Nagios Server monitors client memory usage through Nrpe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.