Ad Widget

Collapse

How to use API to get hostname belongs to one group

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Oover
    Junior Member
    • Nov 2013
    • 4

    #1

    How to use API to get hostname belongs to one group

    I want to get all hostname that belongs to a special group,such as 'Discovered hosts',how can I achive it? I have tried to use the "host.get",but how can I filter group name?
  • tsalle
    Member
    Zabbix Certified Specialist
    • Oct 2012
    • 79

    #2
    Hi,
    You can use the groupids params to retrieve only hosts that belong to one host group.

    Code:
    {
        "jsonrpc": "2.0",
        "method": "host.get",
        "params": {
            "output": ["host"],
            "groupids": [your hostgroup id],
        },
        "auth": "038e1d7b1735c6a5436ee9eae095879e",
        "id": 2
    }

    Comment

    • Oover
      Junior Member
      • Nov 2013
      • 4

      #3
      Originally posted by tsalle
      Hi,
      You can use the groupids params to retrieve only hosts that belong to one host group.

      Code:
      {
          "jsonrpc": "2.0",
          "method": "host.get",
          "params": {
              "output": ["host"],
              "groupids": [your hostgroup id],
          },
          "auth": "038e1d7b1735c6a5436ee9eae095879e",
          "id": 2
      }
      But I just know the group name not the groupid,how can I achive it in one step?

      Comment

      • kargh
        Junior Member
        • Feb 2014
        • 21

        #4
        Just grab the group ID from the URL. Click on the Host Group and the ID is right there.

        Comment

        Working...