使用 Nagios 指南监控 Ceph

Red Hat Ceph Storage 4

使用 Nagios 核心监控 Ceph.

摘要

本文档提供有关安装和配置 Nagios 以监控红帽 Ceph 存储集群的说明。
红帽承诺替换我们的代码、文档和网页属性中存在问题的语言。我们从这四个术语开始: master、slave、blacklist 和 whitelist。这些更改将在即将发行的几个发行本中逐渐实施。详情请查看 CTO Chris Wright 信息

第 1 章 Nagios 和 Ceph

Nagios Core 是一款用于监控节点的开源解决方案。大型红帽 Ceph 存储集群得益于分布式监控系统,如 Nagios Core。Nagios Core 检查集群中的每个节点,包括底层操作系统的健康状态以及红帽 Ceph 存储集群守护进程的健康状况。

要使用 Ceph 部署 Nagios 内核,需要:

  • 一个正在运行的 Red Hat Ceph Storage 集群。

您还可以替换功能更丰富的商业版本 Nagios XI,而不是 Nagios Core。

重要

红帽不提供 Nagios 软件包。

重要

红帽与我们的技术合作伙伴合作,将本文档作为为客户提供服务。但是,红帽不提供对这个产品的支持。如果您需要此产品的技术协助,请联系 Nagios 以获得支持。

第 2 章 Nagios 内核安装和配置

作为存储管理员,您可以通过下载 Nagios 核心源代码来安装 Nagios Core;然后在运行 Nagios Core 实例的节点上配置、设置并安装它。

2.1. 从源安装和配置 Nagios 核心服务器

Nagios 核心软件没有 Red Hat Enterprise Linux 软件包,因此必须根据源代码编译 Nagios 核心软件。

先决条件

  • 访问 OpenSSL.
  • 互联网访问.

流程

  1. 安装先决条件:

    [user@nagios]# yum install -y httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl openssl-devel wget unzip
  2. httpd 打开端口 80:

    [user@nagios]# firewall-cmd --zone=public --add-port=80/tcp
    [user@nagios]# firewall-cmd --zone=public --add-port=80/tcp --permanent
  3. 为 Nagios Core 创建用户和组:

    [user@nagios]# useradd nagios
    [user@nagios]# passwd nagios
    [user@nagios]# groupadd nagcmd
    [user@nagios]# usermod -a -G nagcmd nagios
    [user@nagios]# usermod -a -G nagcmd apache
  4. 下载 Nagios Core 和 Plug-ins 的最新版本:

    [user@nagios]# wget --inet4-only https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.1.tar.gz
    [user@nagios]# wget --inet4-only http://www.nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
    [user@nagios]# tar zxf nagios-4.3.1.tar.gz
    [user@nagios]# tar zxf nagios-plugins-2.2.1.tar.gz
    [user@nagios]# cd nagios-4.3.1
  5. run ./configure:

    [user@nagios]# ./configure --with-command-group=nagcmd
  6. 编译 Nagios 核心源代码:

    [user@nagios]# make all
  7. 安装 Nagios 源代码:

    [user@nagios]# make install
    [user@nagios]# make install-init
    [user@nagios]# make install-config
    [user@nagios]# make install-commandmode
    [user@nagios]# make install-webconf
  8. 复制事件处理程序并更改其所有权:

    [user@nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
    [user@nagios]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
  9. 运行 pre-flight 检查:

    [user@nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  10. 创建并安装 Nagios Core 插件:

    [user@nagios]# cd ../nagios-plugins-2.2.1
    [user@nagios]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
    [user@nagios]# make
    [user@nagios]# make install
  11. 为 Nagios Core 用户界面创建一个用户:

    [user@nagios]$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    重要

    如果添加 nagiosadmin 以外的用户,请确保 /usr/local/nagios/etc/cgi.cfg 文件也使用用户名更新。

    另外,根据需要使用用户名、全名和电子邮件地址修改 /usr/local/nagios/etc/objects/contacts.cfg 文件。

  12. run ./configure:

    [user@nagios]# ./configure --with-command-group=nagcmd
  13. 编译 Nagios 核心源代码:

    [user@nagios]# make all
  14. 安装 Nagios 源代码:

    [user@nagios]# make install
    [user@nagios]# make install-init
    [user@nagios]# make install-config
    [user@nagios]# make install-commandmode
    [user@nagios]# make install-webconf
  15. 复制事件处理程序并更改其所有权:

    [user@nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
    [user@nagios]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
  16. 运行 pre-flight 检查:

    [user@nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

2.2. 启动 Nagios 核心服务

启动 Nagios 核心服务,以监控红帽 Ceph 存储集群的健康状态。

先决条件

  • 对 Nagios 核心服务的根级别访问权限.

流程

  1. 添加 Nagios Core 作为服务并启用它:

    [user@nagios]# chkconfig --add nagios
    [user@nagios]# chkconfig --level 35 nagios on
  2. 启动 Nagios 核心守护进程和 Apache:

    [user@nagios]# systemctl start nagios
    [user@nagios]# systemctl enable httpd
    [user@nagios]# systemctl start httpd

2.3. 登录到 Nagios 内核服务器

登录 Nagios Core 服务器,以查看红帽 Ceph 存储集群的健康状况。

先决条件

  • Nagios Web 界面的用户名和密码。

流程

  1. 启动并运行 Nagios 时,登录到 web 用户界面:

    http://IP_ADDRESS/nagios

    Nagios Core 将提示输入用户名和密码。

  2. 输入默认 Nagios Core 用户的登录名和密码。

第 3 章 Nagios 远程插件执行器安装

作为存储管理员,您可以监控 Ceph 存储集群节点、安装 Nagios 插件、Ceph 插件和 Nagios 远程插件执行器(NRPE)附加组件到每个 Ceph 节点。

为了演示目的,本节将 NRPE 添加到具有主机名 mon 的 Ceph 监控节点。在 Nagios 应监控的所有 Ceph 节点上重复剩余的步骤。

3.1. 安装和配置 Nagios Remote Plug-In Executor

安装 Nagios Remote Plug-in Executor(NPRE),并将其配置为与 Nagios 核心服务器通信。

先决条件

  • 访问 OpenSSL.
  • 对 Ceph 监控节点的用户级访问.

流程

  1. 在节点上安装这些软件包:

    [user@mon]# yum install openssl openssl-devel gcc make git
  2. NRPE 安装需要 Nagios 用户。因此,请首先创建用户:

    [user@mon]# useradd nagios
    [user@mon]# passwd nagios
  3. 下载最新版本的 Nagios 插件。然后,进行并安装它们:

    [user@mon]# wget http://www.nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
    [user@mon]# tar zxf nagios-plugins-2.2.1.tar.gz
    [user@mon]# cd nagios-plugins-2.2.1
    [user@mon]# ./configure
    [user@mon]# make
    [user@mon]# make install
  4. NRPE 使用 xinetd 进行通信.安装 NRPE 模块前安装它:

    [user@mon]# yum install xinetd
  5. 下载 Ceph 插件的最新转换:

    [user@mon]# cd ~
    [user@mon]# git clone --recursive https://github.com/valerytschopp/ceph-nagios-plugins.git
    [user@mon]# cd ceph-nagios-plugins
    [user@mon]# make dist
    [user@mon]# make install
  6. 下载、制作并安装 Nagios NRPE:

    [user@mon]# cd ~
    [user@mon]# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.1.0/nrpe-3.1.0.tar.gz
    [user@mon]# tar xvfz nrpe-3.1.0.tar.gz
    [user@mon]# cd nrpe-3.1.0
    [user@mon]# ./configure
    [user@mon]# make all
    [user@mon]# make install-groups-users
    [user@mon]# make install
    [user@mon]# make install-config
    [user@mon]# make install-init
  7. 编辑 /etc/services 文件,并添加服务字符串 nrpe 5666/tcp
  8. 打开端口 5666,以允许与 NRPE 通信:

    [user@mon]# firewall-cmd --zone=public --add-port=5666/tcp
    [user@mon]# firewall-cmd --zone=public --add-port=5666/tcp --permanent

3.2. 启动 Nagios 远程插件执行器服务

启动 Nagios Remote Plug-in Executor 服务,收集数据并将其报告回 Nagios 核心服务器。

先决条件

  • 用户对 Ceph 监控节点的访问

流程

  1. 启用、重启和重新载入 xinetd:

    [user@mon]# systemctl enable xinetd
    [user@mon]# systemctl restart xinetd
    [user@mon]# systemctl reload xinetd
  2. 启用并启动 NRPE:

    [user@mon]# systemctl enable nrpe
    [user@mon]# systemctl start nrpe

3.3. 配置 Nagios 核心服务器访问远程节点

为了使 Nagios Core 服务器能够访问远程机器上的 Nagios Remote Plugin Executor(NPRE),远程计算机的 xinetd 和 NRPE 配置必须使用 Nagios 核心服务器的 IP 地址更新。

先决条件

  • 用户级访问 Nagios 核心服务器.
  • 互联网访问.
  • 访问 Nagios 远程插件执行器.

流程

  1. 使用 Nagios 服务器的 IP 地址编辑 xinetd 配置:

    [user@mon]# vi /etc/xinetd.d/nrpe
    # default: off
    # description: NRPE (Nagios Remote Plugin Executor)
    service nrpe
    {
        disable         = yes
        socket_type     = stream
        port            = 5666
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        only_from       = 127.0.0.1,IP_ADDRESS_OF_NAGIOS_CORE_SERVER
        log_on_success  =
    }
  2. 将 Nagios Core 服务器的 IP 地址添加到 only_from 选项后,重启 xinetd 服务:

    [user@mon]# systemctl restart xinetd
  3. 使用 Nagios 服务器的 IP 地址编辑 NRPE 配置:

    [user@mon]# vi /usr/local/nagios/etc/nrpe.cfg
    allowed_hosts=127.0.0.1,IP_ADDRESS_OF_NAGIOS_CORE_SERVER
  4. 将 Nagios Core 服务器的 IP 地址添加到 allowed_hosts 设置。然后,重启 nrpe

    [user@mon]# systemctl restart nrpe
  5. 测试安装:

    [user@host]# /usr/local/nagios/libexec/check_nrpe -H localhost

    该检查应回显 NRPE v3.1.0-rc1 (如果工作正常)。

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

将 Nagios 核心服务器配置为了解远程节点。

先决条件

  • 用户级别访问 Nagios Core 服务器上的远程节点。
  • 互联网访问.

流程

  1. 安装 check_nrpe 插件:

    [user@nagios]# cd ~
    [user@nagios]# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.1.0/nrpe-3.1.0.tar.gz
    [user@nagios]# tar xvfz nrpe-3.1.0.tar.gz
    [user@nagios]# cd nrpe-3.1.0
    [user@nagios]# ./configure
    [user@nagios]# make check_nrpe
    [user@nagios]# make install-plugin
  2. 为远程主机创建配置:

    [user@nagios]# cd /usr/local/nagios/etc/objects
    [user@nagios]# cp localhost.cfg mon.cfg

    使用远程主机的主机名替换 localhost,将环回 IP 地址替换为远程主机的 IP 地址。最后,删除或注释掉主机组定义。

  3. 将文件所有权改为 Nagios:

    [user@nagios]# chown nagios:nagios mon.cfg
  4. /usr/local/nagios/etc/nagios .cfg 中添加对 mon.cfg 文件的 mon.cfg 引用

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

    示例

    cfg_file=/usr/local/nagios/etc/objects/mon.cfg

  5. 重启 Nagios 服务器:

    [user@nagios]# systemctl restart nagios
  6. 确保制作和安装过程正常工作,并且 Nagios Core 服务器和包含 NRPE 的远程主机之间有连通性:

    [user@nagios]# /usr/local/nagios/libexec/check_nrpe -H IP_ADDRESS_OF_REMOTE_HOST

    如果 NRPE v3.1.0-rc1 正常工作,则应回显 NRPE v3.1.0-rc1。

第 5 章 为 Ceph 配置 Nagios 插件

为红帽 Ceph 存储集群配置 Nagios 插件。

先决条件

  • 对 Ceph 监控节点的用户级别访问权限.
  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 访问 Nagios 核心服务器.

流程

  1. 登录监控服务器,再为 Nagios 创建 Ceph 密钥和密钥环。

    [user@mon]# ssh mon
    [user@mon]# cd /etc/ceph
    [user@mon]# ceph auth get-or-create client.nagios mon 'allow r' > client.nagios.keyring

    每个插件都需要身份验证。对包含插件的每个节点重复此步骤。

  2. check_ceph_health 插件添加命令:

    [user@mon]# vi /usr/local/nagios/etc/nrpe.cfg

    示例

    command[check_ceph_health]=/usr/lib/nagios/plugins/check_ceph_health --id nagios --keyring /etc/ceph/client.nagios.keyring

  3. 启用并重启 nrpe 服务:

    [user@mon]# systemctl enable nrpe
    [user@mon]# systemctl restart nrpe

    对适用于该节点的每个 Ceph 插件重复此步骤。

  4. 返回到 Nagios Core 服务器,并为 NRPE 插件定义 check_nrpe 命令:

    [user@nagios]# cd /usr/local/nagios/etc/objects
    [user@nagios]# vi commands.cfg
    define command{
     command_name check_nrpe
     command_line USER1/check_nrpe -H HOSTADDRESS -c ARG1
    }
  5. 在 Nagios Core 服务器上,编辑 节点的配置文件,再为 Ceph 插件添加服务。

    示例

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

    define service {
      use                   generic-service
      host_name             mon
      service_description   Ceph Health Check
      check_command         check_nrpe!check_ceph_health
    }
    注意

    check_command 设置在 Ceph 插件名称前面使用 check _nrpe!。这会告知 NRPE 在远程节点上执行 check_ceph_health 命令。

  6. 对适用于该节点的每个插件重复此步骤。
  7. 重启 Nagios Core 服务器:

    [user@nagios]# systemctl restart nagios
  8. 在继续其他配置之前,请确保插件正常工作。

    示例

    [user@mon]# /usr/lib/nagios/plugins/check_ceph_health --id nagios --keyring /etc/ceph/client.nagios.keyring

    注意

    check_ceph_health 插件执行与 ceph health 命令等效的命令。

其它资源