X-MON Cookbook

X-MON Cookbookとは、ChefからX-MONのAPI操作を簡単に行えるようにした独自のLWRPです。

Cookbookに含まれている独自リソースを使用することで、ChefでX-MONのホストやサービス追加を行えます。

X-MON Cookbookは、X-MONサーバを構築するものではありません。ご注意ください。

X-MON Cookbookファイルはこちらよりダウンロードください。

ダウンロード

Node Attributes

node["xmon"]["ip"] X-MONサーバのIPアドレス
node["xmon"]["access_user"] APIをリクエストするユーザID
node["xmon"]["access_key"] X-MON APIアクセスキー

Resources/Providers

xmon_hosts

syntax

レシピにxmon_hostsリソースを使用するには、次のように記載します。

         
         xmon_hosts "name" do
           attribute "value"
           ...
           action :action
         end
         
         

nameはリソースブロックの名前です。対象となるattributeは、host_nameになります。

action

:create ホスト設定の新規作成
:update ホスト設定の更新
:delete ホスト設定の削除

省略時のデフォルトは、:createになります。

attributes

host_name string ホストIDを指定します。
host_alias string ホスト名称を指定します。
approve boolean このリクエストを即座に反映するかどうかを指定します。
address string IPアドレス/FQDNを指定します。
package array 適用させる監視パッケージのIDを指定します。
check_command string ホスト監視用コマンドを指定します。
check_command_param hash ホスト監視用コマンドの引数を指定します。
macaddress string MACアドレスを指定します。
type string 機器種別を指定します。
parents array 親ホストを指定します。
max_check_attempts integer 試行回数を指定します。
check_interval integer 監視間隔を指定します。
retry_interval integer 再試行間隔を指定します。
active_checks_enabled boolean アクティブチェックを指定します。
passive_checks_enabled boolean パッシブチェックを指定します。
check_period string 監視時間帯を指定します。
obsess_over_host boolean 分散監視送信機能を指定します。
check_freshness boolean フレッシュネスチェックを指定します。
freshness_threshold integer フレッシュネスしきい値を指定します。
event_handler_enabled boolean イベントハンドラを指定します。
event_handler string イベントハンドラコマンドを指定します。
low_flap_threshold integer フラッピング検出の低しきい値を指定します。
high_flap_threshold integer フラッピング検出の高しきい値を指定します。
flap_detection_enabled boolean フラッピング検出を指定します。
flap_detection_options hash フラッピング検出の対象を指定します。
process_perf_data boolean パフォーマンスデータ処理を指定します。
retain_status_information boolean 監視ステータス状態の保存を指定します。
retain_nonstatus_information boolean 監視設定情報の保存を指定します。
contact_groups array 通知先のユーザグループを指定します。
notification_interval integer 再通知間隔を指定します。
first_notification_delay integer 初期通知の遅延時間を指定します。
notification_period string 通知及びエスカレーションの時間帯を指定します。
notification_options hash 通知及びエスカレーションの対象を指定します。
notifications_enabled boolean 通知及びエスカレーション機能を指定します。
stalking_options hash 状態追跡オプションを指定します。
icon string ホストのアイコンを指定します。
snmp_version string SNMPのバージョンを指定します。
snmp_community string SNMPのコミュニティ名を指定します。
SNMPv3の場合は、認証ユーザ名を指定します。
snmp_security_level string SNMPv3のセキュリティレベルを指定します。
snmp_authtype string SNMPv3の認証タイプを指定します。
snmp_user string SNMPv3の認証パスワードを指定します。
snmp_protocol string SNMPv3の暗号化プロトコルを指定します。
snmp_pass string SNMPv3の暗号化パスワードを指定します。
wmi_user string WMIのアカウントを指定します。
wmi_pass string WMIのパスワードを指定します。
aws_access string AWSのアクセスキーを指定します。
aws_secret string AWSのシークレットキーを指定します。
aws_region string AWSのリージョンを指定します。
aws_namespace string AWSのインスタンスIDを指定します。

実際に設定する値の情報に関しては、APIドキュメントを参照してください。

example

Webサーバの登録を行う

       xmon_hosts "web-server" do
         host_name 'web-server'
         address '192.168.30.201'
         package ['xmon-default-linux-www']
         check_command 'check-host-alive'
         snmp_version '1'
         snmp_community 'public'
         action :create
       end
       
WebサーバのSNMPをVersion3に変更を行う

       xmon_hosts "web-server" do
         host_name 'web-server'
         snmp_version '3'
         snmp_community 'snmp_user'
         snmp_security_level 'authPriv'
         snmp_authtype 'SHA'
         snmp_user 'password'
         snmp_protocol 'AES'
         snmp_pass 'password'
         action :update
       end
       

xmon_services

syntax

レシピにxmon_servicesリソースを使用するには、次のように記載します。

         
         xmon_services_add "name" do
           attribute "value"
           ...
           action :action
         end
         
         

nameはリソースブロックの名前です。対象となるattributeは、host_nameになります。

action

:create サービス設定の新規作成
:update サービス設定の更新
:delete サービス設定の削除

省略時のデフォルトは、:createになります。

attributes

host_name string ホストIDを指定します。
service_description string サービスIDを指定します。
approve boolean このリクエストを即座に反映するかどうかを指定します。
is_volatile boolean volatileサービスを指定します。
check_command string サービス監視用コマンドを指定します。
check_command_param hash サービス監視用コマンドの引数を指定します。
max_check_attempts integer 試行回数を指定します。
check_interval integer 監視間隔を指定します。
retry_interval integer 再試行間隔を指定します。
active_checks_enabled boolean アクティブチェックを指定します。
passive_checks_enabled boolean パッシブチェックを指定します。
check_period string 監視時間帯を指定します。
obsess_over_service boolean 分散監視送信機能を指定します。
check_freshness boolean フレッシュネスチェックを指定します。
freshness_threshold integer フレッシュネスしきい値を指定します。
event_handler_enabled boolean イベントハンドラを指定します。
event_handler string イベントハンドラコマンドを指定します。
low_flap_threshold integer フラッピング検出の低しきい値を指定します。
high_flap_threshold integer フラッピング検出の高しきい値を指定します。
flap_detection_enabled boolean フラッピング検出を指定します。
flap_detection_options hash フラッピング検出の対象を指定します。
process_perf_data boolean パフォーマンスデータ処理を指定します。
retain_status_information boolean 監視ステータス状態の保存を指定します。
retain_nonstatus_information boolean 監視設定情報の保存を指定します。
contact_groups array 通知先のユーザグループを指定します。
notification_interval integer 再通知間隔を指定します。
first_notification_delay integer 初期通知の遅延時間を指定します。
notification_period string 通知及びエスカレーションの時間帯を指定します。
notification_options hash 通知及びエスカレーションの対象を指定します。
notifications_enabled boolean 通知及びエスカレーション機能を指定します。
stalking_options hash 状態追跡オプションを指定します。

実際に設定する値の情報に関しては、APIドキュメントを参照してください。

example

WebサーバのPINGサービスのラウンドトリップタイムしきい値だけを変更

       xmon_services "web-server-ping" do
         host_name 'web-server'
         service_description 'PING'
         check_command 'check_xmon3_ping'
         check_command_param :arg1 => 500, :arg3 => 800
         action :update
       end
       

xmon_restart

syntax

レシピにxmon_restartリソースを使用するには、次のように記載します。

         
         xmon_services_add "name" do
           action :action
         end
         
         

nameはリソースブロックの名前です。

attributesは存在しません。

action

:restart X-MONの再起動を実行

example

X-MONを再起動させる

       xmon_restart "restart" do
         action :restart
       end