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

maintenance.update

Description 说明

object maintenance.update(object/array maintenances)

This method allows to update existing maintenances. 此方法允许更新已存在的维护模式。

Parameters 参数

(object/array) Maintenance properties to be updated. (object/array)要更新的维护模式的属性。

The maintenanceid property must be defined for each maintenance, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged. 每一个维护模式的maintenanceid属性必须被定义,其他所有属性均为可选。只有被传递的属性才会被更新,所有它属性保持不变。

Additionally to the standard maintenance properties, the method accepts the following parameters. 另外见standard maintenance properties,此方法接受如下参数。

Parameter Type Description
groupids array IDs of the host groups to replace the current groups. 要替换的当前主机组的主机组IDs。
hostids array IDs of the hosts to replace the current hosts. 要替换当前主机的主机IDs。
timeperiods array Maintenance time periods to replace the current periods. 要替换当前维护模式时间周期的时间周期。

At least one host or host group must be defined for each maintenance. 每一个维护模式至少一个主机或者一个主机组被定义。

Return values 返回值

(object) Returns an object containing the IDs of the updated maintenances under the maintenanceids property. (object)maintenanceids属性中返回一个包含已被更新的维护模式的IDs的对象。

Examples 示例

Assigning different hosts 指定不同的主机

Replace the hosts currently assigned to maintenance "3" with two different ones. 用两个不同的主机替换当前分配给维护“3”的主机。

Request:

{
           "jsonrpc": "2.0",
           "method": "maintenance.update",
           "params": {
               "maintenanceid": "3",
               "hostids": [
                   "10085",
                   "10084"
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "maintenanceids": [
                   "3"
               ]
           },
           "id": 1
       }

See also

Source

CMaintenance::update() in frontends/php/include/classes/api/services/CMaintenance.php.