service.getsla

Description

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

This method allows to calculate availability information about services.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters containing the IDs of the services and time intervals to calculate SLA.

ParameterTypeDescription
serviceidsstring/arrayIDs of services to return availability information for.
intervalsarrayTime 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.

PropertyTypeDescription
statusintegerCurrent status of the service.

Refer to the service object page for more information on service statuses.
problemsarrayTriggers that are currently in problem state and are linked either to the service or one of its descendants.
slaarraySLA data about each time period.

Each SLA object has the following properties:
- from - (timestamp) interval start time;
- to - (timestamp) interval end time;
- sla - (float) SLA for the given time interval;
- 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 ui/include/classes/api/services/CService.php.