获取
描述
integer/array hostinterface.get(object parameters)
该方法允许根据给定参数检索主机接口。
任何类型的用户都可以使用该方法。调用该方法的权限可在用户角色设置中撤销。 更多信息请参阅 用户角色。
参数
(object) 定义所需输出的参数。
该方法支持以下参数。
| 参数 | 类型 | 描述 |
|---|---|---|
| hostids | ID/array | 仅返回给定主机使用的主机接口。 |
| interfaceids | ID/array | 仅返回具有给定 ID 的主机接口。 |
| itemids | ID/array | 仅返回给定监控项使用的主机接口。 |
| triggerids | ID/array | 仅返回给定触发器中的监控项所使用的主机接口。 |
| selectItems | query | 返回一个 items 属性,其中包含使用该接口的监控项。支持 count。 |
| selectHosts | query | 返回一个 hosts 属性,其中包含使用该接口的主机数组。 |
| limitSelects | integer | 限制子选择返回的记录数。 适用于以下子选择: selectItems。 |
| sortfield | string/array | 按给定属性对结果进行排序。 可能的值: interfaceid、dns、ip。 |
| countOutput | boolean | 这些参数在参考说明中进行了说明。 |
| 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": "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.