[comment]: # translation:outdated

[comment]: # ({f9178426-f9178426})
# service.getsla

[comment]: # ({/f9178426-f9178426})

[comment]: # ({39490ff9-39490ff9})
### Description

`object service.getsla(object parameters)`

This method allows to calculate availability information about services.

[comment]: # ({/39490ff9-39490ff9})

[comment]: # ({bcbf1cf2-bcbf1cf2})
### Parameters

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

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Description|
|---------|---------------------------------------------------|-----------|
|serviceids|string/array|IDs of services to return availability information for.|
|intervals|array|Time intervals to return service layer availability information about.<br><br>Each time interval must have the following parameters:<br>- `from` - *(timestamp)* interval start time;<br>- `to` - *(timestamp)* interval end time.|

[comment]: # ({/bcbf1cf2-bcbf1cf2})

[comment]: # ({c3636e19-c3636e19})
### Return values

`(object)` Returns the following availability information about each
service under the corresponding service ID.

|Property|[Type](/manual/api/reference_commentary#data_types)|Description|
|--------|---------------------------------------------------|-----------|
|status|integer|Current status of the service.<br><br>Refer to the [service object page](object#service) for more information on service statuses.|
|problems|array|[Triggers](/manual/api/reference/trigger/object) that are currently in problem state and are linked either to the service or one of its descendants.|
|sla|array|SLA data about each time period.<br><br>Each SLA object has the following properties:<br>- `from` - *(timestamp)* interval start time;<br>- `to` - *(timestamp)* interval end time;<br>- `sla` - *(float)* SLA for the given time interval;<br>- `okTime` - *(integer)* time the service was in OK state, in seconds;<br>- `problemTime` - *(integer)* time the service was in problem state, in seconds;<br>- `downtimeTime` - *(integer)* time the service was in scheduled downtime, in seconds.|

[comment]: # ({/c3636e19-c3636e19})

[comment]: # ({b41637d2-b41637d2})
### Examples

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({6803e496-6803e496})
#### Retrieving availability information for an service

Retrieve availability information about a service during a week.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "service.getsla",
    "params": {
        "serviceids": "2",
        "intervals": [
            {
                "from": 1352452201,
                "to": 1353057001
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "2": {
            "status": "3",
            "problems": {
                "13904": {
                    "triggerid": "13904",
                    "expression": "{13359}=0",
                    "description": "Service unavailable",
                    "url": "",
                    "status": "0",
                    "value": "1",
                    "priority": "3",
                    "lastchange": "1352967420",
                    "comments": "",
                    "error": "",
                    "templateid": "0",
                    "type": "0",
                    "value_flags": "0",
                    "flags": "0"
                }
            },
            "sla": [
                {
                    "from": 1352452201,
                    "to": 1353057001,
                    "sla": 97.046296296296,
                    "okTime": 586936,
                    "problemTime": 17864,
                    "downtimeTime": 0
                }
            ]
        }
    },
    "id": 1
}
```

[comment]: # ({/6803e496-6803e496})

[comment]: # ({798081d6-798081d6})
### See also

-   [Trigger](/manual/api/reference/trigger/object#trigger)

[comment]: # ({/798081d6-798081d6})

[comment]: # ({a5414084-a5414084})
### Source

CService::getSla() in *ui/include/classes/api/services/CService.php*.

[comment]: # ({/a5414084-a5414084})
