integer/array hostgroup.get(object parameters)
该方法允许根据给定参数检索主机组.
此方法可供任何类型的用户使用. 调用该方法的权限可以在用户角色设置中撤销. 更多信息请参阅User roles.
(object) 定义所需输出的参数。
该方法支持以下参数。
| 参数 | 数据类型 | 描述 |
|---|---|---|
| graphids | string/array | 仅返回包含主机或具有给定图形的模板的主机组。 |
| groupids | string/array | 仅返回具有指定主机组 ID的主机组。 |
| hostids | string/array | 仅返回包含给定主机的主机组。 |
| maintenanceids | string/array | 仅返回受指定维护影响的主机组。 |
| monitored_hosts | flag | 仅返回包含受监控主机的主机组。 |
| real_hosts | flag | 仅返回包含主机的主机组。 |
| templated_hosts | flag | 仅返回包含模板的 主机 组。 |
| templateids | string/array | 仅返回包含指定模板的 主机 组。 |
| triggerids | string/array | 仅返回包含主机或具有给定触发器模板的主机组。 |
| with_graphs | flag | 仅返回包含带图表主机的主机组。 |
| with_graph_prototypes | flag | 仅返回包含带有图形原型的主机的主机组。 |
| with_hosts_and_templates | 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_items | flag | 仅返回包含主机或启用监控项的模板的主机组。 覆盖 with_simple_graph_items参数。 |
| with_monitored_triggers | flag | 仅返回包含已启用触发器主机的主机组。触发器中使用的所有监控项也必须处于启用状态。 |
| with_simple_graph_items | flag | 仅返回包含具有数值型监控项的主机的主机组。 |
| with_triggers | flag | 仅返回包含带触发器主机的主机组。 覆盖 with_monitored_triggers参数。 |
| selectDiscoveryRule | query | 返回一个包含创建主机组的LLD规则的discoveryRule属性。 |
| selectGroupDiscovery | query | 返回一个包含主机组发现object的groupDiscovery属性。主机组发现object将发现的主机组链接到一个主机组原型,并具有以下属性: groupid - 发现的主机组的(string) ID;lastcheck - 主机组最后一次被发现时的(timestamp)时间;name - 主机组原型的(string)名称;parent_group_prototypeid - 创建主机组的主机组原型的(string) ID;ts_delete - 不再被发现的一个主机组将被删除的(timestamp)时间。 |
| selectHosts | query | 返回一个包含属于主机组的主机的hosts属性。 支持 count。 |
| selectTemplates | query | 返回包含属于主机组的模板的templates属性。 支持 count。 |
| limitSelects | integer | 限制子查询返回的记录数量. 适用于以下子查询类型: selectHosts - 结果将按 host 排序;selectTemplates - 结果将按 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 |
(integer/array) 返回以下两种情况之一:
countOutput参数时)获取名为"Zabbix servers"和"Linux servers"的两个主机组的所有数据。
请求:
{
"jsonrpc": "2.0",
"method": "hostgroup.get",
"params": {
"output": "extend",
"filter": {
"name": [
"Zabbix servers",
"Linux servers"
]
}
},
"auth": "6f38cddc44cfbb6c1bd186f9a220b5a0",
"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 文件中。