dservice.get

Description

integer/array dservice.get(object **parameters**)

The method allows to retrieve discovered 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.

ParameterTypeDescription
dserviceidsstring/arrayReturn only discovered services with the given IDs.
dhostidsstring/arrayReturn only discovered services that belong to the given discovered hosts.
dcheckidsstring/arrayReturn only discovered services that have been detected by the given discovery checks.
druleidsstring/arrayReturn only discovered services that have been detected by the given discovery rules.
selectDRulesqueryReturn a drules property with an array of the discovery rules that detected the service.
selectDHostsqueryReturn a dhosts property with an array the discovered hosts that the service belongs to.
selectHostsqueryReturn a hosts property with the hosts with the same IP address and proxy as the service.

Supports count.
limitSelectsintegerLimits the number of records returned by subselects.

Applies to the following subselects:
selectHosts - result will be sorted by hostid.
sortfieldstring/arraySort the result by the given properties.

Possible values are: dserviceid, dhostid and ip.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
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

Retrieve services discovered on a host

Retrieve all discovered services detected on discovered host “11”.

Request:

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

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "dserviceid": "12",
  6. "dhostid": "11",
  7. "value": "",
  8. "port": "80",
  9. "status": "1",
  10. "lastup": "0",
  11. "lastdown": "1348650607",
  12. "dcheckid": "5",
  13. "ip": "192.168.1.134",
  14. "dns": "john.local"
  15. },
  16. {
  17. "dserviceid": "13",
  18. "dhostid": "11",
  19. "value": "",
  20. "port": "21",
  21. "status": "1",
  22. "lastup": "0",
  23. "lastdown": "1348650610",
  24. "dcheckid": "6",
  25. "ip": "192.168.1.134",
  26. "dns": "john.local"
  27. }
  28. ],
  29. "id": 1
  30. }

See also

Source

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