ja:documentation:pandorafms:monitoring:08_snmp_traps_monitoring

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
ja:documentation:pandorafms:monitoring:08_snmp_traps_monitoring [2024/02/21 08:51] junichija:documentation:pandorafms:monitoring:08_snmp_traps_monitoring [2024/05/17 23:11] (現在) – [複雑な SNMP トラップへのアラート関連付け] junichi
行 5: 行 5:
  
 ===== 概要 ===== ===== 概要 =====
 +
 スイッチ、ルータ、サーバ、プリンタ、AP など、SNMP をサポートするネットワークデバイスは、インターフェイスの障害、CPU またはネットワークの負荷が高すぎたり、UPS の状態が変化したり、ディスクの障害が発生したときなどに、アラーム(SNMP トラップ)を送信することができます。各デバイスには、可能なイベントの独自のコレクションがあり、これは MIB と呼ばれます。この場合、デバイスのポーリングに使用する MIB とは異なります。 スイッチ、ルータ、サーバ、プリンタ、AP など、SNMP をサポートするネットワークデバイスは、インターフェイスの障害、CPU またはネットワークの負荷が高すぎたり、UPS の状態が変化したり、ディスクの障害が発生したときなどに、アラーム(SNMP トラップ)を送信することができます。各デバイスには、可能なイベントの独自のコレクションがあり、これは MIB と呼ばれます。この場合、デバイスのポーリングに使用する MIB とは異なります。
  
行 12: 行 13:
 トラップは、デバイスにて何かが発生した場合に非同期で送信されます。Pandora FMS には、モニタリング対象から送られてくるトラップを表示するトラップ受信コンソールがあり、また、トラップに対してアラートを設定することができます。SNMP トラップは、Pandora FMS の起動時に起動される、OS の SNMP サーバデーモンで受け取ります。このサーバは通常ログファイルを以下に保存します。 トラップは、デバイスにて何かが発生した場合に非同期で送信されます。Pandora FMS には、モニタリング対象から送られてくるトラップを表示するトラップ受信コンソールがあり、また、トラップに対してアラートを設定することができます。SNMP トラップは、Pandora FMS の起動時に起動される、OS の SNMP サーバデーモンで受け取ります。このサーバは通常ログファイルを以下に保存します。
  
-  /var/log/pandora /pandora_snmptrap.log+<file>
  
-トラップは、常に生データで受信されます。つまり、数値 OID で受信します。ただし、OS に MIB ファイルがインストールされている場合は、文字に変換することができます。エンタープライズ版の Pandora FMS の SNMP コンソールでは、トラップをより認識しやすいように、OID を数値や文字で表したり、何らかの説明をつけたりする ("インターフェースダウン" など) ためのルールを設定できます。このようなルールを自動的に定義するために、Pandora FMS はトラップのベンダ MIB を読み込むことができます。ビデオチュートリアル [[https://www.youtube.com/watch?v = Oaxf7vi7eME|"Loading MIBs in Pandora FMS"]] もご覧ください。+/var/log/pandora/pandora_snmptrap.log
  
-最初に、SNMP コンソールを有効化するためには /etc/pandora/pandora_server.conf 内の以下のパラメータを編集する必要があります。+</file>
  
-  snmpconsole 1+The Pandora FMS SNMP console allows you to create rules to rename numerical OIDs to alphanumeric OIDs or simple descriptive text strings, so that it is more intuitive to work with SNMP traps. Pandora FMS also allows you to load trap MIBs from any manufacturer to automatically define those rules.
  
-トラップ文字列変換したい場合(変数のバインディングまたは Enterprise 文字列のいずれか)は、ションも有効化しま(Enterpriase 版み)+Pandora FMS SNMP コンソール使用すると、値 OID 名前を英数字 OID または単純な説明テキスト文字列に変更するルールを作成できるため、SNMP トラップをより直感的に操作できるようになります。 Pandora FMS では、任意メーカーのトラップ MIB をロードして、それらのルールを自動的に定義することできます。 
 + 
 +In order to work with SNMP traps, first modify the following parameter in ''/etc/pandora/pandora_server.conf'' to enable the SNMP Console: 
 + 
 +最初に、SNMP コンソールを有効化するためには ''/etc/pandora/pandora_server.conf''以下のパラメータを編集する必要があります
  
 <code> <code>
 +snmpconsole 1
 +
 +</code>
 +
 +So that the traps SNMP appear translated (whether the variable links or the Enterprise SNMP chain) the following parameters must be activated:
 +
 +トラップを文字列変換したい場合(変数のバインディングまたは Enterprise 文字列のいずれか)は、次のオプションも有効化します。
 +
 +<code>
 +
  translate_variable_bindings 1  translate_variable_bindings 1
  translate_enterprise_strings 1  translate_enterprise_strings 1
 +
 </code> </code>
  
-また、/etc/snmp/snmptrapd.conf ファイルを必要なパラメータで設定する必要があります。 +The ''/etc/snmp/snmptrapd.conf'' file must also be configured with the necessary parameters, for example: 
-例:+ 
 +また、''/etc/snmp/snmptrapd.conf'' ファイルを必要なパラメータで設定する必要があります。例:
  
 <code> <code>
  authCommunity log public  authCommunity log public
  disableAuthorization yes  disableAuthorization yes
 +
 </code> </code>
  
-この設定では、コミュニティ "public"、認証無しでトラップを受け付けます。+With this configuration, traps will be created for the **public** community and will not require authorization. 
 + 
 +この設定では、コミュニティ **public**、認証無しでトラップを受け付けます。
  
 ==== SNMPv3 ==== ==== SNMPv3 ====
行 342: 行 362:
 アップロードが完了すると、システムはそれをトラップライブラリに取り込みます。 アップロードが完了すると、システムはそれをトラップライブラリに取り込みます。
  
-===== 複雑な SNMP トラップのアラート関連付け =====+===== SNMP トラップの Pandora FMS アラートへの関連付け =====
  
-This is an Enterprise feature and is configured in **Management** → **Setup** → **Setup** → **Enterprise** → **Forward SNMP traps to an agent (if it exists)**.+Menu <wrap :en>**Management → Setup → Setup → Enterprise → Forward SNMP traps to an agent (if it exists)**</wrap>.
  
-これは Enterprise 版の機能であり、**管理(Management)** → **セットアップ(Setup)** → **セットアップ(Setup)** → **Enterprise** → **SNMP トラップをエージェント (存在する場合) に転送(Forward SNMP traps to an agent (if it exists)** で設定します+**管理(Management)** → **セットアップ(Setup)** → **セットアップ(Setup)** → **Enterprise** → **SNMP トラップをエージェント (存在する場合) に転送(Forward SNMP traps to an agent (if it exists)**。
  
 <WRAP center round info 60%> <WRAP center round info 60%>
行 406: 行 426:
 With Pandora FMS it is possible to enable forwarding of SNMP traps to an external host by enabling the [[:en:documentation:pandorafms:installation:04_configuration#snmp_forward_trap|snmp_forward_trap]] in the token in the Pandora configuration file. With Pandora FMS it is possible to enable forwarding of SNMP traps to an external host by enabling the [[:en:documentation:pandorafms:installation:04_configuration#snmp_forward_trap|snmp_forward_trap]] in the token in the Pandora configuration file.
  
-Pandora FMS では、Pandora 設定ファイルのトークン [[:ja:documentation:pandorafms:installation:04_configuration#snmp_forward_trap|snmp_forward_trap]] を有効にすること、外部ホストへの SNMP トラップの転送を有効にすることができます。+Pandora FMS では、Pandora サーバの設定ファイル[[:ja:documentation:pandorafms:installation:04_configuration#snmp_forward_trap|snmp_forward_trap]]トークンを有効にすることによりSNMP trap を外部ホストへ転送することができます。
  
  
  
-===== SNMP trap 転送 ===== 
- 
-Pandora FMS では、Pandora サーバの設定ファイルで[[:ja:documentation:02_installation:04_configuration#snmp_forward_trap|snmp_forward_trap]]トークンを有効にすることにより、SNMP trap を外部のホストへ転送することができます。 
  
  
行 479: 行 496:
 何らかの理由により、snmptrapd デーモンを Pandora FMS から独立して管理したい場合(Pandora FMS デーモンとは独立して停止・起動をしたい場合)は、いくつか考慮すべきことがあります。 何らかの理由により、snmptrapd デーモンを Pandora FMS から独立して管理したい場合(Pandora FMS デーモンとは独立して停止・起動をしたい場合)は、いくつか考慮すべきことがあります。
  
-1. The ''snmpconsole'' [[:en:documentation:02_installation:04_configuration#snmpconsole|parameter must be active]] for Pandora FMS server.+1. You must also activate [[:en:documentation:pandorafms:installation:04_configuration#snmpconsole|the]] ''snmpconsole'' parameter on the Pandora FMS server.
  
-1. Pandora FMS サーバにおいて ''snmpconsole'' [[:ja:documentation:02_installation:04_configuration#snmpconsole|パラメータを有効化する必要があります]]。+1. Pandora FMS サーバにおいて ''snmpconsole'' [[:ja:documentation:pandorafms:installation:04_configuration#snmpconsole|パラメータを有効化する必要があります]]。
  
-2. Pandora FMS サーバで設定されるログは、snmptrapd を独立して管理する場合でも同じでなければいけません。+2. The logs configured on the Pandora FMS server must be the same as those generated in the independent call to **snmptrapd** 
 + 
 +2. Pandora FMS サーバで設定されるログは、**snmptrapd** を独立して管理する場合でも同じでなければいけません。 
 + 
 +3. The call to **snmptrapd** must have a specific format **since the call to the standard system daemon is invalid**. The call should be like this (the ''-A'' parameter is especially important): 
 + 
 +3. **snmptrapd** の呼び出しは特定のフォーマットである必要があり、**標準的なシステムからの呼び出しは利用できません** 。呼び出しは次のようにする必要があります(パラメータ ''-A'' はとても重要です)
  
-3. snmptrap の呼び出しは特定のフォーマットである必要があり、**標準的なシステムからの呼び出しは利用できません** 。呼び出しは次のようにする必要があります(パラメータ -A はとても重要です)。 
 <code> <code>
  
行 491: 行 513:
  
 </code> </code>
 +
 +4. You must configure the token in the server configuration file:
  
 4. snmptrapd トークンが、Pandora FMS 設定ファイル内に設定されている必要があります。 4. snmptrapd トークンが、Pandora FMS 設定ファイル内に設定されている必要があります。
行 501: 行 525:
 5. この機能を有効化したら、次の手順を実施する必要があります。 5. この機能を有効化したら、次の手順を実施する必要があります。
  
-  * /etc/pandora/pandora_server.conf の設定を変更+   * Change the configuration in ''/etc/pandora/pandora_server.conf''
 +   * Stop the Pandora FMS server. 
 +   * End the **snmptrapd** process. 
 +   * Start up**snmptrapd** manually (with the format indicated above). 
 +   * Start the Pandora FMS server. 
 + 
 +  * ''/etc/pandora/pandora_server.conf'' の設定を変更
   * Pandora FMS サーバを停止   * Pandora FMS サーバを停止
-  * snmptrapd プロセスが動作していないことを確認 (もし動いていたら、停止するまで待つか kill します) +  * **snmptrapd** プロセスが動作していないことを確認 (もし動いていたら、停止するまで待つか kill します) 
-  * snmptrapd を手動で起動 (上記のフォーマットにて)+  * **snmptrapd** を手動で起動 (上記のフォーマットにて)
   * Pandora FMS サーバを起動   * Pandora FMS サーバを起動
- 
  
 ==== トラップログファイルの管理 ==== ==== トラップログファイルの管理 ====
-//pandora_snmptrap.log.index// および //pandora_snmptrap.log// が変更されていなければ、snmptrapd プロセスは、pandora サーバプロセスの停止および起動に依存せず、停止および起動することができます。これらのファイルに変更が加わっている場合は、pandora サーバの再起動が必要です。トラップのログファイルを外部でローテートする必要がある場合は、前述の 2つのファイルを削除したあとに pandora サーバを再起動する必要があります。+ 
 +The snmptrapd process can be stopped and started without the need to stop and start the Pandora FMS server process, as long as the files ''pandora_snmptrap.log.index'' and ''pandora_snmptrap.log'' are not modified. If these files are modified, it is necessary to restart the Pandora FMS server. If you need to externally rotate the trap log, you must restart the Pandora FMS server after deleting the aforementioned files. 
 + 
 +''pandora_snmptrap.log.index'' および ''pandora_snmptrap.log'' が変更されていなければ、snmptrapd プロセスは、pandora サーバプロセスの停止および起動に依存せず、停止および起動することができます。これらのファイルに変更が加わっている場合は、pandora サーバの再起動が必要です。トラップのログファイルを外部でローテートする必要がある場合は、前述の 2つのファイルを削除したあとに pandora サーバを再起動する必要があります。
  
 ===== SNMP トラップバッファリング ===== ===== SNMP トラップバッファリング =====
  
-SNMPトラップが信頼できない接続を介して外部マネージャに送信されると、情報が失われます。Pandora FMS では、トラップをローカルの //snmptrapd// からの転送ではなく、信頼できる方法で Pandora FMS サーバに転送することができます+<WRAP center round important 60%> 
 + 
 +It is more efficient for the SNMP console to directly process traps from the **snmptrapd** log file. This configuration is recommended only if reliability or direct connectivity is a concern. 
 + 
 +</WRAP> 
 + 
 +<WRAP center round important 60%> 
 + 
 +SNMP コンソールが **snmptrapd** ログファイルからトラップを直接処理する方効率的です。 この設定は、信頼性または直接接続に何らかの懸念がある場合にのみ推奨されます。 
 + 
 +</WRAP> 
 + 
 +If SNMP traps are sent to an external manager over an unreliable connection, some information will be lost. Pandora FMS allows you to instead forward traps from a local **snmptrapd** to your Pandora FMS server in a reliable way. 
 + 
 +SNMP トラップが信頼性の低い接続を介して外部マネージャに送信されると、一部の情報が失われます。 Pandora FMS では、ローカル **snmptrapd** からトラップを信頼できる方法で Pandora FMS サーバに転送できます。 
 + 
 +**Prerequisites**: 
 + 
 +**前提条件**: 
 + 
 +   * A local **snmptrapd** that is receiving traps. 
 +   * A local Pandora FMS agent. 
 +   * An installation of Pandora FMS. 
 + 
 +   * ローカルの **snmptrapd** がトラップを受信すること。 
 +   * ローカルの Pandora FMS エージェントあること。 
 +   * Pandora FMS がインストールされていること 
 + 
 + 
  
 ==== アーキテクチャ ==== ==== アーキテクチャ ====
行 525: 行 586:
   * SNMP コンソールは、プレーンテキストファイルからトラップを処理します。   * SNMP コンソールは、プレーンテキストファイルからトラップを処理します。
  
-<WRAP center round important 60%> 
-SNMPコンソールが //snmptrapd// のログファイルから直接トラップを処理する方が効率的です。この設定は、直接の接続や信頼性に不安がある場合にのみ利用します。 
-</WRAP> 
  
-==== 前提条件 ==== 
  
-  * ローカルの //snmptrapd// がトラップを受信すること。 
-  * ローカルの Pandora FMS エージェントがあること。 
-  * Pandora FMS がインストールされていること。 
  
 ==== 設定 ==== ==== 設定 ====
行 573: 行 627:
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-//snmp_extlog// は、Pandora FMS サーバ書き込み可能な任意のファイルです(同様に ///etc/pandora/pandora_agent.conf// で定義されてい)//snmp_logfile// とは異なります。+ 
 +**snmp_extlog** には、Pandora FMS サーバ書き込むことができる任意のファイルを指定きまが、**snmp_logfile** (''/etc/pandora/pandora_agent.conf'' 定義されています) とは異なるものである必要があります。 
 </WRAP> </WRAP>
  
 ===== トラップジェネレータ ===== ===== トラップジェネレータ =====
  
-このツールは、SNMP コンソールから参照できるトラップを生成します。+This tool allows you to generate custom SNMP traps that you can later view in the SNMP console. It is accessed through the menu **Operation** → **SNMP** → **SNMP trap generator**.
  
-{{  :wiki:generador_de_traps.png  }}+このツールを使用すると、後で SNMP コンソールで表示できるカスタム SNMP トラップを生成できます。 これには、メニュー **操作(Operation)** → **SNMP** → **SNMP トラップジェネレータ(SNMP trap generator)** からアクセスできます。
  
 +In **SNMP Type** choose an SNMP type from the following options:
  
-トラップジェネレーを正しく設定するには、次のフィールド入力する必要があります。+**SNMP イプ(SNMP Type)** で、次のオプションから SNMP タイプ選択します。
  
-**ホストアドレス(Host Address)**+   * **Cold Start**: Indicates that the agent has been started or restarted. 
 +   * **Warm Start**: Indicates that the agent configuration has been modified. 
 +   * **Link down**: Indicates that the communication interface is out of service (inactive)
 +   * **Link up**: Indicates that a communication interface has been activated. 
 +   * **Authentication failure**: Indicates that the agent received a request from an unauthorized (community controlled) NMS. 
 +   * **EGP neighbor loss**: Indicates that on systems where routers use the EGP protocol, a nearby host is out of service. 
 +   * **Enterprise**: This category contains all new SNMP traps, including those from vendors.
  
-トラップ送信先 IP アドレス。 +   * **Cold Start**: エージェントが開始または再開されたことを意味します。 
- +   * **Warm Start**: エージェント設定が変更されたことを意味します。 
-**コミュニティ(Community)** +   * **Link down**: 通信インタフェースが利用できない状態になった(無効化)ことを意味します。 
- +   * **Linu up**: 通信インタフェースが利用できる状態になったことを意味します。 
-トラップジェネレータでアクセスするときの SNMP コミュニティ。 +   * **Authentication failure**: エージェントが(コミュニティによって)認証できない NMS を受信したことを意味します。 
- +   * **EGP neighbor loss**: ルータが EGP プロトコルを使用しているシステムで、近くのホストが利用できない状態になったことを示します。 
-**エンタープライズ文字列(Enterprise String)** +   * **Enterprise**: ベンダトラップを含む、すべての新規トラップです。
- +
-トラップの OID です。例: 1.3.6.1.2.1.2.2.1.8 +
- +
-**値(Value)** +
- +
-トラップで送信するデータであり、値です。 +
- +
-**SNMP エージェント(SNMP Agent)** +
- +
-トラップをシミュレートするエージェントです。 +
- +
-**SNMP タイプ (SNMP Type)** +
- +
-以下から SNMP タイプを選択します。 +
- +
-    * **Cold Start**: エージェントが開始または再開されたことを意味します。 +
-    * **Warm Start**: エージェント設定が変更されたことを意味します。 +
-    * **Link down**: 通信インタフェースが利用できない状態になった(無効化)ことを意味します。 +
-    * **Linu up**: 通信インタフェースが利用できる状態になったことを意味します。 +
-    * **Authentication failure**: エージェントが(コミュニティによって)認証できない NMS を受信したことを意味します。 +
-    * **EGP neighbor loss**: ルータが EGP プロトコルを使用しているシステムで、近くのホストが利用できない状態になったことを示します。 +
-    * **Enterprise**: ベンダトラップを含む、すべての新規トラップです。+
  
 [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]]
行 648: 行 689:
  
 ほかには、エージェントのモジュールに、トラップを関連付ける手段もあります。例えば、トラップ受信で何らかのログファイルに "1" を書くようにし、それを読むモジュールを定義します。この方法により、想定したトラップを受信したときにモジュールの状態が変化するようになり、トラップの受信と関連付けることができます。 ほかには、エージェントのモジュールに、トラップを関連付ける手段もあります。例えば、トラップ受信で何らかのログファイルに "1" を書くようにし、それを読むモジュールを定義します。この方法により、想定したトラップを受信したときにモジュールの状態が変化するようになり、トラップの受信と関連付けることができます。
 +
 +===== (OBSOLETE) 外部 SNMP トラップハンドラ =====
 +
 +SNMP コンソールは、トラップを取得する目的のためだけに作られています。トラップは個々のアイテムとしてのみ処理されます。 1つのトラップは多くの情報を含むことができます。
 +場合によっては、実行できる唯一の監視がトラップに基づいている場合があります。 そのために、取得した 1つのトラップの情報をプラグインとして動作する外部スクリプトで後処理することができます。
 +
 +トラップの詳細データを処理するために、アラートの結果としてトラップのすべてのデータをスクリプトへ渡すことができます。以下に例を示します。これは、Pandora の SNMP コンソールログで見ることができるトラップビューです。
 +
 +<code>
 + 2010-08-26 12:01:46 pandora 10.201.246.2 .1.3.6.1.4.1.1722 .1.3.6.1.4.1.1722.2.10.1.1.1 233 .1.3.6.1.4.1.1722.2.10.1.1.3 = STRING: 
 + AIX_Software_Failure .1.3.6.1.4.1.1722.2.10.1.1.2 = STRING: 08 25 2010 08:23:43:697685 .1.3.6.1.4.1.1722.2.10.1.1.8 = STRING: 1: A 
 + software error PERM with label CORE_DUMP, identifier C69F5C9B occurred at Wed Aug 2 5 10:22:28 DFT 2010 on dvs02 for resource 
 + SYSPROC. Cause is SOFTWARE PROGRAM ABNORMALLY TERMINATED. .1.3.6.1.4.1.1722.2.10.1.1.6 = STRING: 8 
 + .1.3.6.1.4.1.1722.2.10.1.1.11 = STRING: An application may not work properly .1.3.6.1.4.1.1722.2.10.1.1.10 = STRING: An application 
 + may not work properly .1.3.6.1.4.1.1722.2.10.1.1.12 = INTEGER: 4 .1.3.6.1.6.3.1.1.4.3.0 = OID: .1.3.6.1.4.1.1722
 +</code>
 +
 +{{ wiki:SNMP2.JPG?600 }}
 +
 +
 +
 +{{ wiki:SNMP3.JPG?550 }}
 +
 +
 +
 +スクリーンショットで、どのようにアラートを作成するかがわかると思います。トラップの内容 (_data_) に応じてスクリプトを実行します。また、SNMP アラートが作成されます。この場合、特定の OID (.1.3.6.1.4.1.1722.2.10.1.1.1) にマップされます。マップする OID の範囲を広くすることも可能で、例えば、(.1.3.6.1.4.1.1722) を指定すれば、この OID すべてのトラップ (AIX の特定 MIB の一部を想定) でスクリプトが呼び出されるようになります。
 +
 +このデータを処理するスクリプトが実行されます。 また、エージェントからのデータであるかのように、XMLファイルを作成し、'/var/spool/pandora/data_in' に移動することによって、Pandora FMS に直接データを書き込み、トラップを分析できます。 この場合の基本的なスクリプトは、複雑な情報を生成するスクリプトです。 すでにこのトラップに関する十分な情報を処理する処理は、以下から構成されます。
 +
 +  * オリジナルIPアドレス
 +  * メインイベント (コールドスタート)
 +  * 2つ目のイベント(説明): AIX_Software_Failure, 1: A software error PERM with label CORE_DUMP, identifier C69F5C9B occurred at Wed Aug 2 5 10:22:28 DFT 2010 on dvs02 for resource SYSPROC. Cause is SOFTWARE PROGRAM ABNORMALLY TERMINATED, An application may not work properly, An application may not work properly.
 +
 +これらのデータをパースするスクリプトを作る場合、例えば "miscript.pl" というスクリプトであれば、/var/spool/pandora/data_in にランダムな番号をつけたファイル名で XML ファイルを書くようにします。
 +例えば、snmp_gateway.31415.data です。
 +
 +生成した XML ファイルは次のようになります。
 +
 +<code>
 +<?xml version='1.0' encoding='ISO-8859-1'?>
 +<agent_data description='' group='' os_name='aix' os_version='' interval='300' version='3.1(Build 100608)' timestamp='2010/08/26 12:20:26' agent_name='10.201.246.2'>
 +  <module>
 +    <name><![CDATA[Critical_Event]]></name>
 +    <description><![CDATA[]]></description>
 +    <type>async_proc</type>
 +    <data><![CDATA[1]]></data>
 +  </module>
 +<module>
 +    <name><![CDATA[events]]></name>
 +    <description><![CDATA[]]></description>
 +    <type>generic_string</type>
 +    <datalist>
 +      <data><value><![CDATA[AIX_Software_Failure]]></value></data>
 +      <data><value><![CDATA[A software error PERM with label CORE_DUMP, identifier C69F5C9B occurred at Wed Aug 2 5 10:22:28 DFT 2010 on dvs02 for resource SYSPROC.]]></value></data>
 +      <data><value><![CDATA[Cause is SOFTWARE PROGRAM ABNORMALLY TERMINATED, An application may not work properly, An application may not work properly.]]></value></data>
 +    </datalist>
 +  </module>
 +</agent_data>
 +</code>
 +
 +アプリケーションは何でも実現できカスタマイズ可能です。とても強力な構造になっています。多くのシステムでは、情報はテキストだけではなく数値でも取得できます。グラフを書きたい場合等では、数値情報のモジュールを利用します。なお、全てのデータは常に非同期であることに注意してください。
 +
 +==== 実例: トラップを用いた ESX のモニタリング ====
 +
 +最も問題となりうるモニタリングの一つに、VMware ESX のようにバージョンによって情報の収集方法が異なるベンダが提供のシステムがあります。この章では、外部 SNMP トラップハンドラを使って、ESX システムをモニタする方法を説明します。
 +
 +ESX のトラップは次のようになっています。
 +
 +<code>
 + .1.3.6.1.4.1.6876.4.3.301 = STRING: "host"  .1.3.6.1.4.1.6876.4.3.302 = STRING: "c7000-06-01.tsm.inet"      .1.3.6.1.4.1.6876.4.3.303 = ""  
 + .1.3.6.1.4.1.6876.4.3.304 = STRING: "Green" .1.3.6.1.4.1.6876.4.3.305 = STRING: "Yellow"    .1.3.6.1.4.1.6876.4.3.306 = STRING: "Host 
 + cpu usage - Metric Usage = 1%"
 +</code>
 +
 +<code>
 + .1.3.6.1.4.1.6876.4.3.301 = STRING: "host"  .1.3.6.1.4.1.6876.4.3.302 = STRING: "dl360-00.tsm.inet" .1.3.6.1.4.1.6876.4.3.303 = ""  
 + .1.3.6.1.4.1.6876.4.3.304 = STRING: "Yellow".1.3.6.1.4.1.6876.4.3.305 = STRING: "Green"     .1.3.6.1.4.1.6876.4.3.306 = STRING: "Host 
 + memory usage - Metric Usage = 84%"
 +</code>
 +
 +<code>
 + .1.3.6.1.4.1.6876.4.3.301 = STRING: "host"  .1.3.6.1.4.1.6876.4.3.302 = ""  .1.3.6.1.4.1.6876.4.3.303 = ""  .1.3.6.1.4.1.6876.4.3.304 = 
 + STRING: "Red"       .1.3.6.1.4.1.6876.4.3.305 = STRING: "Green" .1.3.6.1.4.1.6876.4.3.306 = STRING: "Datastore usage on disk - Metric 
 + Storage space actually used = 55%"
 +</code>
 +
 +
 +見ての通り、トラップに CPU、ディスク、メモリ の情報がまとめられています。トラップの内容を分析し、XML ファイルを作成する小さなスクリプトを書き、トラップハンドラにすることを考えます。トラップハンドラの書き方は共通です。手順は 4つのステップとなります。
 +
 +  - ハンドラスクリプトを作成します。以下に示すスクリプトを参考にしてください。
 +  - アラートコマンドを作成します。
 +  - 上記のコマンドを使って、アラートアクションを作成します。必要に応じて適用先のエージェントを指定します。(複数の ESX がある場合は、それぞれ別のエージェントに適用したいような場合もあるかもしれません。)
 +  - エンタープライズ OID (この手法でモニタする全トラップのもの) および発信元 IP アドレスにマップする SNMP トラップアラートを作成します。
 +
 +では、トラップハンドラを作成する、最初のステップを見てみましょう。
 +
 +=== トラップハンドラ: esx_trap_manager.pl ===
 +
 +<code>
 +#!/usr/bin/perl
 +# (c) Sancho Lerena 2010 <slerena@artica.es>
 +# Specific Pandora FMS trap collector for ESX 
 +
 +use POSIX qw(setsid strftime);
 +
 +sub show_help {
 + print "\nSpecific Pandora FMS trap collector for ESX\n";
 + print "(c) Sancho Lerena 2010 <slerena@artica.es>\n";
 + print "Usage:\n\n";
 + print "   esx_trap_manager.pl <destination_agent_name> <TRAP DATA>\n\n";
 + exit;
 +}
 +
 +sub writexml {
 + my ($hostname, $xmlmessage ) = @_;
 + my $file = "/var/spool/pandora/data_in/$hostname.".rand(1000).".data";
 +
 + open (FILE, ">> $file") or die "[FATAL] Cannot write to XML '$file'";
 + print FILE $xmlmessage;
 + close (FILE);
 +}
 +
 +if ($#ARGV == -1){
 + show_help();
 +}
 +
 +$chunk = "";
 +
 +# First parameter is always destination host for virtual server
 +$target_host = $ARGV[0];
 +
 +foreach $argnum (1 .. $#ARGV) {
 + if ($chunk ne ""){
 + $chunk .= " ";
 + }
 + $chunk .= $ARGV[$argnum];
 +}
 +
 +my $hostname = "";
 +my $now = strftime ("%Y-%m-%d %H:%M:%S", localtime());
 +my $xmldata = "<agent_data agent_name='$target_host' timestamp='$now' version='1.0' os='Other' os_version='ESX_Collectordime ' interval='9999999999'>";
 +
 +if ($chunk =~ m/.1.3.6.1.4.1.6876.4.3.302 \= STRING\: ([A-Za-z0-9\-\.]*)\s\.1/){
 + $hostname = "_".$1;
 +}
 +
 +if ($chunk =~ m/Host cpu usage \- Metric Usage \= ([0-9]*)\z/){
 + $value = $1;
 + $module_name = "CPU_OCUPADA$hostname";
 +}
 +
 +if ($chunk =~ m/Host memory usage \- Metric Usage = ([0-9\.]*)\z/){
 + $value = $1;
 + $module_name = "MEMORIA_OCUPADA$hostname";
 +}
 +
 +if ($chunk =~ m/Datastore usage on disk \- Metric Storage space actually used \= ([0-9\.]*)\z/){
 + $value = $1;
 + $module_name = "DISCO_OCUPADO$hostname";
 +}
 +
 +$xmldata .= "<module><name>$module_name</name><type>async_data</type><data>$value</data></module>\n";
 +
 +$xmldata .= "</agent_data>\n";
 +writexml ($target_host, $xmldata);
 +</code>
 +
 +
 +=== ステップ 2: アラートコマンドの作成 ===
 +
 +この例では、コマンドスクリプトを /tmp に置いています。(実際には、より安全な場所に置いてください。) そして、それに実行権限を与えます。(chmod 755)
 +
 +{{ wiki:SNMP3.jpg?750 }}
 +
 +
 +== ステップ 3: アラートアクションの作成 ==
 +特定のエージェントのトラップの情報を送信するアクションを作成します。この場合、情報は WINN1247VSR というエージェントに送られます。上記のコマンドは、エージェント名をパラメータとして受け取り、(ESX バーチャルセンターの) 全ての情報を処理し、トラップからのデータを分割します。特に制限はなく、トラップで送られる全ての情報を処理します。
 +
 +{{ wiki:SNMP4.jpg?700 }}
 +
 +
 +=== ステップ 4: SNMP アラートの作成 ===
 +
 +作成したアクションを使って、トラップのアラートを設定します。
 +
 +{{ wiki:SNMP5.jpg?500 }}
 +
 +
 +
 +ESX の全てのトラップを処理するために、ESX のトラップにマップする OID である .1.3.6.1.4.1.6876.4.3.301 を指定します。IP アドレスフィルタリングにより、それぞれの VirtualCenter のソース IP アドレスでフィルタリングすることもできます。
 +
 +=== データの表示 ===
 +
 +以下に情報の参照例を示します。これにより、通常のモジュールとして管理できます。
 +
 +{{  :wiki:snmp6.png?650  |snmp6.png}}
 +
 +{{  :wiki:snmp7.jpg?650  |snmp7.jpg}}
  
  • ja/documentation/pandorafms/monitoring/08_snmp_traps_monitoring.1708505501.txt.gz
  • 最終更新: 2024/02/21 08:51
  • by junichi