maintenance.create

Description

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

This method allows to create new maintenances.

Parameters

(object/array) Maintenances to create.

Additionally to the standard maintenance properties, the method accepts the following parameters.

ParameterTypeDescription
groupids
(required)
arrayIDs of the host groups that will undergo maintenance.
hostids
(required)
arrayIDs of the hosts that will undergo maintenance.
timeperiods
(required)
arrayMaintenance time periods.
tagsarrayProblem tags.

Define what problems must be suppressed.
If no tags are given, all active maintenance host problems will be suppressed.

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.

Examples

Creating a maintenance

Create a maintenance with data collection for host group “2” with problem tags service:mysqld and error. 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.

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. "tags_evaltype": 0,
  9. "groupids": [
  10. "2"
  11. ],
  12. "timeperiods": [
  13. {
  14. "timeperiod_type": 3,
  15. "every": 1,
  16. "dayofweek": 64,
  17. "start_time": 64800,
  18. "period": 3600
  19. }
  20. ],
  21. "tags": [
  22. {
  23. "tag": "service",
  24. "operator": "0",
  25. "value": "mysqld",
  26. },
  27. {
  28. "tag": "error",
  29. "operator": "2",
  30. "value": ""
  31. }
  32. ]
  33. },
  34. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  35. "id": 1
  36. }

Response:

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

See also

Source

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