You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.

hanode.get

説明

integer/array hanode.get(object parameters)

このメソッドは、指定されたパラメータに従って、HAクラスタノードのリストを取得することができます。

このメソッドはスーパ管理者ユーザータイプでのみ利用可能です。 詳細はユーザーロールを参照してください。

パラメーター

(object) 望ましい出力を定義するパラメーター。

このメソッドは以下のパラメーターをサポートします。

パラメーター 説明
ha_nodeids ID/array 指定したノードIDを持つノードのみを返します。
filter object 指定したフィルターに完全一致する結果のみを返します。

オブジェクトを受け入れ、キーはプロパティ名、値は一致させる単一値または値の配列です。

サポートされるプロパティ: name, address, status
sortfield string/array 指定したプロパティで結果をソートします。

指定可能な値: name, lastaccess, status
countOutput flag これらのパラメーターはリファレンス解説で説明されています。
limit integer
output query
preservekeys boolean
sortorder string/array

戻り値

(integer/array) 次のいずれかを返します:

  • オブジェクトの配列
  • countOutputパラメーターが使用されている場合、取得したオブジェクトの数

ステータスで並べ替えたノードのリストを取得する

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "hanode.get",
           "params": {
               "preservekeys": true,
               "sortfield": "status",
               "sortorder": "DESC"
           },
           "id": 1
       }

レスポンス:

{
         "jsonrpc": "2.0",
         "result": {
           "ckuo7i1nw000h0sajj3l3hh8u": {
             "ha_nodeid": "ckuo7i1nw000h0sajj3l3hh8u",
             "name": "node-active",
             "address": "192.168.1.13",
             "port": "10051",
             "lastaccess": "1635335704",
             "status": "3"
           },
           "ckuo7i1nw000e0sajwfttc1mp": {
             "ha_nodeid": "ckuo7i1nw000e0sajwfttc1mp",
             "name": "node6",
             "address": "192.168.1.10",
             "port": "10053",
             "lastaccess": "1635332902",
             "status": "2"
           },
           "ckuo7i1nv000c0sajz85xcrtt": {
             "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
             "name": "node4",
             "address": "192.168.1.8",
             "port": "10052",
             "lastaccess": "1635334214",
             "status": "1"
           },
           "ckuo7i1nv000a0saj1fcdkeu4": {
             "ha_nodeid": "ckuo7i1nv000a0saj1fcdkeu4",
             "name": "node2",
             "address": "192.168.1.6",
             "port": "10051",
             "lastaccess": "1635335705",
             "status": "0"
           }
         },
         "id": 1
       }

IDで特定のノードのリストを取得する

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "hanode.get",
           "params": {
               "ha_nodeids": ["ckuo7i1nw000e0sajwfttc1mp", "ckuo7i1nv000c0sajz85xcrtt"]
           },
           "id": 1
       }

レスポンス:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
                   "name": "node4",
                   "address": "192.168.1.8",
                   "port": "10052",
                   "lastaccess": "1635334214",
                   "status": "1"
               },
               {
                   "ha_nodeid": "ckuo7i1nw000e0sajwfttc1mp",
                   "name": "node6",
                   "address": "192.168.1.10",
                   "port": "10053",
                   "lastaccess": "1635332902",
                   "status": "2"
               }
           ],
           "id": 1
       }

停止したノードのリストを取得する

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "hanode.get",
           "params": {
               "output": ["ha_nodeid", "address", "port"],
               "filter": {
                   "status": 1
               }
           },
           "id": 1
       }

レスポンス:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "ha_nodeid": "ckuo7i1nw000g0sajjsjre7e3",
                   "address": "192.168.1.12",
                   "port": "10051"
               },
               {
                   "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
                   "address": "192.168.1.8",
                   "port": "10052"
               },
               {
                   "ha_nodeid": "ckuo7i1nv000d0sajd95y1b6x",
                   "address": "192.168.1.9",
                   "port": "10053"
               }
           ],
           "id": 1
       }

スタンバイノードの数を取得する

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "hanode.get",
           "params": {
               "countOutput": true,
               "filter": {
                   "status": 0
               }
           },
           "id": 1
       }

レスポンス:

{
           "jsonrpc": "2.0",
           "result": "3",
           "id": 1
       }

特定のIPアドレスでノードのステータスを確認する

リクエスト:

{
           "jsonrpc": "2.0",
           "method": "hanode.get",
           "params": {
               "output": ["name", "status"],
               "filter": {
                   "address": ["192.168.1.7", "192.168.1.13"]
               }
           },
           "id": 1
       }

レスポンス:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "name": "node3",
                   "status": "0"
               },
               {
                   "name": "node-active",
                   "status": "3"
               }
           ],
           "id": 1
       }

ソース

CHaNode::get() in ui/include/classes/api/services/CHaNode.php.