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. (object) 定义期望输出的参数。

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. 仅返回给定IDs的维护模式。
selectGroupsqueryReturn host groups assigned to the maintenance in the groups property. 在group属性中返回维护模式所指定的主机组。
selectHostsqueryReturn hosts assigned to the maintenance in the hosts property. 在host属性中返回维护模式所指定的主机。
selectTimeperiodsqueryReturn the maintenance’s time periods in the timeperiods property. 在timeperiods属性中返回维护模式的时间周期。
sortfieldstring/arraySort the result by the given properties. 根据给定的属性记性排序。

Possible values are: maintenanceid, name and maintenance_type. 可能的值有:, name and maintenance_type
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary. 这些参数在reference commentary中详细描述的所有get方法是通用的。
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, hosts and defined time periods. 获取所有配置的维护模式,以及关于指定主机组、主机和定义的时间周期数据。

Request:

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

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. "groups": [
  12. {
  13. "groupid": "4",
  14. "name": "Zabbix servers",
  15. "internal": "0"
  16. }
  17. ],
  18. "timeperiods": [
  19. {
  20. "timeperiodid": "4",
  21. "timeperiod_type": "3",
  22. "every": "1",
  23. "month": "0",
  24. "dayofweek": "1",
  25. "day": "0",
  26. "start_time": "64800",
  27. "period": "3600",
  28. "start_date": "2147483647"
  29. }
  30. ]
  31. }
  32. ],
  33. "id": 1
  34. }

See also

Source

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