Nagios Server通过NRPE监控client memory usage.

How to monitor server memory usage with Nagios Remote Plugin Executor (NRPE)

Last updated on September 8, 2014 Authored by Sarmed Rahman 5 Comments

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.

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, 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%.

# ./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 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%.

# 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

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 simple, we will 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 ‘$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 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.service

Troubleshooting

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

  1. Make sure that NRPE port is allowed all the way to 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/plugins/check_nrpe -H remote-server
  3. You 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 any configuration or permission errors. If there are not hits in the log, it is very likely that the requests are not reaching the remote server due to port filtering at some point.

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

时间: 2024-11-02 17:05:53

Nagios Server通过NRPE监控client memory usage.的相关文章

实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- Nagios Server端

关于nrpe的方式网上已经有很多很好的总结,我现在说说在我们系统中如何是用NSCA方式来获取我们需要的被监控节点的资源使用情况信息. 先讲讲Nagios Server端的基本配置: 1. nagios web gui 访问配置,系统中使用的是nagios core中推荐的配置方式,通过apache httpd访问nagios web,安装nagios的时候会自动寻找系统中安装的httpd,把nagios的httpd文件放到httpd的conf.d目录下,这样,只要生成一次nagios web访问

How to Add Linux Host to Nagios Monitoring Server Using NRPE Plugin

In our first part of this article, we’ve explained in detail on how to install and configure latest Nagios Core 4.2.0on CentOS 7.2 server. In this article we will show you how to add Remote Linux machine and it’s services to Nagios Monitoring host us

Nagios学习笔记四:基于NRPE监控远程Linux主机

1.NRPE简介 Nagios监控远程主机的方法有多种,其方式包括SNMP.NRPE.SSH和NCSA等.这里介绍其通过NRPE监控远程Linux主机的方式. NRPE(Nagios Remote Plugin Executor)是用于在远端服务器上运行检测命令的守护进程,它用于让Nagios监控端基于安装的方式触发远端主机上的检测命令,并将检测结果输出至监控端.而其执行的开销远低于基于SSH的检测方式,而且检测过程并不需要远程主机上的系统帐号等信息,其安全性也高于SSH的检测方式. 2.安装配

Nagios基于NRPE 监控远程Linux主机

1 安装环境: 监控段IP: 192.168.4.34 主机名:nagios.com 操作系统:CentOS release 6.8 (Final) 软件:nagios-4.2.0,nagios-plugins-2.1.2,nrpe-2.15 被监控端IP:192.168.4.111 主机名:client.com操作系统:CentOS release 6.8 (Final)软件:nagios-plugins-2.1.2,nrpe-2.15 2 NRPE简介 2.1 NRPE 功能介绍 NRPE是

Nagios利用NRPE监控Linux主机

一.简介 1.NRPE介绍 NRPE是Nagios的一个功能扩展,它可在远程Linux/Unix主机上执行插件程序.通过在远程服务器上安装NRPE插件及Nagios插件程序来向Nagios监控平台提供该服务器的本地情况,如CPU负载,内存使用,磁盘使用等.这里将Nagios监控端称为Nagios服务器端,而将远程被监控的主机称为Nagios客户端. Nagios监控远程主机的方法有多种,其方式包括SNMP,NRPE,SSH,NCSA等.这里介绍其通过NRPE监控远程Linux主机的方式. NRP

Nagios利用NRPE监控Linux主机(3)

一.利用NRPE监控远程Linux的"本地信息" 上面已经对远程Linux 主机是否存活做了监控,而判断远程机器是否存活,我们可以使用ping 工具对其监测.还有一些远程主机服务,例如ftp.ssh.http,都是对外开放的服务,即使不用Nagios,我们也可以试的出来,随便找一台机器看能不能访问这些服务就行了.但是对于像磁盘容量,cpu负载这样的"本地信息",Nagios只能监测自己所在的主机,而对其他的机器则显得有点无能为力.毕竟没得到被控主机的适当权限是不可能

关于Nagios通过NRPE监控客户端的安装与配置

环境介绍>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>服务端(监控端):192.168.100.2     --nagios服务+check_nrpe客户端(被监控端):192.168.100.3    --nrpe守护进程+检测插件 Nagios通过NRPE来远端管理服务的过程1. Nag

实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- 被监控端

Nagios要求被监控端按照约定格式定时将数据发送到Nagios端.监控包括节点和服务2种. 节点监控约定数据格式如下: [<timestamp>] PROCESS_HOST_CHECK_RESULT;<host_name>;<host_status>;<plugin_output> 格式很容易理解,数据提交时间戳,被监控节点名称,节点状态(UP/DOWN/UNREARCHABLE),插件自定义的额外数据.状态具体每个字段的解释如下: 1. timestam

nagios安装以及NRPE的安装

nagios不检测任何具体数值指示(如操作系统上的进程个数),它只描述四种被监控对象的状态:OK,WARNING,CRITICAL和UNKNOWN.于是,我们只需要对魔种监控对象的WARNING和CRITICAL状态的阈值进行关注,nagios将阈值传递给插件,由插件负责具体对象的监控以及结果分析,其返回四中状态信息 nagios监控的不同对象的不同方式   linux/UNIX: SNMP,NRPE,send-nsca   switch: SNMP   print: SNMP   window