第 4 章 在 Nagios 核心服务器上配置远程节点
将 Nagios 核心服务器配置为了解远程主机。
先决条件
- 对 Nagios 核心服务器上的远程节点的根级别访问权限。
- 互联网访问。
流程
安装
check_nrpe插件:示例
[root@nagios ~]# cd ~ [root@nagios ~]# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.0.3/nrpe-4.0.3.tar.gz [root@nagios ~]# tar xvfz nrpe-4.0.3.tar.gz [root@nagios ~]# cd nrpe-4.0.3 [root@nagios nrpe-4.0.3]# ./configure [root@nagios nrpe-4.0.3]# make check_nrpe [root@nagios nrpe-4.0.3]# make install-plugin为远程主机创建配置:
语法
cd /usr/local/nagios/etc/objects cp localhost.cfg HOST_TO_ADD.cfg示例
[root@nagios nrpe-4.0.3]# cd /usr/local/nagios/etc/objects [root@nagios objects]# cp localhost.cfg host01.cfg编辑配置文件并更新远程主机的设置:
语法
vi HOST_TO_ADD.cfg示例
[root@nagios objects]# vi host01.cfg语法
# Define a host for the local machine define host { use linux-server ; Name of host template to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name LOCALHOST alias LOCALHOST address 127.0.0.1 }将 LOCALHOST 替换为远程主机的主机名,将
127.0.0.1替换为 Ceph 监控主机的 IP 地址。示例
# Define a host for the local machine define host { use linux-server ; Name of host template to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name host01 alias host01 address 10.10.128.69 }删除或注释掉主机组定义:
示例
[root@nagios objects]# vi host01.cfg#define hostgroup { # # hostgroup_name linux-servers ; The name of the hostgroup # alias Linux Servers ; Long name of the group # members localhost ; Comma separated list of hosts that belong to this group #}将文件所有权改为 Nagios:
示例
[root@nagios objects]# chown nagios:nagios host01.cfg向
/usr/local/nagios/etc/nagios.cfg中的host01.cfg文件添加cfg_file=引用:示例
[root@nagios objects]# vi /usr/local/nagios/etc/nagios.cfgcfg_file=/usr/local/nagios/etc/objects/host01.cfg重启 Nagios 服务器:
示例
[root@nagios objects]# systemctl restart nagios确保 make 和 install 过程可以正常工作,并且 Nagios 核心服务器和包含 NRPE 的远程主机之间存在连接:
语法
/usr/local/nagios/libexec/check_nrpe -H HOSTNAME_OF_REMOTE_HOST将 HOSTNAME_OF_REMOTE_HOST 替换为要监控的 Ceph 主机的 IP 地址。
示例
[root@nagios objects]# /usr/local/nagios/libexec/check_nrpe -H host01
验证
-
如果检查正常工作,则检查应该回显
NRPE v4.0.3。