创建

说明

object maintenance.create(object/array maintenances)

此方法允许创建新的维护模式。

参数

(object/array)要创建的维护模式。

另外见标准的维护属性,此方法接受如下参数。

属性 类 描述
groupids
(必须)
array 要执行维护模式的主机组IDs。
hostids
(必须)
array 要执行维护模式的主机的IDs。
timeperiods
(必须)
array 维护模式时间周期。
tags array 问题标签
定义哪些问题必须被抑制。如果没有给出标记,所有活动维护主机问题都将被抑制。

<note important>每个维护模式至少一个主机或主机组被定义。 :::

Return values 返回值

(object)maintenanceids属性中返回一个包含所有已被创建的维护模式的对象的ID。返回的IDs的排序与传递的维护模式的IDs顺序一致。

示例

创建一个维护模式

为主机组"2"以with data collection(持续收集数据)模式创建一个维护模式。该维护模式生效于22.01.2013 到 22.01.2014,每周六的18:00生效,并持续1个小时。

请求:

{  "jsonrpc": "2.0",  "method": "maintenance.create",  "params": {  "name": "Sunday maintenance",  "active_since": 1358844540,  "active_till": 1390466940,  "tags_evaltype": 0,  "groupids": [  "2"  ],  "timeperiods": [  {  "timeperiod_type": 3,  "every": 1,  "dayofweek": 64,  "start_time": 64800,  "period": 3600  }  ],  "tags": [  {  "tag": "service",  "operator": "0",  "value": "mysqld",  },  {  "tag": "error",  "operator": "2",  "value": ""  }  ]  },  "auth": "038e1d7b1735c6a5436ee9eae095879e",  "id": 1 }

响应:

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

参见

来源

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