第 4 章 在 Nagios 核心服务器上配置远程节点


将 Nagios 核心服务器配置为了解远程主机。

先决条件

  • 对 Nagios 核心服务器上的远程节点的根级别访问权限。
  • 互联网访问。

流程

  1. 安装 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

  2. 为远程主机创建配置:

    语法

     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

  3. 编辑配置文件并更新远程主机的设置:

    语法

    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
    }

  4. 删除或注释掉主机组定义:

    示例

    [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
    #}
  5. 将文件所有权改为 Nagios:

    示例

    [root@nagios objects]# chown nagios:nagios host01.cfg

  6. 向 /usr/local/nagios/etc/nagios.cfg 中的 host01.cfg 文件添加 cfg_file= 引用:

    示例

    [root@nagios objects]# vi /usr/local/nagios/etc/nagios.cfg

    cfg_file=/usr/local/nagios/etc/objects/host01.cfg
  7. 重启 Nagios 服务器:

    示例

    [root@nagios objects]# systemctl restart nagios

  8. 确保 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。
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部