整数/数组 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 | 按照给定的属性对结果进行排序. 可能的值: dhostid 和 druleid. |
| 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的发现规则发现的所有主机及其上正在运行的服务
请求:
{
"jsonrpc": "2.0",
"method": "dhost.get",
"params": {
"output": "extend",
"selectDServices": "extend",
"druleids": "4"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}响应:
{
"jsonrpc": "2.0",
"result": [
{
"dservices": [
{
"dserviceid": "1",
"dhostid": "1",
"type": "4",
"key_": "",
"value": "",
"port": "80",
"status": "0",
"lastup": "1337697227",
"lastdown": "0",
"dcheckid": "5",
"ip": "192.168.1.1",
"dns": "station.company.lan"
}
],
"dhostid": "1",
"druleid": "4",
"status": "0",
"lastup": "1337697227",
"lastdown": "0"
},
{
"dservices": [
{
"dserviceid": "2",
"dhostid": "2",
"type": "4",
"key_": "",
"value": "",
"port": "80",
"status": "0",
"lastup": "1337697234",
"lastdown": "0",
"dcheckid": "5",
"ip": "192.168.1.4",
"dns": "john.company.lan"
}
],
"dhostid": "2",
"druleid": "4",
"status": "0",
"lastup": "1337697234",
"lastdown": "0"
},
{
"dservices": [
{
"dserviceid": "3",
"dhostid": "3",
"type": "4",
"key_": "",
"value": "",
"port": "80",
"status": "0",
"lastup": "1337697234",
"lastdown": "0",
"dcheckid": "5",
"ip": "192.168.1.26",
"dns": "printer.company.lan"
}
],
"dhostid": "3",
"druleid": "4",
"status": "0",
"lastup": "1337697234",
"lastdown": "0"
},
{
"dservices": [
{
"dserviceid": "4",
"dhostid": "4",
"type": "4",
"key_": "",
"value": "",
"port": "80",
"status": "0",
"lastup": "1337697234",
"lastdown": "0",
"dcheckid": "5",
"ip": "192.168.1.7",
"dns": "mail.company.lan"
}
],
"dhostid": "4",
"druleid": "4",
"status": "0",
"lastup": "1337697234",
"lastdown": "0"
}
],
"id": 1
}CDHost::get() in frontends/php/include/classes/api/services/CDHost.php.