This is the documentation page for an unsupported version of Zabbix.
Is this not what you were looking for? Switch to the current version or choose one from the drop-down menu.

service.get

Description

integer/array service.get(object parameters)

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

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 defining the desired output.

The method supports the following parameters.

Parameter Type Description
serviceids string/array Return only services with the given IDs.
parentids string/array Return only services that are linked to the given parent services.
deep_parentids flag Return all direct and indirect child services. Used together with parentids.
childids string/array Return only services that are linked to the given child services.
evaltype integer Rules for tag searching.

Possible values:
0 - (default) And/Or;
2 - Or.
tags object/array of objects Return only services with given tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value.
Format: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...].
An empty array returns all services.

Possible operator values:
0 - (default) Contains;
1 - Equals;
2 - Does not contain;
3 - Does not equal;
4 - Exists;
5 - Does not exist.
problem_tags object/array of objects Return only services with given problem tags. Exact match by tag and case-sensitive or case-insensitive search by tag value depending on operator value.
Format: [{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...].
An empty array returns all services.

Possible operator values:
0 - (default) Contains;
1 - Equals;
2 - Does not contain;
3 - Does not equal;
4 - Exists;
5 - Does not exist.
without_problem_tags flag Return only services without problem tags.
slaids string/array Return only services that are linked to the specific SLA(s).
selectChildren query Return a children property with the child services.

Supports count.
selectParents query Return a parents property with the parent services.

Supports count.
selectTags query Return a tags property with service tags.

Supports count.
selectProblemEvents query Return a problem_events property with an array of problem event objects.

The problem event object has the following properties:
eventid - (string) Event ID;
severity - (string) Current event severity;
name - (string) Resolved event name.

Supports count.
selectProblemTags query Return a problem_tags property with problem tags.

Supports count.
selectStatusRules query Return a status_rules property with status rules.

Supports count.
selectStatusTimeline object/array of objects Return a status_timeline property containing service state changes for given periods.

Format [{"period_from": "<period_from>", "period_to": "<period_to>"}, ...] - period_from being a starting date (inclusive; integer timestamp) and period_to being an ending date (exclusive; integer timestamp) for the period you're interested in.

Returns an array of entries containing a start_value property and an alarms array for the state changes within specified periods.
sortfield string/array Sort the result by the given properties.

Possible values are: serviceid, name, status, sortorder and created_at.
countOutput boolean These parameters being common for all get methods are described in detail in the reference commentary.
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

Return values

(integer/array) Returns either:

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

Examples

Retrieving all services

Retrieve all data about all services and their dependencies.

Request:

{
           "jsonrpc": "2.0",
           "method": "service.get",
           "params": {
               "output": "extend",
               "selectChildren": "extend",
               "selectParents": "extend"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "serviceid": "1",
                   "name": "My Service - 0001",
                   "status": "-1",
                   "algorithm": "2",
                   "sortorder": "0",
                   "weight": "0",
                   "propagation_rule": "0",
                   "propagation_value": "0",
                   "description": "My Service Description 0001.",
                   "uuid": "dfa4daeaea754e3a95c04d6029182681",
                   "created_at": "946684800",
                   "readonly": false,
                   "parents": [],
                   "children": []
               },
               {
                   "serviceid": "2",
                   "name": "My Service - 0002",
                   "status": "-1",
                   "algorithm": "2",
                   "sortorder": "0",
                   "weight": "0",
                   "propagation_rule": "0",
                   "propagation_value": "0",
                   "description": "My Service Description 0002.",
                   "uuid": "20ea0d85212841219130abeaca28c065",
                   "created_at": "946684800",
                   "readonly": false,
                   "parents": [],
                   "children": []
               }
           ],
           "id": 1
       }

Source

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