获取

描述

hostgroup.get(对象参数)整数/数组

该方法允许根据给定的参数检索主机组。

这个方法仅允许任何用户类型。可以在用户角色中撤销调用方法的权限设置。详情参考 用户角色

参数

(对象) 参数定义所需的输出。

该方法支持以下参数。

参数描述
graphids字符串/数组只返回包含给定图形的主机或模板的主机组。
groupids字符串/数组只返回具有给定主机组id的主机组。
hostids字符串/数组只返回包含给定主机的主机组。
maintenanceids字符串/数组只返回受给定维护影响的主机组。
monitored_hosts标记只返回包含监控主机的主机组。
real_hosts标记只返回包含主机的主机组。
templated_hosts标记只返回包含模板的主机组。
templateids字符串/数组只返回包含给定模板的主机组。
triggerids字符串/数组只返回包含具有给定触发器的主机或模板的主机组。
with_graphs标记只返回包含有图形的主机的主机组。
with_graph_prototypes标记只返回包含带有图形原型的主机的主机组。
with_hosts_and_templates标记只返回包含主机 模板的主机组。
with_httptests标记只返回包含web检查主机的主机组。

覆盖 with_monitored_httptests 参数。
with_items标记只返回包含有监控项的主机或模板的主机组。

覆盖 with_monitored_itemswith_simple_graph_items 参数。
with_item_prototypes标记只返回包含带有监控项原型的主机的主机组。

覆盖 with_simple_graph_item_prototypes 参数。
with_simple_graph_item_prototypes标记只返回包含具有监控项原型的主机的主机组,监控项原型支持创建并具有数字类型的信息。
with_monitored_httptests标记只返回包含启用web检查的主机的主机组。
with_monitored_items标记只返回包含启用监控项的主机或模板的主机组。

覆盖 with_simple_graph_items 参数。
with_monitored_triggers标记只返回包含启用触发器的主机的主机组。触发器中使用的所有监控项也必须启用。
with_simple_graph_items标记只返回包含带有数字监控项的主机的主机组。
with_triggers标记只返回包含有触发器的主机的主机组。

覆盖 with_monitored_triggers 参数。
selectDiscoveryRule查询返回 发现规则 属性和创建主机组的LLD规则。
selectGroupDiscovery查询返回 groupDiscovery 属性和主机组发现对象.

发现主机组对象将发现的主机组链接到主机组原型,具有以下属性:
groupid - (字符串) 发现的主机组ID;
lastcheck - (时间戳) 最后发现主机组的时间;
name - (字符串) 主机组原型的名称;
parent_group_prototypeid - (字符串) 创建主机组的主机组原型ID;
ts_delete - (时间戳) 当主机组未被发现时,删除该主机组的时间。
selectHosts查询返回主机属性和属于主机组的主机。

支持 count.
selectTemplates查询返回 模板 属性和属于主机组的模板。

支持 count.
limitSelects整型限制子查询返回的记录数量。

适用于下列子查询项:
selectHosts - 结果将按 host 排序;
selectTemplates - r结果将按 host 排序。
sortfield字符串/数组根据给定的属性对结果进行排序。

可能的值是: groupid, name.
countOutput布尔值这些对所有 get 方法通用的参数在 参考注释 中有详细描述。
editable布尔值
excludeSearch布尔值
filter对象
limit整型
output查询
preservekeys布尔值
search对象
searchByAny布尔值
searchWildcardsEnabled布尔值
sortorder字符串/数组
startSearch布尔值

返回值

(整数/数组) 返回其中之一:

  • 一组对象;
  • 如果使用了 countOutput 参数,返回对象的数量。

示例

按名称检索数据

检索关于“Zabbix servers”和“Linux servers”两个主机组的所有数据。

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostgroup.get",
  4. "params": {
  5. "output": "extend",
  6. "filter": {
  7. "name": [
  8. "Zabbix servers",
  9. "Linux servers"
  10. ]
  11. }
  12. },
  13. "auth": "6f38cddc44cfbb6c1bd186f9a220b5a0",
  14. "id": 1
  15. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "groupid": "2",
  6. "name": "Linux servers",
  7. "internal": "0"
  8. },
  9. {
  10. "groupid": "4",
  11. "name": "Zabbix servers",
  12. "internal": "0"
  13. }
  14. ],
  15. "id": 1
  16. }

另请参考

源代码

CHostGroup::get() in ui/include/classes/api/services/CHostGroup.php.