dservice.get

描述

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

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

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

参数

(object) Parameters defining the desired output.

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

The method supports the following parameters.

该方法支持以下参数

参数 类型 描述
dserviceids string/array Return only discovered services with the given IDs. 只返回指定ID的已发现服务
dhostids string/array Return only discovered services that belong to the given discovered hosts. 只返回指定已发现主机的发现服务
dcheckids string/array Return only discovered services that have been detected by the given discovery checks. 只返回指定检查ID探测到的服务
druleids string/array Return only discovered services that have been detected by the given discovery rules. 只返回给指定现规则ID探测到的服务
selectDRules query Return the discovery rule that detected the service as an array in the drules property. 将探测到服务的发现规则作为drules属性中的数组返回
selectDHosts query Return the discovered host that service belongs to as an array in the dhosts property. 将服务归属的已发现主机作为dhosts 属性中的数组返回
selectHosts query Return the hosts with the same IP address as the service in the hosts property. Supports count.
limitSelects integer Limits the number of records returned by subselects. 限制子选项返回的记录数 Applies to the following subselects: 子选项的应用 selectHosts - result will be sorted by hostid. 结果按照hostid排序
sortfield string/array Sort the result by the given properties. 结果按照指定属性排序 可能的值: dserviceid, dhostidip.
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

返回值

返回整数/数组:

  • 返回一个对象数组;

  • 如果countOutput被使用,返回检索对象的计数.

示例

Retrieve services discovered on a host

检索一台主机上已发现的服务

Retrieve all discovered services detected on discovered host “11”.获取在已发现主机11上探测到发现的服务

请求:

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

响应:

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

参考

来源

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