作成日 | 2024/12/25 |
---|
はじめに
今回、この記事ではコマンドラインを用いた、監視設定の登録及び設定変更についてご紹介します。
コマンドラインツールとは
コマンドラインツールとは、
Hinemosクライアント上のほぼ全ての操作をCUI(キャラクタユーザ インタフェース)上で実現可能となる運用支援ツールです。
実際に監視の登録と設定変更をしてみる
今回は例として、Ping監視の設定を扱います。
実際に実行した結果を元に監視設定の登録や変更方法について説明します。
コマンドラインツールの前提条件と導入方法については今回は省略いたします。
●使用環境
使用した環境については以下の通りです。
Hinemosマネージャ環境
・OS:RHEL 9
・Hinemos ver.7.1.0
Hinemosコマンドラインツール環境
・OS:RHEL 9
・Hinemos ver.7.1.0
・Python:3.8.17
●事前準備
監視設定の前提条件は以下の通りです。
・監視対象とするスコープ または ノードを事前に登録する必要があります
・通知設定を事前に登録する必要があります
今回は予めWebクライアントで以下を実施しました。
次章以降のノード名やイベント通知IDは以下の登録内容となっています。
登録するノードやノード名、通知設定は任意で設定可能となっていますので、変更される場合は置き換えてください。
・コマンドラインツール導入したサーバを、ノード”node_cmdline”と登録する

・常に通知するイベント通知”ntf_event_test”を登録する /p>

監視設定を登録する
今回は5分間隔でノード"node_cmdline"を監視する、監視項目ID"test-ping"を作成します。
以下の項目以外の設定はデフォルトです。
・監視項目ID:test-ping
・スコープ:node_cmdline
・通知ID:ntf_event_test
・アプリケーション:test-ping
実行コマンドをコマンドラインツール配置しているディレクトリ配下で実行します。
設定内容を記述した後に、monitorsetting_addPingMonitor.pyを実行する事で登録されます。
実行コマンド
json=$(cat << EOS { "monitorId" : "test-ping", "monitorType" : "NUMERIC", "monitorTypeId" : "MON_PING_N", "application" : "test-ping", "description" : null, "monitorFlg" : true, "runInterval" : "MIN_05", "calendarId" : null, "facilityId" : "node_cmdline", "scope" : "node_cmdline", "notifyRelationList" : [ { "notifyId" : "ntf_event_test", "notifyType" : "EVENT" } ], "ownerRoleId" : "ALL_USERS", "collectorFlg" : false, "itemName" : "応答時間", "measure" : "msec", "predictionFlg" : false, "predictionMethod" : "POLYNOMIAL_1", "predictionAnalysysRange" : 60, "predictionTarget" : 60, "predictionApplication" : "test-ping", "changeFlg" : false, "changeAnalysysRange" : 60, "changeApplication" : "test-ping", "numericValueInfo" : [ { "monitorNumericType" : "CHANGE", "priority" : "INFO", "message" : null, "thresholdLowerLimit" : -1.0, "thresholdUpperLimit" : 1.0 } { "monitorNumericType" : "CHANGE", "priority" : "WARNING", "message" : null, "thresholdLowerLimit" : -2.0, "thresholdUpperLimit" : 2.0 } { "monitorNumericType" : "CHANGE", "priority" : "CRITICAL", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } { "monitorNumericType" : "CHANGE", "priority" : "UNKNOWN", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } { "monitorNumericType" : "BASIC", "priority" : "INFO", "message" : null, "thresholdLowerLimit" : 1000.0, "thresholdUpperLimit" : 1.0 } { "monitorNumericType" : "BASIC", "priority" : "WARNING", "message" : null, "thresholdLowerLimit" : 3000.0, "thresholdUpperLimit" : 51.0 } { "monitorNumericType" : "BASIC", "priority" : "CRITICAL", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } { "monitorNumericType" : "BASIC", "priority" : "UNKNOWN", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } ], "predictionNotifyRelationList" : [], "changeNotifyRelationList" : [], "pingCheckInfo" : { "runCount" : 1, "runInterval" : 1000, "timeout" : 5000 } } EOS ) python3 monitorsetting_addPingMonitor.py -H "http://[HinemosマネージャのIPadress]:8080" -U "[ログインユーザ]" -w "[ログインパスワード]" -L "ja" -a "$json"
実際に実行した結果です。



Webクライアントより、先ほどの監視設定が登録されていることを確認します。


登録されていることを確認出来ました。
監視設定を変更する
先ほど登録した監視項目ID"test-ping"の監視間隔を、5分から1分に変更してみます。
実行コマンドをコマンドラインツール配置しているディレクトリ配下で実行します。
同様に設定内容を記述した後に、monitorsetting_modifyPingMonitor.pyを実行する事で登録されます。
実行コマンド9行目"runInterval"を"MIN_01"に変更します。
実行コマンド
json=$(cat << EOS { "monitorId" : "test-ping", "monitorType" : "NUMERIC", "monitorTypeId" : "MON_PING_N", "application" : "test-ping", "description" : null, "monitorFlg" : true, "runInterval" : "MIN_01", "calendarId" : null, "facilityId" : "node_cmdline", "scope" : "node_cmdline", "notifyRelationList" : [ { "notifyId" : "ntf_event_test", "notifyType" : "EVENT" } ], "ownerRoleId" : "ALL_USERS", "collectorFlg" : false, "itemName" : "応答時間", "measure" : "msec", "predictionFlg" : false, "predictionMethod" : "POLYNOMIAL_1", "predictionAnalysysRange" : 60, "predictionTarget" : 60, "predictionApplication" : "test-ping", "changeFlg" : false, "changeAnalysysRange" : 60, "changeApplication" : "test-ping", "numericValueInfo" : [ { "monitorNumericType" : "CHANGE", "priority" : "INFO", "message" : null, "thresholdLowerLimit" : -1.0, "thresholdUpperLimit" : 1.0 } { "monitorNumericType" : "CHANGE", "priority" : "WARNING", "message" : null, "thresholdLowerLimit" : -2.0, "thresholdUpperLimit" : 2.0 } { "monitorNumericType" : "CHANGE", "priority" : "CRITICAL", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } { "monitorNumericType" : "CHANGE", "priority" : "UNKNOWN", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } { "monitorNumericType" : "BASIC", "priority" : "INFO", "message" : null, "thresholdLowerLimit" : 1000.0, "thresholdUpperLimit" : 1.0 } { "monitorNumericType" : "BASIC", "priority" : "WARNING", "message" : null, "thresholdLowerLimit" : 3000.0, "thresholdUpperLimit" : 51.0 } { "monitorNumericType" : "BASIC", "priority" : "CRITICAL", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } { "monitorNumericType" : "BASIC", "priority" : "UNKNOWN", "message" : null, "thresholdLowerLimit" : 0.0, "thresholdUpperLimit" : 0.0 } ], "predictionNotifyRelationList" : [], "changeNotifyRelationList" : [], "pingCheckInfo" : { "runCount" : 1, "runInterval" : 1000, "timeout" : 5000 } } EOS ) python3 monitorsetting_modifyPingMonitor.py -H "http://[HinemosマネージャのIPadress]:8080" -U "[ログインユーザ]" -w "[ログインパスワード]" -L "ja" -mn "test-ping" -md "$json"
実際に実行した結果です。



Webクライアントより、先ほどの変更点が反映されているか確認します。


監視間隔が5分から1分に変更されていることを確認出来ました。
おわりに
この記事では、コマンドラインを用いた、監視設定の登録及び設定変更方法についてご紹介しました。
ご覧いただきありがとうございました。