integer/array hostinterface.get(object parameters)
该方法允许根据给定参数检索主机接口。
此方法可供任何类型的用户使用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参阅User roles。
(object)
定义输出结果的参数。
该方法支持以下参数。
参数 | 数据类型 | 描述 |
---|---|---|
hostids | string/array | 仅返回指定主机使用的主机接口。 |
interfaceids | string/array | 仅返回具有指定ID的主机接口。 |
itemids | string/array | 仅返回指定监控项使用的主机接口。 |
triggerids | string/array | 仅返回在指定触发器中由监控项使用的主机接口。 |
selectItems | query | 返回包含使用该接口的监控项的items属性。 支持 count 。 |
selectHosts | query | 返回包含使用该接口的主机的array的hosts属性。 |
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
参数,则返回检索到的objects数量。获取关于主机 "30057"所使用的所有接口数据。
请求:
{
"jsonrpc": "2.0",
"method": "hostinterface.get",
"params": {
"output": "extend",
"hostids": "30057"
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": [
{
"interfaceid": "50039",
"hostid": "30057",
"main": "1",
"type": "1",
"useip": "0",
"ip": "",
"dns": "localhost",
"port": "10050",
"available": "0",
"error": "",
"errors_from": "0",
"disable_until": "0",
"details": []
},
{
"interfaceid": "55082",
"hostid": "30057",
"main": "1",
"type": "2",
"useip": "1",
"ip": "127.0.0.1",
"dns": "",
"port": "161",
"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 文件中。