如何在CentOS/RHEL 7/6上安装NRPE

第1步 - 安装EPEL存储库

NRPE包和插件在EPEL yum存储库下可用,使用以下命令之一启用EPEL存储库。

### On CentOS/RHEL - 7 ###
rpm -Uvh http://dl.project.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

### On CentOS/RHEL - 6 ###
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

第2步 - 安装NRPE和Nrpe插件

启用EPEL存储库后,使用以下命令在您的系统中安装NRPE和插件。

yum --enablerepo=epel -y install nrpe nagios-plugins

我们还需要安装NRPE执行的用于监视服务的命令。 使用以下命令获取可用命令包的列表。 在您的远程系统上安装所需的软件包。

yum --enablerepo=epel -y list nagios-plugins*

Installed Packages
nagios-plugins.x86_64                      2.2.1-4git.el7     @epel
Available Packages                                          
nagios-plugins-all.x86_64                  2.2.1-4git.el7     epel
nagios-plugins-apt.x86_64                  2.2.1-4git.el7     epel
nagios-plugins-bacula.x86_64               5.2.13-23.1.el7    base
nagios-plugins-bonding.x86_64              1.4-3.el7          epel
nagios-plugins-breeze.x86_64               2.2.1-4git.el7     epel
nagios-plugins-by_ssh.x86_64               2.2.1-4git.el7     epel
nagios-plugins-check-updates.x86_64        1.6.18-2.el7       epel
nagios-plugins-cluster.x86_64              2.2.1-4git.el7     epel
nagios-plugins-dbi.x86_64                  2.2.1-4git.el7     epel
nagios-plugins-dhcp.x86_64                 2.2.1-4git.el7     epel
nagios-plugins-dig.x86_64                  2.2.1-4git.el7     epel
nagios-plugins-disk.x86_64                 2.2.1-4git.el7     epel
nagios-plugins-disk_smb.x86_64             2.2.1-4git.el7     epel
nagios-plugins-dns.x86_64                  2.2.1-4git.el7     epel
[...]

步骤3 - 配置NRPE

首先,我们需要编辑NRPE配置文件并启动配置才能正常工作。

vim /etc/nagios/nrpe.cfg

用下面的allowed_hosts添加你的Nagios服务器ip,例如Nagio服务器的ip是192.168.1.110。

allowed_hosts=127.0.0.1, 192.168.1.110

添加上面的条目后,您将看到Nagios服务器能够连接NRPE客户端。 让添加命令来监视服务。 在同一个文件中添加新的命令或更新下面的现有命令。

command[check_root_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

按照监视要求,可以添加更多的命令。

步骤4 - 启动NRPE服务

完成所有更改后,重新引导NRPE一次以读取新配置,同时将NRPE配置为在系统引导时自动启动。

sudo systemctl enable nrpe.service
sudo systemctl start nrpe.service

第5步 - 从Nagios服务器测试NRPE

登录到Nagios服务器并执行以下命令来验证Nagios服务器是否能够连接到客户端的NRPE服务。 连接成功后,会显示客户端版本的NRPE包。 例如,安装了NRPE的远程系统IP是192.168.1.20。

check_nrpe -H 192.168.1.20

NRPE v3.1

更多Nagios相关教程见以下内容

Nagios 的详细介绍请点这里
Nagios 的下载地址请点这里

猜你喜欢

转载自www.linuxidc.com/Linux/2017-12/149212.htm