Red Hat Training

A Red Hat training course is available for Red Hat Ceph Storage

Nagios を使用した Red Hat Enterprise Linux 用の Ceph の監視

Red Hat Ceph Storage 3

Nagios Core を使用した Red Hat Enterprise Linux 用の Ceph の監視

概要

本ガイドでは、RHEL ベースの Ceph Storage クラスターを監視するように Nagios をインストールし、設定する方法を説明します。

第1章 はじめに

Nagios Core は、ホストを監視するためのオープンソースソリューションです。大規模な Ceph Storage クラスターは、クラスター内の各ホストを確認する Nagios Core や、基礎となるオペレーティングシステムの健全性や Ceph Storage Cluster デーモンの正常性など、分散監視システムを利用します。

Ceph と共に Nagios Core をデプロイするには、以下が必要です。

  • 実行中の Ceph クラスター。
  • 実行中の Nagios コアサーバー。

Nagios Core の代わりに、より機能が豊富な商用バージョンである Nagios XI を置き換えることもできます。

重要

Red Hat は、Nagios パッケージを提供しません。

重要

Red Hat は、弊社のテクノロジーパートナーと協力して、本書をお客様にサービスとして提供します。ただし、Red Hat はこの製品のサポートを提供しません。この製品の技術的なサポートが必要な場合は、Nagios にサポートを依頼してください。

第2章 Nagios Core のインストール

Nagios Core のインストールには、Nagios Core ソースコードをダウンロードし、Nagios Core インスタンスを実行するホストに設定、作成、およびインストールする必要があります。

以下のセクションでは、RHEL 7 以降のリリースのプロセスを説明します。

2.1. Nagios の前提条件のインストール

前提条件をインストールします。

[user@nagios]# yum install -y httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl openssl-devel wget unzip

httpd のポート 80 を開きます。

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

2.2. Nagios ユーザーおよびグループの作成

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

2.3. Nagios ソースコードおよびプラグインのダウンロード

最新バージョンの Nagios Core およびプラグインをダウンロードします。

[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

2.4. Nagios Core の作りとインストール

Nagios Core を作成およびインストールするには、最初に ./configure を実行します。

[user@nagios]# ./configure --with-command-group=nagcmd

./configure を実行した後、Nagios Core ソースコードをコンパイルします。

[user@nagios]# make all

Nagios Core を作成したら、インストールします。

[user@nagios]# make install
[user@nagios]# make install-init
[user@nagios]# make install-config
[user@nagios]# make install-commandmode
[user@nagios]# make install-webconf

イベントハンドラーをコピーし、その所有権を変更します。

[user@nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
[user@nagios]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

最後に、プリフライトチェックを実行します。

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

2.5. Nagios Core プラグインの作成およびインストール

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

2.6. デフォルトの Nagios Core ユーザーの作成

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 ファイルも変更します。

2.7. Nagios の起動

サービスとして Nagios Core を追加し、有効にします。次に、Nagios Core デーモンと Apache を起動します。

[user@nagios]# chkconfig --add nagios
[user@nagios]# chkconfig --level 35 nagios on
[user@nagios]# systemctl start nagios
[user@nagios]# systemctl enable httpd
[user@nagios]# systemctl start httpd

2.8. Nagios Core へのログイン

Nagios を起動して実行し、Web ユーザーインターフェースにログインします。

http://<ip-address>/nagios

Nagios Core は、ユーザー名とパスワードの入力を求めるプロンプトを表示します。デフォルトの Nagios Core ユーザーのログインおよびパスワードを入力します。

第3章 Nagios Remote Plug-in Executor(NRPE)のインストール

Ceph Storage クラスターホストを監視するには、Nagios プラグイン、Ceph プラグイン、および NRPE アドオンを各 Ceph クラスターの各ホストにインストールします。

本セクションでは、ホスト名が mon の Ceph monitor ノードに NRPE を追加します。監視する必要のある全 Ceph ノードで残りの手順を繰り返します。

3.1. インストールの前提条件

NRPE には OpenSSL が必要です。最初に以下のライブラリーをインストールします。

以下のコマンドを実行します。

[user@host]# yum install openssl openssl-devel gcc make git

3.2. Nagios ユーザーの作成

NRPE インストールには、Nagios ユーザーが必要です。したがって、最初にユーザーを作成します。

[user@mon]# useradd nagios
[user@mon]# passwd nagios

3.3. Nagios プラグインのダウンロード、製造、およびインストール

最新バージョンの 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

3.4. Nagios Ceph プラグインのダウンロード、製造、およびインストール

Ceph プラグインの最新バージョンをダウンロードします。詳細は、https://github.com/valerytschopp/ceph-nagios-plugins を参照してください。

[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

3.5. xinetd のインストール

NRPE は通信に xinetd を使用します。NRPE モジュールをインストールする前にこれをインストールします。以下のコマンドを実行します。

[user@mon]# yum install xinetd

3.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

次に、nrpe 5666/tcp/etc/services ファイルに追加します。

3.7. xinetd を有効にし、再起動し、再読み込みします。

[user@mon]# systemctl enable xinetd
[user@mon]# systemctl restart xinetd
[user@mon]# systemctl reload xinetd

3.8. NRPE の有効化および起動

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

3.9. Open Port 5666

ポート 5666 を開き、NRPE との通信を許可します。

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

3.10. Nagios Core Server の IP アドレスの追加

Nagios Core サーバーがリモートマシンで NRPE にアクセスするには、リモートマシンの xinetd と NRPE の設定を Nagios Core サーバーの IP アドレスで更新する必要があります。

Nagios サーバーの IP アドレスで xinetd 設定を編集します。

[user@mon]# vim /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>
    log_on_success  =
}

Nagios Core サーバーの IP アドレスを only_from 設定に追加します。次に、xinetd を再起動します。

[user@mon]# systemctl restart xinetd

Nagios サーバーの IP アドレスで NRPE 設定を編集します。

[user@mon]# vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,<ip-address-of-nagios-core>

allowed_hosts 設定に、Nagios Core サーバーの IP アドレスを追加します。次に、nrpe を再起動します。

[user@mon]# systemctl restart nrpe

3.11. インストールのテスト

make および install 手順が正常に機能していることを確認します。

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

正しく機能している場合は、このチェックにより NRPE v3.1.0-rc1 が出力されるはずです。

第4章 Nagios Core Server の設定

Ceph ホストで NRPE を設定した後、ホストを認識して監視するように Nagios Core Server を設定します。

4.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

4.2. 接続性を確保するためのチェック

作成手順とインストール手順が機能し、Nagios Core サーバーと NRPE が含まれるリモートホストとの間に接続されていることを確認します。

[user@nagios]# /usr/local/nagios/libexec/check_nrpe -H <IP-address-of-remote-host>

正しく機能している場合は、NRPE v3.1.0-rc1 が出力されるはずです。

4.3. リモートホストの設定の作成

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

localhost を、リモートホストのホスト名に置き換え、ループバック IP アドレスを、リモートホストの IP アドレスに置き換えます。最後に、ホストグループの定義を削除またはコメントアウトします。

ファイルの所有権を nagios に変更します。

[user@nagios]# chown nagios:nagios mon.cfg

/usr/local/nagios/etc/nagios.cfgmon.cfg ファイルに cfg_file= 参照を追加します。

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

以下に例を示します。

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

次に、Nagios サーバーを再起動します。

[user@nagios]# systemctl restart nagios

第5章 Ceph プラグインの設定

https://github.com/valerytschopp/ceph-nagios-plugins には、いくつかのオープンソースの Ceph プラグインが用意されています。使用可能なオプションには、以下のものがあります。

  • check_ceph_df: このプラグインは、クラスター全体または個々のプールに対して ceph df に関連するメッセージを出力します。このプラグインは Ceph monitor ホストでのみ実行する必要があります。個々のプールを監視するように複数のインスタンスを設定できます。
  • check_ceph_health: このプラグインは、ceph health の結果を出力します。このプラグインは Ceph monitor ホストでのみ実行する必要があります。
  • check_ceph_mon: このプラグインは単一のモニターをチェックし、モニターが稼働している場合は OK を返します。そうでない場合は WARN が返されます。このプラグインは Ceph monitor ホストでのみ実行する必要があります。
  • check_ceph_osd: このプラグインは OSD ホストまたは単一の OSD をチェックし、OSD が稼働している場合は OK または WARN がダウンしている場合は WARN を返します。このプラグインは Ceph OSD ホストでのみ実行する必要があります。
  • check_ceph_rgw: このプラグインは単一の Ceph Object Gateway をチェックし、OK およびバケットとデータの使用状況が up および running の場合はデータの使用状況を返します(down または missing の場合は WARN )。このプラグインは Ceph Object Gateway ホストでのみ実行する必要があります。
  • check_ceph_mds: このプラグインは単一のメタデータサーバーを確認し、稼働している場合は OK を返します。Laggy の場合は WARN、ダウンまたは見つからない場合は WARN を返します。このプラグインは、Ceph メタデータサーバーホストでのみ実行する必要があります。これらのプラグインは適切な Ceph ホストにインストールされます。以下のセクションでは、モニターホストで ceph health プラグインを設定する方法を説明します。

5.1. キーリングおよびキーの作成

monitor サーバーにログインし、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

各プラグインには認証が必要です。プラグインが含まれる各ノードで、この手順を繰り返します。

5.2. Ceph プラグインのインストールのテスト

追加の設定を進める前に、このプラグインが機能していることを確認します。以下に例を示します。

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

check_ceph_health プラグインは、以下と同等です。

[user@mon]# ceph health

5.3. Ceph プラグインのコマンドの追加

check_ceph_health プラグインのコマンドを追加します。

[user@mon]# vim /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

NRPE を保存して再起動します。

[user@mon]# systemctl restart nrpe

ホストに適用される各 Ceph プラグインに対して、この手順を繰り返します。使用方法については、https://github.com/valerytschopp/ceph-nagios-plugins を参照してください。

5.4. check_nrpe コマンドの定義

Nagios サーバーに戻り、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.5. プラグイン用のサービスの定義

Nagios サーバーで、ホストの設定ファイルを編集し、Ceph プラグインのサービスを追加します。以下に例を示します。

[user@nagios]# vim /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!' を使用することに注意してください。これにより、リモートホストで check_ceph_health コマンドを実行するように NRPE に指示します。

このホストに適用される各プラグインに対して、この手順を繰り返します。

次に、Nagios サーバーを再起動します。

[user@nagios]# systemctl restart nagios

第6章 概要

前述の手順を完了したら、Nagios Web ユーザーインターフェースに戻り、「ホスト」リンクをクリックします。ホストがホストの一覧に表示されます。ホストをクリックして、詳細情報を表示します。View Status Detail ハイパーリンクをクリックします。実行するチェックが表示されるはずです。インスタント例では、Ceph クラスターのステータス情報が含まれる Ceph Health Check サービスが必要です。