データクエリファイル (XML形式) を作成する

Cactiのデータクエリファイルの作成手順を紹介します。

クエリファイルの例

<interface>
  <name>Get SNMP PP Interfaces</name>
  <description>Queries a host for a list of monitorable interfaces</description>
  <oid_index>.1.3.6.1.4.1.1182.2.3.9.1.1</oid_index>
  <oid_num_indexes>.1.3.6.1.4.1.1182.2.3.9.1.1</oid_num_indexes>
  <index_order>yrIfPpIndex</index_order>
  <index_order_type>numeric</index_order_type>
  <index_title_format>|chosen_order_field|</index_title_format>

  <fields>
    <yrIfPpIndex>
      <name>Index</name>
      <method>walk</method>
      <source>value</source>
      <direction>input</direction>
      <oid>.1.3.6.1.4.1.1182.2.3.9.1.1</oid>
    </yrIfPpIndex>
    <yrIfPpDescr>
      <name>Description</name>
      <method>walk</method>
      <source>value</source>
      <direction>input</direction>
      <oid>.1.3.6.1.4.1.1182.2.3.9.1.2</oid>
    </yrIfPpDescr>
    <yrIfPpSpeed>
      <name>Speed</name>
      <method>walk</method>
      <source>value</source>
      <direction>input</direction>
      <oid>.1.3.6.1.4.1.1182.2.3.9.1.5</oid>
    </yrIfPpSpeed>
    <yrIfPpAdminStatus>
      <name>Status</name>
      <method>walk</method>
      <source>value</source>
      <direction>input</direction>
      <oid>.1.3.6.1.4.1.1182.2.3.9.1.7</oid>
    </yrIfPpAdminStatus>
    <yrIfPpInOctets>
      <name>Bits In</name>
      <method>walk</method>
      <source>value</source>
      <direction>output</direction>
      <oid>.1.3.6.1.4.1.1182.2.3.9.1.10</oid>
    </yrIfPpInOctets>
    <yrIfPpOutOctets>
      <name>Bits Out</name>
      <method>walk</method>
      <source>value</source>
      <direction>output</direction>
      <oid>.1.3.6.1.4.1.1182.2.3.9.1.16</oid>
    </yrIfPpOutOctets>
  </fields>
</interface>

解説

  <name>Get SNMP PP Interfaces</name>
  <description>Queries a host for a list of monitorable interfaces</description>
  <oid_index>.1.3.6.1.4.1.1182.2.3.9.1.1</oid_index>
  <oid_num_indexes>.1.3.6.1.4.1.1182.2.3.9.1.1</oid_num_indexes>
  <index_order>yrIfPpIndex</index_order>
  <index_order_type>numeric</index_order_type>
  <index_title_format>|chosen_order_field|</index_title_format>
  • name : このクエリファイルの名前を指定します。わかりやすい名前を付けます。
  • description : このクエリファイルの説明を記述します・
  • oid_index : このグループのインデックスを示すOIDを指定します。
  • oid_num_indexes : このグループのグループの個数を示すOIDを指定します。個数を示すOIDがない場合はインデックスを示すOIDを指定するか、省略しても良いようです。
  • index_order : Cactiでのソート順を示します。タグ内の値はfieldsのタグ名を指定します。上記のファイルの例では,"yrIfPpIndex","yrIfPpDescr","yrIfPpSpeed"などのfieldsの直下のタグ名を指定できます。
  • index_title_format : 項目名のフォーマットです。

Fieldsタグ内のフィールドの書式は以下の通りです。
    <yrIfPpIndex>
      <name>Index</name>
      <method>walk</method>
      <source>value</source>
      <direction>input</direction>
      <oid>.1.3.6.1.4.1.1182.2.3.9.1.1</oid>
    </yrIfPpIndex>
タグ名"yrIfPpIndex"は任意の名前でよいですが、mibファイルがある場合はmibの名前と揃えておくと混乱がないかと思われます。
  • name : このMIBノードの名前を記述します。
  • method : このノードに対する処理を記述します。"walk"と"get"が選べますが、通常はwalkで問題ないようです。
  • source : 値の取り扱い方法を記述します。通常は"value"で問題ないようです
  • direction : 値の使用方法を設定します。"input"を設定するとその値は見出しとして利用されます。"output"を設定するとグラフなどを描画するための値として使われます。
  • oid : このmibノードのoidを指定します。

実行結果

上記のデータクエリファイルを使用して Data Queryを作成しHostテンプレートに組み込みDeviceに適用し、New Graph画面を表示させた際に、以下のデータクエリの表示となります。Inputで指定した項目が見出しになっています。


著者
iPentecのプログラマー、最近はAIの積極的な活用にも取り組み中。
とっても恥ずかしがり。
掲載日: 2012-07-26
iPentec all rights reserverd.