Zabbix Documentation 2.0

3.04.04.24.4 (current)| In development:5.0 (devel)| Unsupported:1.82.02.22.43.23.4Guidelines

User Tools

Site Tools


Sidebar

manual:appendix:api:hostgroup:get

hostgroup.get

Description

integer/array hostgroup.get(object parameters)

The method allows to retrieve host groups according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

Parameter Type Description
graphids string/array Return only host groups that contain hosts or templates with the given graphs.
groupids string/array Return only host groups with the given host group IDs.
hostids string/array Return only host groups that contain the given hosts.
maintenanceids string/array Return only host groups that are affected by the given maintenances.
monitored_hosts flag Return only host groups that contain monitored hosts.
not_proxy_hosts flag Return only host groups that do not contain proxies.
real_hosts flag Return only host groups that contain hosts.
templated_hosts flag Return only host groups that contain templates.
templateids string/array Return only host groups that contain the given templates.
triggerids string/array Return only host groups that contain hosts or templates with the given triggers.
with_applications flag Return only host groups that contain hosts with applications.
with_graphs flag Return only host groups that contain hosts with graphs.
with_historical_items flag Return only host groups that contain hosts with enabled or not supported items with historical data.

Overrides the with_simple_graph_items parameter.
with_hosts_and_templates flag Return only host groups that contain hosts or templates.
with_httptests flag Return only host groups that contain hosts with web checks.

Overrides the with_monitored_httptests parameter.
with_items flag Return only host groups that contain hosts or templates with items.

Overrides the with_monitored_items, with_historical_items and with_simple_graph_items parameters.
with_monitored_httptests flag Return only host groups that contain hosts with enabled web checks.
with_monitored_items flag Return only host groups that contain hosts or templates with enabled items.

Overrides the with_historical_items and with_simple_graph_items parameters.
with_monitored_triggers flag Return only host groups that contain hosts with enabled triggers. All of the items used in the trigger must also be enabled.
with_simple_graph_items flag Return only host groups that contain hosts with numeric items.
with_triggers flag Return only host groups that contain hosts with triggers.

Overrides the with_monitored_triggers parameter.
selectHosts query Return the hosts that belong to the host group in the hosts property.

Supports count; does not support shorten.
selectTemplates query Return the templates that belong to the host group in the templates property.

Supports count; does not support shorten.
limitSelects integer Limits the number of records returned by subselects.

Applies to the following subselects:
selectHosts - results will be sorted by host;
selectTemplates - results will be sorted by host.
sortfield string/array Sort the result by the given properties.

Possible values are: groupid, name.
countOutputflagThese parameters being common for all get methods are described in detail on the Generic Zabbix API information page.
editable boolean
excludeSearch flag
filter object
limit integer
nodeids string/array
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving data by name

Retrieve all data about two host groups named “Zabbix servers” and “Linux servers”.

Request:

{
    "jsonrpc": "2.0",
    "method": "hostgroup.get",
    "params": {
        "output": "extend",
        "filter": {
            "name": [
                "Zabbix servers",
                "Linux servers"
            ]
        }
    },
    "auth": "6f38cddc44cfbb6c1bd186f9a220b5a0",
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "groupid": "2",
            "name": "Linux servers",
            "internal": "0"
        },
        {
            "groupid": "4",
            "name": "Zabbix servers",
            "internal": "0"
        }
    ],
    "id": 1
}

See also

Source

CHostGroup::get() in frontends/php/api/classes/CHostGroup.php.