获取SLA

Description 说明

object service.getsla(object **parameters**)

This method allows to calculate availability information about services. 此方法允许计算有关服务的可用性信息。

Parameters 参数

(object) Parameters containing the IDs of the services and time intervals to calculate SLA. (object)参数包含服务ID以及计算SLA的时间间隔。

Parameter 参数Type 类型Description 说明
serviceidsstring/array 字符串/数组IDs of services to return availability information for. 提供可用性信息的服务ID。
intervalsarray 数组Time intervals to return service layer availability information about. 返回服务层可用性信息的时间间隔。

Each time interval must have the following parameters: 每个时间间隔必须具有以下参数:
- from - (timestamp 时间戳) interval start time; 间隔开始时间;
- to - (timestamp 时间戳) interval end time. 间隔结束时间。

Return values 返回值

(object) Returns the following availability information about each service under the corresponding service ID. (object)返回关于相应服务ID下每个服务的可用性信息。

Property 属性Type 类型Description 说明
statusinteger 整数型Current status of the service. 当前服务的状态。

Refer to the service object page for more information on service statuses. 有关服务状态的更多信息,请参阅service object page
problemsarray 数组Triggers that are currently in problem state and are linked either to the service or one of its descendants. 当前处于故障状态并且与服务或服务的子项所关联的触发器。
slaarray 数组SLA data about each time period. 每个时间段的SLA数据。

Each SLA object has the following properties: 每个SLA对象具有以下属性:
- from - (timestamp 时间戳) interval start time; 间隔开始时间;
- to - (timestamp 时间戳) interval end time; 间隔结束时间;
- sla - (float 浮点数) SLA for the given time interval; 指定时间间隔的SLA;
- okTime - (integer 整数型) time the service was in OK state, in seconds; 服务处于正常状态的时间,单位秒;
- problemTime - (integer 整数型) time the service was in problem state, in seconds; 服务处于故障状态的时间,单位秒;
- downtimeTime - (integer 整数型) time the service was in scheduled downtime, in seconds. 服务处于计划停机的时间,单位秒。

Examples 范例

Retrieving availability information for an service 检索服务的可用性信息

Retrieve availability information about a service during a week. 检索有关服务在一周内的可用性信息。

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "service.getsla",
  4. "params": {
  5. "serviceids": "2",
  6. "intervals": [
  7. {
  8. "from": 1352452201,
  9. "to": 1353057001
  10. }
  11. ]
  12. },
  13. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  14. "id": 1
  15. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "2": {
  5. "status": "3",
  6. "problems": {
  7. "13904": {
  8. "triggerid": "13904",
  9. "expression": "{13359}=0",
  10. "description": "Service unavailable",
  11. "url": "",
  12. "status": "0",
  13. "value": "1",
  14. "priority": "3",
  15. "lastchange": "1352967420",
  16. "comments": "",
  17. "error": "",
  18. "templateid": "0",
  19. "type": "0",
  20. "value_flags": "0",
  21. "flags": "0"
  22. }
  23. },
  24. "sla": [
  25. {
  26. "from": 1352452201,
  27. "to": 1353057001,
  28. "sla": 97.046296296296,
  29. "okTime": 586936,
  30. "problemTime": 17864,
  31. "downtimeTime": 0
  32. }
  33. ]
  34. }
  35. },
  36. "id": 1
  37. }

See also 参考

Source 源码

CService::getSla() in frontends/php/include/classes/api/services/CService.php. CService::getSla()方法可在frontends/php/include/classes/api/services/CService.php中参考。