maintenance.create

Description 说明

object maintenance.create(object/array **maintenances**)

This method allows to create new maintenances. 此方法允许创建新的维护模式。

Parameters 参数

(object/array) Maintenances to create.

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

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

ParameterTypeDescription
groupids
(required)
arrayIDs of the host groups that will undergo maintenance. 要执行维护模式的主机组IDs。
hostids
(required)
arrayIDs of the hosts that will undergo maintenance. 要执行维护模式的主机的IDs。
timeperiods
(required)
arrayMaintenance time 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 created maintenances under the maintenanceids property. The order of the returned IDs matches the order of the passed maintenances. (object)maintenanceids属性中返回一个包含所有已被创建的维护模式的对象的ID。返回的IDs的排序与传递的维护模式的IDs顺序一致。

Examples 示例

Creating a maintenance 创建一个维护模式

Create a maintenance with data collection for host group “2”. It must be active from 22.01.2013 till 22.01.2014, come in effect each Sunday at 18:00 and last for one hour. 为主机组“2”以with data collection(持续收集数据)模式创建一个维护模式。该维护模式生效于22.01.2013 到 22.01.2014,每周六的18:00生效,并持续1个小时。

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "maintenance.create",
  4. "params": {
  5. "name": "Sunday maintenance",
  6. "active_since": 1358844540,
  7. "active_till": 1390466940,
  8. "groupids": [
  9. "2"
  10. ],
  11. "timeperiods": [
  12. {
  13. "timeperiod_type": 3,
  14. "every": 1,
  15. "dayofweek": 64,
  16. "start_time": 64800,
  17. "period": 3600
  18. }
  19. ]
  20. },
  21. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  22. "id": 1
  23. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "maintenanceids": [
  5. "3"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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