integer/array hostgroup.get(object parameters)
该方法允许根据给定参数检索主机组。
任何类型的用户都可以使用该方法。调用该方法的权限可在用户角色设置中撤销。 更多信息,请参阅 用户角色。
(object)
定义所需输出的参数。
该方法支持以下参数。
参数 | 类型 | 描述 |
---|---|---|
graphids | ID/数组 | 仅返回包含具有指定图形的主机的主机群组。 |
groupids | ID/数组 | 仅返回具有指定主机群组ID的主机群组。 |
hostids | ID/数组 | 仅返回包含指定主机的主机群组。 |
maintenanceids | ID/数组 | 仅返回受指定维护影响的主机群组。 |
triggerids | ID/数组 | 仅返回包含具有指定触发器的主机的主机群组。 |
with_graphs | 标记 | 仅返回包含具有图形的主机的主机群组。 |
with_graph_prototypes | 标记 | 仅返回包含具有图形原型的主机的主机群组。 |
with_hosts | 标记 | 仅返回包含主机的主机群组。 |
with_httptests | 标记 | 仅返回包含具有web检查的主机的主机群组。 覆盖 with_monitored_httptests 参数。 |
with_items | 标记 | 仅返回包含具有监控项的主机的主机群组。 覆盖 with_monitored_items 和with_simple_graph_items 参数。 |
with_item_prototypes | 标记 | 仅返回包含具有监控项原型的主机的主机群组。 覆盖 with_simple_graph_item_prototypes 参数。 |
with_simple_graph_item_prototypes | 标记 | 仅返回包含具有启用创建和数值类型信息的监控项原型的主机的主机群组。 |
with_monitored_httptests | 标记 | 仅返回包含启用web检查的主机的主机群组。 |
with_monitored_hosts | 标记 | 仅返回包含受监控的主机的主机群组。 |
with_monitored_items | 标记 | 仅返回包含启用监控项的主机的主机群组。 覆盖 with_simple_graph_items 参数。 |
with_monitored_triggers | 标记 | 仅返回包含启用触发器的主机的主机群组。触发器中使用的所有监控项也必须启用。 |
with_simple_graph_items | 标记 | 仅返回包含具有数值监控项的主机的主机群组。 |
with_triggers | 标记 | 仅返回包含具有触发器的主机的主机群组。 覆盖 with_monitored_triggers 参数。 |
selectDiscoveryRules | 查询 | 返回一个[发现规则](/manual/api/reference/discoveryrule/object) 属性,包含发现该主机群组的LLD规则。 |
selectGroupDiscoveries | 查询 | 返回一个groupDiscoveries 属性,包含主机群组发现对象。每个主机群组发现对象是一个与发现的主机群组关联的主机群组原型,具有以下属性: parent_group_prototypeid - (ID) 从其中发现主机群组的主机群组原型的ID;name - (字符串) 主机群组原型的名称;lastcheck - (时间戳) 上次发现主机群组的时间;ts_delete - (时间戳) 不再发现的主机群组将被删除的时间;status - (整数) 主机群组发现状态:0 - (默认) 主机群组被发现, 1 - 主机群组不再被发现。 |
selectHostPrototypes | 查询 | 返回一个[主机原型](/manual/api/reference/hostprototypes/object) 属性,包含发现此主机群组的主机原型。 |
selectHosts | 查询 | 返回一个[主机](/manual/api/reference/host/object) 属性,包含属于主机群组的主机。支持 计数 。 |
limitSelects | 整数 | 限制子查询返回的记录数。 适用于以下子查询: selectHosts - 结果将按host 排序。 |
sortfield | 字符串/数组 | 按给定属性对结果进行排序。 可能的值: groupid ,name 。 |
countOutput | 布尔值 | 这些参数在参考说明中描述。 |
editable | 布尔值 | |
excludeSearch | 布尔值 | |
filter | 对象 | |
limit | 整数 | |
output | 查询 | |
preservekeys | 布尔值 | |
search | 对象 | |
searchByAny | 布尔值 | |
searchWildcardsEnabled | 布尔值 | |
sortorder | 字符串/数组 | |
startSearch | 布尔值 | |
monitored_hosts (已废弃) |
标记 | 此参数已废弃,请改用with_monitored_hosts 。仅返回包含受监控的主机的主机群组。 |
real_hosts (已废弃) |
标记 | 此参数已废弃,请改用with_hosts 。仅返回包含主机的主机群组。 |
(integer/array)
返回二者之一:
countOutput
参数,则读取的对象数量。检索名为 "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.