Zabbix-主机的组列表

时间:2018-10-16 14:42:20

标签: zabbix

我正在尝试从zabbix获取某些主机的组列表。

curl -X GET -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"hostgroup.get","params":{"output":"extend","filter":{"hostid":"10789"}},"id":1,"auth":"mytoken"}' http://zabbix-server/api_jsonrpc.php

但是对于该特定主机,我没有三个组,而是在我的zabbix服务器上获得了所有组。

我应该更改我的代码吗?

1 个答案:

答案 0 :(得分:0)

摘自API文档:

  

检索组主机“ Zabbix服务器”的名称,但不是   托管自己的详细信息。

     

请求:

{
    "jsonrpc": "2.0",
    "method": "host.get",
    "params": {
        "output": ["hostid"],
        "selectGroups": "extend",
        "filter": {
            "host": [
                "Zabbix server"
            ]
        }
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 2
}
  

响应:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "hostid": "10085",
            "groups": [
                {
                    "groupid": "2",
                    "name": "Linux servers",
                    "internal": "0",
                    "flags": "0"
                },
                {
                    "groupid": "4",
                    "name": "Zabbix servers",
                    "internal": "0",
                    "flags": "0"
                }
            ]
        }
    ],
    "id": 2
}
相关问题