hostinterface.get

Description

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

The method allows to retrieve host interfaces according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
hostidsstring/arrayReturn only host interfaces used by the given hosts.
interfaceidsstring/arrayReturn only host interfaces with the given IDs.
itemidsstring/arrayReturn only host interfaces used by the given items.
triggeridsstring/arrayReturn only host interfaces used by items in the given triggers.
selectItemsqueryReturn an items property with the items that use the interface.

Supports count.
selectHostsqueryReturn a hosts property with an array of hosts that use the interface.
limitSelectsintegerLimits the number of records returned by subselects.

Applies to the following subselects:
selectItems.
sortfieldstring/arraySort the result by the given properties.

Possible values are: interfaceid, dns, ip.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary page.
editableboolean
excludeSearchboolean
filterobject
limitinteger
nodeidsstring/array
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 host interfaces

Retrieve all data about the interfaces used by host “30057.”

Request:

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

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "interfaceid": "30050",
  6. "hostid": "30057",
  7. "main": "1",
  8. "type": "1",
  9. "useip": "1",
  10. "ip": "127.0.0.1",
  11. "dns": "",
  12. "port": "10050",
  13. "details": []
  14. },
  15. {
  16. "interfaceid": "30067",
  17. "hostid": "30057",
  18. "main": "0",
  19. "type": "1",
  20. "useip": "0",
  21. "ip": "",
  22. "dns": "localhost",
  23. "port": "10050",
  24. "details": []
  25. },
  26. {
  27. "interfaceid": "30068",
  28. "hostid": "30057",
  29. "main": "1",
  30. "type": "2",
  31. "useip": "1",
  32. "ip": "127.0.0.1",
  33. "dns": "",
  34. "port": "161",
  35. "details": {
  36. "version": "2",
  37. "bulk": "0",
  38. "community": "{$SNMP_COMMUNITY}"
  39. }
  40. }
  41. ],
  42. "id": 1
  43. }

See also

Source

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