2022 Zabbix中国峰会
2022 Zabbix中国峰会

hostinterface.get

Description 说明

integer/array hostinterface.get(object parameters)

The method allows to retrieve host interfaces according to the given parameters.该方法允许根据给定的参数检索主机接口。

Parameters 参数

(object) Parameters defining the desired output.定义所需输出的参数。

The method supports the following parameters.该方法支持以下参数。

参数 类 描述
hostids string/array Return only host interfaces used by the given hosts. 仅返回给定主机使用的主机接口。
interfaceids string/array Return only host interfaces with the given IDs.只返回具有给定ID的主机接口。
itemids string/array Return only host interfaces used by the given items.仅返回给定项目使用的主机接口。
triggerids string/array Return only host interfaces used by items in the given triggers.只返回给定触发器中项目使用的主机接口。
selectItems query Return the items that use the interface in the items property.在“items”属性中返回使用界面的项目。

Supports count.支持“计数”。
selectHosts query Return the host that uses the interface as an array in the hosts property. 在“hosts”属性中返回使用该接口作为数组的主机。
limitSelects integer Limits the number of records returned by subselects.限制子选择返回的记录数。

Applies to the following subselects:适用于以下子选项:
selectItems.
sortfield string/array Sort the result by the given properties. 按照给定的属性对结果进行排序。

Possible values are: interfaceid, dns, ip.可能的值为:interfaceiddnsip
countOutput flag These parameters being common for all get methods are described in detail in the reference commentary page. 这些参数对于所有的“获取”方法是常见的,在参考评论页中有详细描述。
editable boolean
excludeSearch flag
filter object
limit integer
nodeids string/array
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

Return values 返回值

(integer/array) Returns either:返回:

  • an array of objects;一组对象;
  • the count of retrieved objects, if the countOutput parameter has been used.如果已经使用“countOutput”参数,则检索到的对象的计数。

Examples 示例

Retrieve host interfaces检索主机接口

Retrieve all data about the interfaces used by host "30057."检索主机“30057”使用的接口的所有数据。

Request:

{
           "jsonrpc": "2.0",
           "method": "hostinterface.get",
           "params": {
               "output": "extend",
               "hostids": "30057"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "interfaceid": "30050",
                   "hostid": "30057",
                   "main": "1",
                   "type": "1",
                   "useip": "1",
                   "ip": "127.0.0.1",
                   "dns": "",
                   "port": "10050",
                   "bulk": "1"
               },
               {
                   "interfaceid": "30067",
                   "hostid": "30057",
                   "main": "0",
                   "type": "1",
                   "useip": "0",
                   "ip": "",
                   "dns": "localhost",
                   "port": "10050",
                   "bulk": "1"
               },
               {
                   "interfaceid": "30068",
                   "hostid": "30057",
                   "main": "1",
                   "type": "2",
                   "useip": "1",
                   "ip": "127.0.0.1",
                   "dns": "",
                   "port": "161",
                   "bulk": "1"
               }
           ],
           "id": 1
       }

See also 参见

Source 来源

CHostInterface::get() in frontends/php/include/classes/api/services/CHostInterface.php.