integer/array hostinterface.get(object parameters)
该方法允许根据给定参数检索主机接口。
任何类型的用户都可以使用该方法。调用该方法的权限可在用户角色设置中撤销。 更多信息请参阅 用户角色。
(object)
定义所需输出的参数。
该方法支持以下参数。
参数 | 类型 | 描述 |
---|---|---|
hostids | ID/数组 | 仅返回给定主机所使用的主机接口。 |
interfaceids | ID/数组 | 仅返回具有给定ID的主机接口。 |
itemids | ID/数组 | 仅返回给定监控项所使用的主机接口。 |
triggerids | ID/数组 | 仅返回在给定触发器中的监控项所使用的主机接口。 |
selectItems | 查询 | 返回一个items 属性,其中包含使用该接口的监控项。支持 count 。 |
selectHosts | 查询 | 返回一个hosts 属性,其中包含一个使用该接口的主机数组。 |
limitSelects | 整数 | 限制子查询返回的记录数。 适用于以下子查询: selectItems 。 |
sortfield | 字符串/数组 | 根据给定属性对结果进行排序。 可能的值: interfaceid ,dns ,ip 。 |
countOutput | 布尔值 | 这些参数在参考说明中描述。 |
editable | 布尔值 | |
excludeSearch | 布尔值 | |
filter | 对象 | |
limit | 整数 | |
output | 查询 | |
preservekeys | 布尔值 | |
search | 对象 | |
searchByAny | 布尔值 | |
searchWildcardsEnabled | 布尔值 | |
sortorder | 字符串/数组 | |
startSearch | 布尔值 |
(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": "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}",
"max_repetitions": "10"
}
}
],
"id": 1
}
CHostInterface::get() 在 ui/include/classes/api/services/CHostInterface.php.