integer/array hostgroup.get(object parameters)
The method allows to retrieve host groups according to the given parameters.该方法允许根据给定的参数检索主机组。
(object)
Parameters defining the desired output. 定义所需输出的参数。
The method supports the following parameters.该方法支持以下参数。
参数 类 | 描述 | |
---|---|---|
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. 只返回具有给定主机组ID的主机组。 |
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.仅返回包含受监视主机的主机组。 |
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_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.仅返回包含具有Web检查的主机的主机组。 Overrides the with_monitored_httptests parameter.覆盖“with_monitored_httptests”参数。 |
with_items | flag | Return only host groups that contain hosts or templates with items.仅返回包含主题或包含项目的模板的主机组。 Overrides the with_monitored_items andwith_simple_graph_items parameters.覆盖“with_monitored_items”和"with_simple_graph_items“参数。 |
with_monitored_httptests | flag | Return only host groups that contain hosts with enabled web checks.仅返回包含启用Web检查的主机的主机组。 |
with_monitored_items | flag | Return only host groups that contain hosts or templates with enabled items.仅返回包含启用项目的主机或模板的主机组。 Overrides the with_simple_graph_items parameter.覆盖with_simple_graph_items 参数。 |
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. 覆盖“with_monitored_triggers”参数。 |
selectDiscoveryRule | query | Return the LLD rule that created the host group in the discoveryRule property.返回在“discoveryRule”属性中创建主机组的LLD规则。 |
selectGroupDiscovery | query | Return the host group discovery object in the groupDiscovery property. 在“groupDiscovery”属性中返回主机组发现对象。The host group discovery object links a discovered host group to a host group prototype and has the following properties: 主机组发现对象将发现的主机组链接到主机组原型,并具有以下属性: groupid - (string) ID of the discovered host group; 发现的主机组的ID;lastcheck - (timestamp) time when the host group was last discovered;主机组最后发现的时间;name - (string) name of the host goup prototype;主机组名称原型;parent_group_prototypeid - (string) ID of the host group prototype from which the host group has been created;创建主机组的主机组原型的ID;ts_delete - (timestamp) time when a host group that is no longer discovered will be deleted.不再发现主机组将被删除的时间。 |
selectHosts | query | Return the hosts that belong to the host group in the hosts property.在“hosts”属性中返回属于主机组的主机。Supports count . |
selectTemplates | query | Return the templates that belong to the host group in the templates property. 在“”模板“”属性中返回属于主机组的模板。Supports count . |
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 . 可能的值为:groupid ,name 。 |
countOutput | flag | These parameters being common for all get methods are described in detail in the reference commentary page. 这些参数对于所有的“获取”方法是常见的,在参考评论页中有详细描述。 |
editable | boolean | |
excludeSearch | flag | |
filter | object | |
limit | integer | |
output | query | |
preservekeys | flag | |
search | object | |
searchByAny | boolean | |
searchWildcardsEnabled | boolean | |
sortorder | string/array | |
startSearch | flag |
(integer/array)
Returns either:返回:
countOutput
parameter has been used.如果已经使用“countOutput”参数,则检索到的对象的计数。Retrieve all data about two host groups named "Zabbix servers" and "Linux servers".检索有关名为“Zabbix服务器”和“Linux服务器”的两个主机组的所有数据。
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
}
CHostGroup::get() in frontends/php/include/classes/api/services/CHostGroup.php.