hostinterface.get

描述

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 返回一个hosts属性,包含使用该接口的主机的array。
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) 返回以下两种情况之一:

  • 一个array的objects;
  • 检索到的objects数量,如果使用了countOutput参数。

示例

检索主机接口

获取关于主机 "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 文件中.