这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

获取

描述

integer/array hostgroup.get(object parameters)

该方法允许根据指定的参数获取主机组。

参数

(object) 定义期望输出的参数。

该方法支持以下参数:

参数 [ 型](/zh/manual/api/reference_commentary#data_types) 描述
graphids 字符串/数组 返回包含 有给定图表的主机或模板的主机组。
groupids 字符串/数组 返回给定 机组ID的主机组。
hostids 字符串/数组 返回包含 定主机的主机组。
maintenanceids 字符串/数组 返回受指 维护影响的主机组。
monitored_hosts 标识 返 包含受监视主机的主机组。
real_hosts 标识 返 包含主机的主机组。
templated_hosts 标识 返 包含模板的主机组。
templateids 字符串/数组 返回包含 定模板的主机组。
triggerids 字符串/数组 返回包含 定触发器的主机或模板的主机组。
with_applications 标识 返 给定应用集包含主机的主机组。
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 查询 在 discoveryRule](/zh/manual/api/reference/drule/object)属性中返回创建主机组的发现规则。
selectGroupDiscovery 查询 在 groupDiscovery属性中返回主机组发现对象。

主机组发现对象将发现的主机组链接到主机组原型,并具有以下属性:
groupid-(字符串)I已经发现主机组的ID;
lastcheck-(时间戳)主机组最后一次被发现的时间;
name-(字符串)主机组原型的名称;
parent_group_prototypeid-(字符串)创建主机组的主机组原型的ID;
ts_delete-(时间戳)主机组不再被发现删除的时间。| |selectHosts|查询 在|hosts](/zh/manual/api/reference/host/object)属性中返回归属主机组的主机。

支持
count。| |selectTemplates|查询 在|templates](/zh/manual/api/reference/template/object)属性中返回归属主机组的模板。

支持
count。| |limitSelects|整数 限|子选择返回的记录数.

适用于以下子选项:
selectHosts- 结果将按host排序;
selectTemplates- 结果将按host排序。| |sortfield|字符串/数组 根据给定|属性排序.

可能值:
groupidname。| |countOutput|布尔值 这些|数对于所有get`方法都是通用的,详情可参考reference commentary
editable 布尔值 ::
excludeSearch 布尔值 ::
filter 对象 : :
limit 整数 : :
output 查询 : :
preservekeys 布尔值 ::
search 对象 : :
searchByAny 布尔值 ::
searchWildcardsEnabled 布尔值 ::
sortorder 字符串/数组 :::
startSearch 布尔值 ::

返回值

(integer/array) 返回:

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

示例

根据名称获取数据

获取所有关于主机组Zabbix serversLinux 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() in ui/include/classes/api/services/CHostGroup.php.