2022 Zabbix中国峰会
2022 Zabbix中国峰会

host.massupdate

Description 说明

object host.massupdate(object parameters)

This method allows to simultaneously replace or remove related objects and update properties on multiple hosts.此方法允许同时替换或移除相关对象和在多个主机中更新属性。

Parameters 参数

(object) Parameters containing the IDs of the hosts to update and the properties that should be updated. 参数包含更新主机的ID和需要更新的属性。

Additionally to the standard host properties, the method accepts the following parameters.另外,对于标准主机属性,此方法接受以下参数。

参数 类 说明
hosts
(required)
object/array Hosts to be updated.需要更新的主机。

The hosts must have the hostid property defined.主机必须已定义过hostid属性。
groups object/array Host groups to replace the current host groups the hosts belong to. 替换当前主机所属主机组。

The host groups must have the groupid property defined. 主机组必须已定义过groupid属性。
interfaces object/array Host interfaces to replace the current host interfaces on the given hosts.在指定主机上替换当前主机接口。
inventory object Host inventory properties.主机资产清单属性。

Host inventory mode cannot be updated using the inventory parameter, use inventory_mode instead.使用参数inventory无法更新主机资产清单模式,用参数inventory_mode替换
inventory_mode integer Host inventory population mode. 主机资产清单群体模式。

Refer to the host inventory object page for a list of supported inventory modes.参考host inventory object page支持的资产清单模式列表
macros object/array User macros to replace the current user macros on the given hosts. 在指定主机中替换当前用户宏。
templates object/array Templates to replace the currently linked templates on the given hosts. 在指定主机中替换当前链接的模板。

The templates must have the templateid property defined. 模板必须已定义过templateid属性。
templates_clear object/array Templates to unlink and clear from the given hosts. 在指定主机中删除模板链接并清除。

The templates must have the templateid property defined. 模板必须已定义过templateid属性。

Return values 返回值

(object) Returns an object containing the IDs of the updated hosts under the hostids property.返回一个对象其中包含在hostids属性下已更新主机的ID

Examples 范例

Enabling multiple hosts 启用多个主机

Enable monitoring of two hosts, i.e., set their status to 0.启用两个主机的监控,例如,把这两个主机的状态设置为0。

Request:

{
           "jsonrpc": "2.0",
           "method": "host.massupdate",
           "params": {
               "hosts": [
                   {
                       "hostid": "69665"
                   },
                   {
                       "hostid": "69666"
                   }
               ],
               "status": 0
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "hostids": [
                   "69665",
                   "69666"
               ]
           },
           "id": 1
       }

See also 参见

Source 来源

CHost::massUpdate() in frontends/php/include/classes/api/services/CHost.php.