integer/array hostgroup.get(object parameters)
该方法允许根据给定的参数检索 主机 组。
此方法适用于任何类型的用户。可以在用户角色设置中撤销调用该方法的权限。更多信息请参见 User roles。
(object)
参数定义了期望的输出。
该方法支持以下参数。
参数 | 数据类型 | 描述 |
---|---|---|
graphids | ID/array | 仅返回包含具有给定图表的主机的主机组。 |
groupids | ID/array | 仅返回具有给定主机组 ID的主机组。 |
hostids | ID/array | 仅返回包含给定主机的主机组。 |
maintenanceids | ID/array | 仅返回受给定维护影响的主机组。 |
triggerids | ID/array | 仅返回包含具有给定触发器的主机的主机组。 |
with_graphs | flag | 仅返回包含具有图表的主机的主机组。 |
with_graph_prototypes | flag | 仅返回包含具有图表原型的主机的主机组。 |
with_hosts | flag | 仅返回包含给定主机的主机组。 |
with_httptests | flag | 仅返回包含具有Web检查的主机的主机组。 覆盖 with_monitored_httptests 参数。 |
with_items | flag | 仅返回包含具有监控项的主机的主机组。 覆盖 with_monitored_items 和with_simple_graph_items 参数。 |
with_item_prototypes | flag | 仅返回包含具有监控项原型的主机的主机组。 覆盖 with_simple_graph_item_prototypes 参数。 |
with_simple_graph_item_prototypes | flag | 仅返回包含具有已启用创建且信息类型为数值的监控项原型的主机所在的主机组。 |
with_monitored_httptests | flag | 仅返回包含已启用Web检查的主机的主机组。 |
with_monitored_hosts | flag | 仅返回包含受监控的主机的主机组。 |
with_monitored_items | flag | 仅返回包含具有已启用的监控项的主机的主机组。 覆盖 with_simple_graph_items 参数。 |
with_monitored_triggers | flag | 仅返回包含具有已启用触发器的主机的主机组。触发器中使用的所有监控项也必须已启用。 |
with_simple_graph_items | flag | 仅返回包含具有数值型监控项的主机的主机组。 |
with_triggers | flag | 仅返回包含具有触发器的主机的主机组。 覆盖 with_monitored_triggers 参数。 |
selectDiscoveryRules | query | 返回一个包含发现主机组的LLD规则的discoveryRules 属性。 |
selectGroupDiscoveries | query | 返回一个包含主机组发现objects的groupDiscoveries 属性。每个主机组发现object是一个链接到已发现主机组的一个主机组原型,并具有以下属性: parent_group_prototypeid - 已发现主机组的主机组原型的(ID) ID;name - (string) 名称的主机组原型;lastcheck - (timestamp) 主机组最后被发现的时间;ts_delete - (timestamp) 不再被发现的主机组将被删除的时间;status - (int) 主机组发现状态:0 - (默认) 主机组被发现, 1 - 主机组不再被发现。 |
selectHostPrototypes | query | 返回一个包含发现此主机组的主机原型的hostPrototypes 属性。 |
selectHosts | query | 返回一个包含属于主机组的主机的hosts 属性。支持 count 。 |
limitSelects | integer | 限制子查询返回的记录数量。 适用于以下子查询: selectHosts - 结果将按host 排序。 |
sortfield | string/array | 按给定属性对结果进行排序。 可能的值: groupid 、name 。 |
countOutput | boolean | 这些参数在通用get方法参数中描述。 |
editable | boolean | |
excludeSearch | boolean | |
filter | object | |
limit | integer | |
output | query | |
preservekeys | boolean | |
search | object | |
searchByAny | boolean | |
searchWildcardsEnabled | boolean | |
sortorder | string/array | |
startSearch | boolean | |
monitored_hosts (deprecated) |
flag | 此参数已弃用,请改用with_monitored_hosts 。仅返回包含受监控的主机的主机组。 |
real_hosts (deprecated) |
flag | 此参数已弃用,请改用with_hosts 。仅返回包含给定主机的主机组。 |
(integer/array)
返回以下之一:
countOutput
参数,则为检索到的 objects 的数量。检索有关两个名为 "Zabbix servers" 和 "Linux servers" 的 主机 组的所有数据。
执行请求:
{
"jsonrpc": "2.0",
"method": "hostgroup.get",
"params": {
"output": "extend",
"filter": {
"name": [
"Zabbix servers",
"Linux servers"
]
}
},
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": [
{
"groupid": "2",
"name": "Linux servers",
"internal": "0"
},
{
"groupid": "4",
"name": "Zabbix servers",
"internal": "0"
}
],
"id": 1
}
CHostGroup::get() 在 ui/include/classes/api/services/CHostGroup.php 中。