This is the documentation page for an unsupported version of Zabbix.
Is this not what you were looking for? Switch to the current version or choose one from the drop-down menu.

host.update

説明

object host.update(object/array hosts)

このメソッドでは、既存のホストを更新することができます。

このメソッドは、Admin および Super admin ユーザータイプにのみ使用できます。このメソッドを呼び出す許可は、
ユーザーロール設定で取り消すことができます。詳細については、User roles を参照してください。

パラメータ

(object/array) 更新されるホストプロパティ

hostid プロパティは各ホストに対して定義する必要があり、他のプロパティはすべてオプションです。
与えられたプロパティのみが更新され、その他のプロパティは変更されません。

しかし、ホストの technical name(実ホスト名) を更新すると、ホストの visible name (表示名 指定されていないか空の場合) も
ホストの technical name の値で更新されることに注意してください。

standard host propertiesに加えて、このメソッドは以下のパラメータを受け付けます。

パラメータ Type 説明
groups object/array Host groups to replace the current host groups the host belongs to.

The host groups must have the groupid property defined. All host groups that are not listed in the request will be unlinked.
interfaces object/array Host interfaces to replace the current host interfaces.

All interfaces that are not listed in the request will be removed.
tags object/array Host tags to replace the current host tags.

All tags that are not listed in the request will be removed.
inventory object Host inventory properties.
macros object/array User macros to replace the current user macros.

All macros that are not listed in the request will be removed.
templates object/array Templates to replace the currently linked templates. All templates that are not listed in the request will be only unlinked.

The templates must have the templateid property defined.
templates_clear object/array Templates to unlink and clear from the host.

The templates must have the templateid property defined.

Zabbix フロントエンドとは異なり、name(表示名)とhost(ホスト名)が同じ場合、API 経由で host を更新しても、
自動的に name は更新されません。両方のプロパティを明示的に更新する必要があります。

戻り値

(object) hostids プロパティの下で更新されたホストの ID を含むオブジェクトを返します。

ホストの有効化

ホストの監視を有効にする、つまりステータスを0にします。

リクエスト :

{
           "jsonrpc": "2.0",
           "method": "host.update",
           "params": {
               "hostid": "10126",
               "status": 0
           },
           "id": 1
       }
Copy
✔ Copied

レスポンス :

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10126"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

テンプレートのリンク削除

ホストから2つのテンプレートのリンクを削除してクリアします。

リクエスト :

{
           "jsonrpc": "2.0",
           "method": "host.update",
           "params": {
               "hostid": "10126",
               "templates_clear": [
                   {
                       "templateid": "10124"
                   },
                   {
                       "templateid": "10125"
                   }
               ]
           },
           "id": 1
       }
Copy
✔ Copied

レスポンス :

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10126"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

ホストマクロの更新

すべてのホストマクロを新しい2つのマクロに置き換えます。

リクエスト :

{
           "jsonrpc": "2.0",
           "method": "host.update",
           "params": {
               "hostid": "10126",
               "macros": [
                   {
                       "macro": "{$PASS}",
                       "value": "password"
                   },
                   {
                       "macro": "{$DISC}",
                       "value": "sda",
                       "description": "Updated description"
                   }
               ]
           },
           "id": 1
       }
Copy
✔ Copied

レスポンス :

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10126"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

ホストインベントリの更新

インベントリモードの変更とロケーションの追加をします。

リクエスト :

{
           "jsonrpc": "2.0",
           "method": "host.update",
           "params": {
               "hostid": "10387",
               "inventory_mode": 0,
               "inventory": {
                   "location": "Latvia, Riga"
               }
           },
           "id": 1
       }
Copy
✔ Copied

レスポンス :

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10387"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

ホストタグの更新

すべてのホストタグを新しいものに置き換えます。

リクエスト :

{
           "jsonrpc": "2.0",
           "method": "host.update",
           "params": {
               "hostid": "10387",
               "tags": {
                   "tag": "OS",
                   "value": "RHEL 7"
               }
           },
           "id": 1
       }
Copy
✔ Copied

レスポンス :

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10387"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

検出されたホストマクロの更新

作成した検出ルールの"自動"マクロを"手動"に変換し、その値を"new-value"に変更します。

リクエスト :

{
           "jsonrpc": "2.0",
           "method": "host.update",
           "params": {
               "hostid": "10387",
               "macros": {
                   "hostmacroid": "5541",
                   "value": "new-value",
                   "automatic": "0"
               }
           },
           "id": 1
       }
Copy
✔ Copied

レスポンス :

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10387"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

Updating host encryption

Update the host "10590" to use PSK encryption only for connections from host to Zabbix server. In addition, update the PSK identity and PSK key for this host. Note that the Zabbix agent that is installed on the host has to be configured to use PSK.

Request:

{
           "jsonrpc": "2.0",
           "method": "host.update",
           "params": {
               "hostid": "10590",
               "tls_connect": 1,
               "tls_accept": 2,
               "tls_psk_identity": "PSK 002",
               "tls_psk": "e560cb0d918d26d31b4f642181f5f570ad89a390931102e5391d08327ba434e9"
           },
           "id": 1
       }
Copy
✔ Copied

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "10590"
               ]
           },
           "id": 1
       }
Copy
✔ Copied

参照

ソース

CHost::update() in ui/include/classes/api/services/CHost.php.

To toggle search highlight, press Ctrl+Alt+H
Have an improvement suggestion for this page? Select the text that could be improved and press Ctrl+Enter to send it to the editors.