Nagios を使用した Ceph の監視ガイド

Red Hat Ceph Storage 4

Nagios Core を使用した Ceph の監視

概要

本ガイドでは、Red Hat Ceph Storage クラスターを監視するように Nagios をインストールおよび設定する方法を説明します。
Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。まずは、マスター (master)、スレーブ (slave)、ブラックリスト (blacklist)、ホワイトリスト (whitelist) の 4 つの用語の置き換えから始めます。この取り組みは膨大な作業を要するため、今後の複数のリリースで段階的に用語の置き換えを実施して参ります。詳細は、弊社の CTO、Chris Wright のメッセージを参照してください。

第1章 Nagios および Ceph

Nagios Core は、ノードを監視するためのオープンソースソリューションです。大規模な Red Hat Ceph Storage クラスターは、Nagios Core などの分散監視システムの恩恵を受けています。Nagios Core は、基本となるオペレーティングシステムの健全性や Red Hat Ceph Storage クラスターデーモンの正常性など、クラスター内の各ノードをチェックします。

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

  • 稼働中の Red Hat Ceph Storage クラスター

Nagios Core の代わりに、より機能豊富な商用版である Nagios XI を代用することもできます。

重要

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

重要

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

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

ストレージ管理者は、Nagios Core ソースコードをダウンロードし、その後に Nagios Core インスタンスを実行するノードに設定、作成、およびインストールすることで、Nagios Core をインストールできます。

2.1. ソースからの Nagios Core サーバーのインストールおよび設定

Nagios Core ソフトウェアには Red Hat Enterprise Linux パッケージがないため、ソースから Nagios Core ソフトウェアをコンパイルする必要があります。

前提条件

  • 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 およびプラグインをダウンロードします。

    [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. ./configure を実行します。

    [user@nagios]# ./configure --with-command-group=nagcmd
  6. Nagios Core ソースコードをコンパイルします。

    [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. プレフライトチェックを実行します。

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

2.2. Nagios Core サービスの起動

Nagios Core サービスを起動して、Red Hat Ceph Storage クラスターの正常性を監視します。

前提条件

  • Nagios Core サービスへのルートレベルのアクセス。

手順

  1. サービスとして Nagios Core を追加し、有効にします。

    [user@nagios]# chkconfig --add nagios
    [user@nagios]# chkconfig --level 35 nagios on
  2. Nagios Core デーモンおよび Apache を起動します。

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

2.3. Nagios Core サーバーへのログイン

Red Hat Ceph Storage クラスターの正常性ステータスを表示するには、Nagios Core サーバーにログインします。

前提条件

  • Nagios Web インターフェースのユーザー名およびパスワード

手順

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

    http://IP_ADDRESS/nagios

    Nagios Core は、ユーザー名とパスワードの入力を求めるプロンプトを表示します。

  2. デフォルトの Nagios Core ユーザーのログインおよびパスワードを入力します。

第3章 Nagios リモートプラグインエグゼキューターのインストール

ストレージ管理者は、Ceph ストレージクラスターノードを監視して、Nagios プラグイン、Ceph プラグイン、および各 Ceph ノードへの Nagios リモートプラグインエグゼキューター (NRPE) アドオンをインストールできます。

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

3.1. Nagios Remote Plug-In Executor のインストールおよび設定

Nagios Remote Plug-in Executor (NPRE) をインストールし、Nagios Core サーバーと通信するように設定します。

前提条件

  • OpenSSL へのアクセス。
  • Ceph Monitor ノードへのユーザーレベルのアクセス。

手順

  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 Remote Plug-in Executor サービスの起動

Nagios Remote Plug-in Executor サービスを起動してデータを収集し、Nagios サーバーに報告します。

前提条件

  • Ceph Monitor ノードへのユーザーレベルのアクセス

手順

  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. リモートノードへの 1 つの Nagios Core サーバーアクセスの設定

Nagios Core サーバーがリモートマシン上で Nagios Remote Plugin Executor (NPRE) にアクセスするためには、リモートマシンの xinetd と NRPE の設定を Nagios Core サーバーの IP アドレスで更新しなければなりません。

前提条件

  • Nagios Core サーバーへのユーザーレベルのアクセス。
  • インターネットアクセス。
  • Nagios Remote Plugin Executor へのアクセス

手順

  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. allowed_hosts 設定に、Nagios Core サーバーの IP アドレスを追加します。次に、nrpe を再起動します。

    [user@mon]# systemctl restart nrpe
  5. インストールをテストします。

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

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

第4章 Nagios Core サーバーでのリモートノードの設定

Nagios Core サーバーを設定して、リモートノードを認識させます。

前提条件

  • 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.cfgmon.cfg ファイルに cfg_file= 参照を追加します。

    [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 が出力されるはずです。

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

Red Hat Ceph Storage クラスターの場合には、Nagios プラグインを設定します。

前提条件

  • Ceph Monitor ノードへのユーザーレベルのアクセス。
  • 稼働中の Red Hat Ceph Storage クラスター
  • Nagios Core Server へのアクセス

手順

  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

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

  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! を使用します。これにより、リモートノードで check_ceph_health コマンドを実行するように NRPE に指示します。

  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 コマンドと同等のコマンドを実行します。

関連情報

  • 使用方法は、Ceph Nagios プラグインの Web ページ を参照してください。