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上探测到发现的服务

请求:

{
           "jsonrpc": "2.0",
           "method": "dservice.get",
           "params": {
               "output": "extend",
               "dhostids": "11"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "dserviceid": "12",
                   "dhostid": "11",
                   "value": "",
                   "port": "80",
                   "status": "1",
                   "lastup": "0",
                   "lastdown": "1348650607",
                   "dcheckid": "5",
                   "ip": "192.168.1.134",
                   "dns": "john.local"
               },
               {
                   "dserviceid": "13",
                   "dhostid": "11",
                   "value": "",
                   "port": "21",
                   "status": "1",
                   "lastup": "0",
                   "lastdown": "1348650610",
                   "dcheckid": "6",
                   "ip": "192.168.1.134",
                   "dns": "john.local"
               }
           ],
           "id": 1
       }

参考

来源

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