object host.update(object/array hosts)
このメソッドは、既存のホストを更新することができます。
このメソッドは、AdminおよびSuper adminタイプのユーザーのみ利用可能です。メソッドを呼び出す権限は、ユーザーの役割の設定で取り消すことができます。詳細はユーザーの役割を参照してください。
(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
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
レスポンス:
ホストから2つのテンプレートのリンクを削除してクリアします。
リクエスト:
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10126",
"templates_clear": [
{
"templateid": "10124"
},
{
"templateid": "10125"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
レスポンス:
すべてのホストマクロを新しい2つのマクロに置き換えます。
リクエスト:
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10126",
"macros": [
{
"macro": "{$PASS}",
"value": "password"
},
{
"macro": "{$DISC}",
"value": "sda",
"description": "Updated description"
}
]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
レスポンス:
インベントリモードの変更とロケーションの追加
リクエスト:
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10387",
"inventory_mode": 0,
"inventory": {
"location": "Latvia, Riga"
}
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
レスポンス:
すべてのホストタグを新しいものに置き換えます。
リクエスト:
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10387",
"tags": {
"tag": "OS",
"value": "RHEL 7"
}
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
レスポンス:
ホスト"10590"を更新して、ホストからZabbixサーバーへの接続にのみPSK暗号化を使用するようにし、PSK IDとPSKキーを変更します。
ホストはPSKを使用するように事前設定する必要があることに注意してください。
リクエスト:
{
"jsonrpc": "2.0",
"method": "host.update",
"params": {
"hostid": "10590",
"tls_connect": 1,
"tls_accept": 2,
"tls_psk_identity": "PSK 002",
"tls_psk": "e560cb0d918d26d31b4f642181f5f570ad89a390931102e5391d08327ba434e9"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
レスポンス:
CHost::update() in ui/include/classes/api/services/CHost.php.