Ad Widget

Collapse

Zabbix API hostgroup.get(hostids=xxxxxx) returns only one group (three expected)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • technic26
    Junior Member
    • May 2021
    • 1

    #1

    Zabbix API hostgroup.get(hostids=xxxxxx) returns only one group (three expected)

    Hi.

    I run hostgroup.get(hostids=xxxxxx) and get single group but three are expected. Tried both zabbix API and python module ZabbixAPI.
    But in GUI and SQL this host is in three groups.
    I checked other hostids and even other zabbix servers and similar requests return more than 1 group.

    Python ZabbixAPI:
    print(zapi.hostgroup.get(hostids="29320"))

    Output:
    [{'groupid': '48', 'name': 'Group3', 'internal': '0', 'flags': '0'}]

    Postman API payload:
    {
    "jsonrpc": "2.0",
    "method": "hostgroup.get",
    "params": {
    "hostids":"29320"
    },
    "auth": "74aae8378f7032f0a8c8ddfffee3800",
    "id": 1
    }

    Output:
    {
    "jsonrpc": "2.0",
    "result": [
    {
    "groupid": "48",
    "name": "Group3",
    "internal": "0",
    "flags": "0"
    }
    ],
    "id": 1
    }

    BUT
    SQL:
    SELECT hosts.hostid, hosts.host,hg.groupid, hstgrp.name
    from public.hosts
    JOIN public.hosts_groups hg ON hosts.hostid = hg.hostid
    JOIN public.hstgrp hstgrp ON hstgrp.groupid = hg.groupid
    WHERE hosts.hostid =29320;

    Output:
    29320 "PSXXXXXXX_PSS" 79 "Group1"
    29320 "PSXXXXXXX_PSS" 82 "Group2"
    29320 "PSXXXXXXX_PSS" 48 "Group3"

    Zabbix 5.0.2
    DB postgresql-server-12.1-2.module_el8.1.0+273+979c16e6.x86_64
    CentOS Linux release 8.2.2004

    Do I use API wrong?

    Regards.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Exact same "print(zapi.hostgroup.get(hostids="xxxxx"))" returns all groups, if I try it.. I just ran a random host ID and got all 4 groups back as it is supposed to (v4.4 here)

    Comment

    Working...