Nagios を使用した Ceph の監視ガイド
Nagios Core を使用した Ceph の監視
概要
第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 へのアクセス。
- インターネットアクセス。
手順
前提条件をインストールします。
[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
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
最新バージョンの 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
./configure
を実行します。[user@nagios]# ./configure --with-command-group=nagcmd
Nagios Core ソースコードをコンパイルします。
[user@nagios]# make all
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
イベントハンドラーをコピーし、その所有権を変更します。
[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
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
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 サービスへのルートレベルのアクセス。
手順
サービスとして Nagios Core を追加し、有効にします。
[user@nagios]# chkconfig --add nagios [user@nagios]# chkconfig --level 35 nagios on
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 インターフェースのユーザー名およびパスワード
手順
Nagios を起動して実行し、Web ユーザーインターフェースにログインします。
http://IP_ADDRESS/nagios
Nagios Core は、ユーザー名とパスワードの入力を求めるプロンプトを表示します。
- デフォルトの 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 ノードへのユーザーレベルのアクセス。
手順
これらのパッケージをノードにインストールします。
[user@mon]# yum install openssl openssl-devel gcc make git
NRPE インストールには、Nagios ユーザーが必要です。したがって、最初にユーザーを作成します。
[user@mon]# useradd nagios [user@mon]# passwd 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
NRPE は通信に
xinetd
を使用します。NRPE モジュールをインストールする前にこれをインストールします。[user@mon]# yum install xinetd
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
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
-
/etc/services
ファイルを編集し、サービス文字列nrpe 5666/tcp
を追加します。 ポート
5666
を開き、NRPE との通信を許可します。[user@mon]# firewall-cmd --zone=public --add-port=5666/tcp [user@mon]# firewall-cmd --zone=public --add-port=5666/tcp --permanent
関連情報
- 詳細は、https://github.com/valerytschopp/ceph-nagios-plugins を参照してください。
3.2. Nagios Remote Plug-in Executor サービスの起動
Nagios Remote Plug-in Executor サービスを起動してデータを収集し、Nagios サーバーに報告します。
前提条件
- Ceph Monitor ノードへのユーザーレベルのアクセス
手順
xinetd
を有効、再起動、および再読み込みします。[user@mon]# systemctl enable xinetd [user@mon]# systemctl restart xinetd [user@mon]# systemctl reload xinetd
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 へのアクセス
手順
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 = }
Nagios Core サーバーの IP アドレスを
only_from
オプションに追加したら、xinetd
サービスを再起動します。[user@mon]# systemctl restart xinetd
Nagios サーバーの IP アドレスで NRPE 設定を編集します。
[user@mon]# vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,IP_ADDRESS_OF_NAGIOS_CORE_SERVER
allowed_hosts
設定に、Nagios Core サーバーの IP アドレスを追加します。次に、nrpe
を再起動します。[user@mon]# systemctl restart nrpe
インストールをテストします。
[user@host]# /usr/local/nagios/libexec/check_nrpe -H localhost
正しく機能している場合は、このチェックにより
NRPE v3.1.0-rc1
が出力されるはずです。
第4章 Nagios Core サーバーでのリモートノードの設定
Nagios Core サーバーを設定して、リモートノードを認識させます。
前提条件
- Nagios Core サーバー上のリモートノードへのユーザーレベルのアクセス。
- インターネットアクセス。
手順
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
リモートホストの設定を作成します。
[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.cfg
のmon.cfg
ファイルにcfg_file=
参照を追加します。[user@nagios]# vi /usr/local/nagios/etc/nagios.cfg
例
cfg_file=/usr/local/nagios/etc/objects/mon.cfg
Nagios サーバーを再起動します。
[user@nagios]# systemctl restart nagios
作成およびインストール手順が機能し、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 へのアクセス
手順
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
各プラグインには認証が必要です。プラグインが含まれる各ノードで、この手順を繰り返します。
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
nrpe
サービスを有効にして再起動します。[user@mon]# systemctl enable nrpe [user@mon]# systemctl restart nrpe
ノードに適用される各 Ceph プラグインに対して、この手順を繰り返します。
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 }
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 に指示します。- このノードに適用される各プラグインに対して、この手順を繰り返します。
Nagios Core サーバーを再起動します。
[user@nagios]# systemctl restart nagios
追加の設定を進める前に、このプラグインが機能していることを確認します。
例
[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 ページ を参照してください。