Ad Widget

Collapse

API: hostgroup.get with filter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hm75
    Junior Member
    • May 2013
    • 2

    #1

    API: hostgroup.get with filter

    Hello
    i use zabbix 2.0.6 and want to automate the configuration of the monitored hosts. Therefore i tried to use the api to get a list of all hostgroups from a given host. The Problem ist, whateveer i use as filter, i alway get a list of all hostgroups as respond. The json request i used is
    Code:
    {
    "jsonrpc":"2.0",
    "method":"hostgroup.getobjects",
    "params":{
    	"output":"extend",
    	"filter":{
    		"nodeids":["10111"]
    		}
    	},
    	"auth":"dbc1b01280447cf95b886986ca2b1bc4",
    	"id":"13693129326839"
    }
    Any suggestions what is wrong?
  • Heilig
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2013
    • 366

    #2
    Try this code:
    Code:
    {
    "jsonrpc":"2.0",
    "method":[B]"hostgroup.get"[/B],
    "params":{
    	"output":"extend",
    	[B]"hostids":"10111"[/B]
    	      },
    	"auth":"dbc1b01280447cf95b886986ca2b1bc4",
    	"id":"13693129326839"
    }

    Comment

    • Heilig
      Senior Member
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Mar 2013
      • 366

      #3
      OR
      Code:
      {"jsonrpc":"2.0",
      "method":"host.get",
      "params":{"filter":{"host":"Zabbix server"},"selectGroups":"extend"},"auth":...}

      Comment

      • hm75
        Junior Member
        • May 2013
        • 2

        #4
        Sorry for the late respond and thanks for your help.
        The only working solution i have found is
        Code:
        {"jsonrpc":"2.0",
        	"method":"host.get",
        	"params":{
        		"filter":{
        			"hostid":"10111"
        		},
        		"selectGroups":"extend"
        	},
        	"auth":...
        }
        Has anybody futher information why the other way return always all groups as respond. Is the mistake in the api dacumentation or in my way of generatiing the json request?

        Comment

        • Heilig
          Senior Member
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Mar 2013
          • 366

          #5
          Originally posted by hm75
          Is the mistake in the api dacumentation or in my way of generatiing the json request?
          The second.

          Comment

          • Pavels
            Member
            • Oct 2011
            • 83

            #6
            The easiest way to do it would be to use the hostgroup.get method with the hostids parameter:

            Code:
            {
                "jsonrpc": "2.0",
                "method": "hostgroup.get",
                "params": {
                    "output": "extend",
                    "hostids": "10111"
                },
                "id": 3,
                "auth": "0a64b1dbefe61264d88a3d5bee3b8ae2"
            }
            Refer to the API documentation for additional information

            Comment

            Working...