maintenance.get

Description

integer/array maintenance.get(object **parameters**)

The method allows to retrieve maintenances according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
groupidsstring/arrayReturn only maintenances that are assigned to the given host groups.
hostidsstring/arrayReturn only maintenances that are assigned to the given hosts.
maintenanceidsstring/arrayReturn only maintenances with the given IDs.
selectGroupsqueryReturn a groups property with host groups assigned to the maintenance.
selectHostsqueryReturn a hosts property with hosts assigned to the maintenance.
selectTagsqueryReturn a tags property with problem tags of the maintenance.
selectTimeperiodsqueryReturn a timeperiods property with time periods of the maintenance.
sortfieldstring/arraySort the result by the given properties.

Possible values are: maintenanceid, name and maintenance_type.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

(integer/array) Returns either:

  • an array of objects;

  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving maintenances

Retrieve all configured maintenances, and the data about the assigned host groups, defined time periods and problem tags.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "maintenance.get",
  4. "params": {
  5. "output": "extend",
  6. "selectGroups": "extend",
  7. "selectTimeperiods": "extend",
  8. "selectTags": "extend"
  9. },
  10. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  11. "id": 1
  12. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "maintenanceid": "3",
  6. "name": "Sunday maintenance",
  7. "maintenance_type": "0",
  8. "description": "",
  9. "active_since": "1358844540",
  10. "active_till": "1390466940",
  11. "tags_evaltype": "0",
  12. "groups": [
  13. {
  14. "groupid": "4",
  15. "name": "Zabbix servers",
  16. "internal": "0"
  17. }
  18. ],
  19. "timeperiods": [
  20. {
  21. "timeperiodid": "4",
  22. "timeperiod_type": "3",
  23. "every": "1",
  24. "month": "0",
  25. "dayofweek": "1",
  26. "day": "0",
  27. "start_time": "64800",
  28. "period": "3600",
  29. "start_date": "2147483647"
  30. }
  31. ],
  32. "tags": [
  33. {
  34. "tag": "service",
  35. "operator": "0",
  36. "value": "mysqld",
  37. },
  38. {
  39. "tag": "error",
  40. "operator": "2",
  41. "value": ""
  42. }
  43. ]
  44. }
  45. ],
  46. "id": 1
  47. }

See also

Source

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