dhost.get

Description

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

The method allows to retrieve discovered hosts according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
dhostidsstring/arrayReturn only discovered hosts with the given IDs.
druleidsstring/arrayReturn only discovered hosts that have been created by the given discovery rules.
dserviceidsstring/arrayReturn only discovered hosts that are running the given services.
selectDRulesqueryReturn a drules property with an array of the discovery rules that detected the host.
selectDServicesqueryReturn a dservices property with the discovered services running on the host.

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

Applies to the following subselects:
selectDServices - results will be sorted by dserviceid.
sortfieldstring/arraySort the result by the given properties.

Possible values are: dhostid and druleid.
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 discovered hosts by discovery rule

Retrieve all hosts and the discovered services they are running that have been detected by discovery rule “4”.

Request:

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

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "dservices": [
  6. {
  7. "dserviceid": "1",
  8. "dhostid": "1",
  9. "type": "4",
  10. "key_": "",
  11. "value": "",
  12. "port": "80",
  13. "status": "0",
  14. "lastup": "1337697227",
  15. "lastdown": "0",
  16. "dcheckid": "5",
  17. "ip": "192.168.1.1",
  18. "dns": "station.company.lan"
  19. }
  20. ],
  21. "dhostid": "1",
  22. "druleid": "4",
  23. "status": "0",
  24. "lastup": "1337697227",
  25. "lastdown": "0"
  26. },
  27. {
  28. "dservices": [
  29. {
  30. "dserviceid": "2",
  31. "dhostid": "2",
  32. "type": "4",
  33. "key_": "",
  34. "value": "",
  35. "port": "80",
  36. "status": "0",
  37. "lastup": "1337697234",
  38. "lastdown": "0",
  39. "dcheckid": "5",
  40. "ip": "192.168.1.4",
  41. "dns": "john.company.lan"
  42. }
  43. ],
  44. "dhostid": "2",
  45. "druleid": "4",
  46. "status": "0",
  47. "lastup": "1337697234",
  48. "lastdown": "0"
  49. },
  50. {
  51. "dservices": [
  52. {
  53. "dserviceid": "3",
  54. "dhostid": "3",
  55. "type": "4",
  56. "key_": "",
  57. "value": "",
  58. "port": "80",
  59. "status": "0",
  60. "lastup": "1337697234",
  61. "lastdown": "0",
  62. "dcheckid": "5",
  63. "ip": "192.168.1.26",
  64. "dns": "printer.company.lan"
  65. }
  66. ],
  67. "dhostid": "3",
  68. "druleid": "4",
  69. "status": "0",
  70. "lastup": "1337697234",
  71. "lastdown": "0"
  72. },
  73. {
  74. "dservices": [
  75. {
  76. "dserviceid": "4",
  77. "dhostid": "4",
  78. "type": "4",
  79. "key_": "",
  80. "value": "",
  81. "port": "80",
  82. "status": "0",
  83. "lastup": "1337697234",
  84. "lastdown": "0",
  85. "dcheckid": "5",
  86. "ip": "192.168.1.7",
  87. "dns": "mail.company.lan"
  88. }
  89. ],
  90. "dhostid": "4",
  91. "druleid": "4",
  92. "status": "0",
  93. "lastup": "1337697234",
  94. "lastdown": "0"
  95. }
  96. ],
  97. "id": 1
  98. }

See also

Source

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