dhost.get

描述

整数/数组 dhost.get(对象 参数)

该方法允许根据给定的参数检索已发现的主机

参数

(对象) 定义所需输出的参数

该方法支持以下参数:

参数 类型 描述
dhostids string/array 只返回给定ID的已发现主机.
druleids string/array 只返回给定发现规则(ID)创建的已发现主机.
dserviceids string/array 只返回正在运行给定服务(ID)的已发现主机.
selectDRules query 将探测到主机的发现规则作为drules属性中的数组返回.
selectDServices query 将主机上已发现的服务作为dservices属性返回. 支持 count.
limitSelects integer 限制子选项返回的记录数. 适用于以下子选项: selectDServices - 结果按照dserviceid.
sortfield string/array 按照给定的属性对结果进行排序. 可能的值: dhostiddruleid.
countOutput flag下面这些参数的get方法在reference commentary里面有详细说明.
editable boolean
excludeSearch flag
filter object
limit integer
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

返回值

(integer/array) 返回:

  • 对象数组;

  • 如果使用了countOutput参数,将返回对象的计数.

示例

获取通过发现规则发现的主机

获取所有被ID为4的发现规则发现的所有主机及其上正在运行的服务

请求:

  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. }

响应:

  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. }

参考

来源

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