「冗長系とフェールオーバーのネットワーク監視」の版間の差分

提供: Nagios 3翻訳プロジェクト Wiki
移動: 案内検索
(シナリオ 1 - 監視の冗長化 (Scenario 1 - Redundant Monitoring))
(シナリオ 1 - 監視の冗長化 (Scenario 1 - Redundant Monitoring))
40行目: 40行目:
  
 
[[ファイル:Redundancy.png|left]]
 
[[ファイル:Redundancy.png|left]]
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
 
===初期プログラム設定 Initial Program Settings===
 
===初期プログラム設定 Initial Program Settings===
 
スレーブホスト(ホストE)は初期設定の[http://nagios.sourceforge.net/docs/3_0/configmain.html#enable_notifications enable_notifications]ディレクティブが無効になっているためホストやサービスの通知は行われません。 同様にスレーブホストは[http://nagios.sourceforge.net/docs/3_0/configmain.html#check_external_commands check_external_commands]ディレクティブを有効にしておきます。これらの設定は簡単でしょう・・・。  
 
スレーブホスト(ホストE)は初期設定の[http://nagios.sourceforge.net/docs/3_0/configmain.html#enable_notifications enable_notifications]ディレクティブが無効になっているためホストやサービスの通知は行われません。 同様にスレーブホストは[http://nagios.sourceforge.net/docs/3_0/configmain.html#check_external_commands check_external_commands]ディレクティブを有効にしておきます。これらの設定は簡単でしょう・・・。  
 
  
 
===初期設定 Initial Configuration===
 
===初期設定 Initial Configuration===
次に、マスターとスレーブの[オブジェクト設定概要]の違いを見る必要があります・・・。
+
次に、マスターとスレーブの[[オブジェクト設定概要]]の違いを見る必要があります・・・。
 +
 
 +
上のダイヤグラムの全ホストの監視をマスターホスト(ホストA)が行う設定と仮定します。スレーブホスト(ホストE)はマスターホストと同じ監視ホスト、サービスの設定を行う必要があり、それに加えて次の設定を行います・・・。
 +
 
 +
*TホストA(ホストEの設定ファイルホストAのホスト定義に、[[イベントハンドラ]]を設定する必要があります。このイベントハンドラの名前は handle-master-host-eventとします。
 +
*ホストEの設定ファイルにホストAのNagiosプロセスを監視するためのサービス定義を記述します。 これは check_nagiosプラグインをホストA上で動かすということと仮定します。 これはこのFAQ通りにやればよいでしょう。(アップデートしてください!).
 +
*ホストAのNagiosプロセスチェックのサービス定義に[[イベントハンドラ]]を設定します。このイベントハンドラの名前はhandle-master-proc-eventとしておきます。
 +
 
 +
 
 +
重要な点としては、ホストA(マスターホスト)はホストE(スレーブホスト)の状態は知らなくても良いということです。このシナリオでは単純にその必要はありません。 もちろん、ホストAからホストEの監視を行いたければやってもかまいませんが、冗長構成にはなんの影響も与えません…。
 +
 
 +
 
 +
===イベントハンドラコマンド定義 Event Handler Command Definitions===
 +
スレーブホスト上に次のようなイベントハンドラをコマンド定義に記述するためちょっと時間を割く必要があります。次に例を挙げます・・・。
 +
<pre>
 +
define command{
 +
 
 +
command_name handle-master-host-event
 +
 
 +
command_line /usr/local/nagios/libexec/eventhandlers/handle-master-host-event $HOSTSTATE$ $HOSTSTATETYPE$
 +
 
 +
}
 +
 
 +
 +
 
 +
define command{
 +
 
 +
command_name handle-master-proc-event
 +
 
 +
command_line /usr/local/nagios/libexec/eventhandlers/handle-master-proc-event $SERVICESTATE$ $SERVICESTATETYPE$
 +
 
 +
}
 +
</pre>
 +
 
 +
イベントハンドラスクリプトを/usr/local/nagios/libexec/eventhandlersディレクトリに置くという前提になっています。置き場所はどこでも好きなところで結構ですが、この例をちょっと修正する必要があります。
 +
 
 +
 
 +
===イベントハンドラスクリプト Event Handler Scripts===
 +
それでは、イベントハンドラスクリプトがどんなものか見ていきましょう・・・。
 +
 
 +
ホストイベントハンドラ (handle-master-host-event):
 +
 
 +
<pre>
 +
#!/bin/sh
 +
 
 +
 
 +
 
 +
# Only take action on hard host states...
 +
 
 +
case "$2" in
 +
 
 +
HARD)
 +
 
 +
case "$1" in
 +
 
 +
DOWN)
 +
 
 +
# The master host has gone down!
 +
 
 +
# We should now become the master host and take
 +
 
 +
# over the responsibilities of monitoring the
 +
 
 +
# network, so enable notifications...
 +
 
 +
/usr/local/nagios/libexec/eventhandlers/enable_notifications
 +
 
 +
;;
 +
 
 +
UP)
 +
 
 +
# The master host has recovered!
 +
 
 +
# We should go back to being the slave host and
 +
 
 +
# let the master host do the monitoring, so
 +
 
 +
# disable notifications...
 +
 
 +
/usr/local/nagios/libexec/eventhandlers/disable_notifications
 +
 
 +
;;
 +
 
 +
esac
 +
 
 +
;;
 +
 
 +
esac
 +
 
 +
exit 0
 +
</pre>
 +
 
 +
サービスイベントハンドラ (handle-master-proc-event):
 +
 
 +
<pre>
 +
#!/bin/sh
 +
 
 +
 
 +
 
 +
# Only take action on hard service states...
 +
 
 +
case "$2" in
 +
 
 +
HARD)
 +
 
 +
case "$1" in
 +
 
 +
CRITICAL)
 +
 
 +
# The master Nagios process is not running!
 +
 
 +
# We should now become the master host and
 +
 
 +
# take over the responsibility of monitoring
 +
 
 +
# the network, so enable notifications...
 +
 
 +
/usr/local/nagios/libexec/eventhandlers/enable_notifications
 +
 
 +
;;
 +
 
 +
WARNING)
 +
 
 +
UNKNOWN)
 +
 
 +
# The master Nagios process may or may not
 +
 
 +
# be running.. We won't do anything here, but
 +
 
 +
# to be on the safe side you may decide you
 +
 
 +
# want the slave host to become the master in
 +
 
 +
# these situations...
 +
 
 +
;;
 +
 
 +
OK)
 +
 
 +
# The master Nagios process running again!
 +
 
 +
# We should go back to being the slave host,
 +
 
 +
# so disable notifications...
 +
 
 +
/usr/local/nagios/libexec/eventhandlers/disable_notifications
 +
 
 +
;;
 +
 
 +
esac
 +
 
 +
;;
 +
 
 +
esac
 +
 
 +
exit 0
 +
 
 +
</pre>
 +
 
 +
 
 +
===

2010年9月3日 (金) 10:50時点における版

導入 Introduction

このセクションでは、様々なタイプのネットワークレイアウトで冗長化監視を実現するためのいくつかのシナリオについて述べます。冗長化ホストを使うことにより、Nagiosを実行する主要なホストがダウンしたりする場合や、ネットワークの一部に到達できなくなる場合に、あなたのネットワークを監視機能を維持することができます。

Note.gifもし、Nagiosの使用方法を学んでいるところであれば私が示した 前提条件になれるまでは、冗長化を試さないように提案します。 冗長化は、理解するのに比較的複雑な問題であり、適切に実行させるのも難しいのです

index

前提条件

サンプルスクリプト

シナリオ 1 - 監視の冗長化

シナリオ 2 - 監視のフェイルオーバー化

前提条件 (Prerequisites)

冗長化の実装について考える前に、以下をよく知っている必要があります...

  • ホストとサービスのためのイベントハンドラの実装
  • Nagiosへシェルスクリプト経由での外部コマンドの発行
  • nrpe アドオンまたは、他の方法を利用してリモートホスト・プラグインの実行
  • check nagios プラグインを利用してNagiosのプロセスチェック


サンプルスクリプト (Sample Scripts)

私がこのドキュメントの中で使用するサンプル・スクリプトは、Nagiosディストリビューションのサブディレクトリ内のeventhandlers/ですべて見つけることができます。 ただ、あなたのシステム上で実行させる為には、修正が必要でしょうが・・・。


シナリオ 1 - 監視の冗長化 (Scenario 1 - Redundant Monitoring)

導入 Introduction

この方法は、あなたのネットワーク上で冗長化監視を実装する簡単(かつ素朴な)方法であり、限られたケースの障害にのみ有効です。異なるネットワークセグメントを超える等のより優れた冗長化、より堅牢な冗長化を提供するためには、より複雑なセットアップが必要です。

目的 Goals

ここでの冗長化の目的は単純です。 「マスター」と「スレーブ」の両ホストは、ネットワーク上の同じホストとサービスを監視します。普通の状況の下では、「マスター」ホストだけが通知先に障害に関する"通知"を送るでしょう。私たちは「スレーブ」ホストが、次に挙げるような問題が発生した場合に通知先に通知する仕事を引き継いでNagiosを実行することを望みます。例えば、

  1. Nagiosを実行している"マスター"ホストがダウンしている・・・。または、・・・
  2. "マスター"上のNagiosプロセスが何かの理由でストップしている・・・、など


ネットワークレイアウトダイアグラム Network Layout Diagram

下記のダイアグラムは非常に単純なネットワークを示しています。このシナリオでは、ホストAおよびホストEがNagiosを実行しており図中のすべてのホストをモニターしている、ことを想定しています。ホストAは「マスター」ホスト、ホストEは「スレーブ」ホストと考えます。

Redundancy.png











初期プログラム設定 Initial Program Settings

スレーブホスト(ホストE)は初期設定のenable_notificationsディレクティブが無効になっているためホストやサービスの通知は行われません。 同様にスレーブホストはcheck_external_commandsディレクティブを有効にしておきます。これらの設定は簡単でしょう・・・。

初期設定 Initial Configuration

次に、マスターとスレーブのオブジェクト設定概要の違いを見る必要があります・・・。

上のダイヤグラムの全ホストの監視をマスターホスト(ホストA)が行う設定と仮定します。スレーブホスト(ホストE)はマスターホストと同じ監視ホスト、サービスの設定を行う必要があり、それに加えて次の設定を行います・・・。

  • TホストA(ホストEの設定ファイルホストAのホスト定義に、イベントハンドラを設定する必要があります。このイベントハンドラの名前は handle-master-host-eventとします。
  • ホストEの設定ファイルにホストAのNagiosプロセスを監視するためのサービス定義を記述します。 これは check_nagiosプラグインをホストA上で動かすということと仮定します。 これはこのFAQ通りにやればよいでしょう。(アップデートしてください!).
  • ホストAのNagiosプロセスチェックのサービス定義にイベントハンドラを設定します。このイベントハンドラの名前はhandle-master-proc-eventとしておきます。


重要な点としては、ホストA(マスターホスト)はホストE(スレーブホスト)の状態は知らなくても良いということです。このシナリオでは単純にその必要はありません。 もちろん、ホストAからホストEの監視を行いたければやってもかまいませんが、冗長構成にはなんの影響も与えません…。


イベントハンドラコマンド定義 Event Handler Command Definitions

スレーブホスト上に次のようなイベントハンドラをコマンド定義に記述するためちょっと時間を割く必要があります。次に例を挙げます・・・。

define command{

	command_name	handle-master-host-event

	command_line	/usr/local/nagios/libexec/eventhandlers/handle-master-host-event $HOSTSTATE$ $HOSTSTATETYPE$

	}

	

define command{

	command_name	handle-master-proc-event

	command_line	/usr/local/nagios/libexec/eventhandlers/handle-master-proc-event $SERVICESTATE$ $SERVICESTATETYPE$

	}

イベントハンドラスクリプトを/usr/local/nagios/libexec/eventhandlersディレクトリに置くという前提になっています。置き場所はどこでも好きなところで結構ですが、この例をちょっと修正する必要があります。


イベントハンドラスクリプト Event Handler Scripts

それでは、イベントハンドラスクリプトがどんなものか見ていきましょう・・・。

ホストイベントハンドラ (handle-master-host-event):

#!/bin/sh



# Only take action on hard host states...

case "$2" in

HARD)

	case "$1" in

	DOWN)

		# The master host has gone down!

		# We should now become the master host and take

		# over the responsibilities of monitoring the 

		# network, so enable notifications...

		/usr/local/nagios/libexec/eventhandlers/enable_notifications

		;;

	UP)

		# The master host has recovered!

		# We should go back to being the slave host and

		# let the master host do the monitoring, so 

		# disable notifications...

		/usr/local/nagios/libexec/eventhandlers/disable_notifications

		;;

	esac

	;;

esac

exit 0

サービスイベントハンドラ (handle-master-proc-event):

#!/bin/sh



# Only take action on hard service states...

case "$2" in

HARD)

	case "$1" in

	CRITICAL)

		# The master Nagios process is not running!

		# We should now become the master host and

		# take over the responsibility of monitoring

		# the network, so enable notifications...

		/usr/local/nagios/libexec/eventhandlers/enable_notifications

		;;

	WARNING)

	UNKNOWN)

		# The master Nagios process may or may not

		# be running.. We won't do anything here, but

		# to be on the safe side you may decide you 

		# want the slave host to become the master in

		# these situations...

		;;

	OK)

		# The master Nagios process running again!

		# We should go back to being the slave host, 

		# so disable notifications...

		/usr/local/nagios/libexec/eventhandlers/disable_notifications

		;;

	esac

	;;

esac

exit 0


=