Zabbix Documentation 4.0

3.04.04.2 (current)| In development:4.4 (devel)| Unsupported:1.82.02.22.43.23.4Guidelines

User Tools

Site Tools


Sidebar

zh:manual:api:reference:hostinterface:get

获取

描述

integer/array hostinterface.get(object parameters)

此方法允许获取给定参数的主机接口记录

参数

(对象) 定义期望输出的参数.

该方法支持以下参数.

参数 类型 描述
hostids 字符串/数组 返回给定主机使用的主机接口.
interfaceids 字符串/数组 返回给定ID的主机接口.
itemids 字符串/数组 返回给定项目的主机接口.
triggerids 字符串/数组 返回给定触发器中项目使用的主机接口.
selectItems 查询 返回items属性中使用接口的监控项.

支持 count.
selectHosts 查询 返回hosts属性中使用接口作为数组的主机.
limitSelects 整数 限制子选择返回的记录数.

适用于以下子选项:
selectItems.
sortfield 字符串/数组 按照给定的属性对结果进行排序.

可能的值: interfaceid, dns, ip.
countOutput 布尔值这些参数对于所有get方法都是通用的,详情可参考 reference commentary.
editable 布尔值
excludeSearch 布尔值
filter 对象
limit 整数
nodeids 字符串/数组
output 查询
preservekeys 布尔值
search 对象
searchByAny 布尔值
searchWildcardsEnabled 布尔值
sortorder 字符串/数组
startSearch 布尔值

返回值

(整数/数组) 返回:

  • 一组对象;
  • 如果设置了countOutput参数,则返回获取到的对象数量.

示例

获取主机接口

获取ID为''30057'的主机使用的接口的所有数据.

请求:

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

响应:

{
    "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
}

参考

来源

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