integer/array hostinterface.get(object parameters)
该方法允许根据给定参数检索主机接口。
任何类型的用户都可以使用该方法。调用该方法的权限可在用户角色设置中撤销。 更多信息请参阅 用户角色。
(object) 定义所需输出的参数。
该方法支持以下参数。
| 参数 | 类型 | 说明 |
|---|---|---|
| hostids | ID/array | 只返回给定主机使用的主机接口。 |
| interfaceids | ID/array | 只返回具有给定 ID 的主机接口。 |
| itemids | ID/array | 只返回给定监控项使用的主机接口。 |
| triggerids | ID/array | 只返回给定触发器中的项目所使用的主机接口。 |
| selectItems | query | 返回一个 监控项 属性,其中包含使用该接口的监控项。支持 count. |
| selectHosts | query | 返回一个 主机 属性,其中包含一个使用该接口的主机的数组。 |
| limitSelects | integer | 限制子选择返回的记录数。 适用于以下子选择: selectItems. |
| sortfield | string/array | 根据给定的属性对结果进行排序。 可能的值: interfaceid, dns, ip. |
| countOutput | boolean | 这些参数是所有 get 方法的通用参数,详见 参考评注 页面。 |
| editable | boolean | |
| excludeSearch | boolean | |
| filter | object | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean |
(integer/array) 返回二者之一:
countOutput 参数,则读取的对象数量。检索主机 "30057 "所使用接口的所有数据。
请求:
{ "jsonrpc": "2.0", "method": "hostinterface.get", "params": { "output": "extend", "hostids": "30057" }, "id": 1 }响应:
{ "jsonrpc": "2.0", "result": [ { "interfaceid": "50039", "hostid": "30057", "main": "1", "type": "1", "useip": "1", "ip": "::1", "dns": "", "port": "10050", "available": "0", "error": "", "errors_from": "0", "disable_until": "0", "details": [] }, { "interfaceid": "55082", "hostid": "30057", "main": "0", "type": "1", "useip": "1", "ip": "127.0.0.1", "dns": "", "port": "10051", "available": "0", "error": "", "errors_from": "0", "disable_until": "0", "details": { "version": "2", "bulk": "0", "community": "{$SNMP_COMMUNITY}" } } ], "id": 1 }CHostInterface::get() 在 ui/include/classes/api/services/CHostInterface.php.