2022 Zabbix中国峰会
2022 Zabbix中国峰会

查询图表原型

描述

 integer/array graphprototype.get(object parameters)  该方法允许根据指定的参数来检索图表原型。  ::: noteclassic 这种方法对任何类型的用户都适用。调用该方法的权限可以在用户角色设置中被撤销。 前往用户角色以了解更多信息。 :::

参数

(object) 参数定义了所需的输出。

该方法支持下列参数。

参数 类型 描述
discoveryids ID/array 仅返回指定发现规则的图表原型。
graphids ID/array 仅返回指定ID的图表原型
groupids ID/array 仅返回指定主机组或模板组中的主机或模板的图表原型。
hostids ID/array 仅返回指定主机的图表原型。
inherited boolean 如果设置为true仅返回从模版继承的图表原型。
itemids ID/array 仅返回包含指定监控项原型的图表原型。
templated boolean 如果设置为true仅返回模版的图表原型。
templateids ID/array 仅返回指定模版的图表原型。
selectDiscoveryRule query 返回图表原型所属的LLD规则的发现规则的属性。
selectGraphItems query 返回图表原型中使用的图表监控项的属性。
selectHostGroups query 返回图表原型所属的主机组的属性。
selectHosts query 返回图表原型所属的主机的属性。
selectItems query 返回图表原型中使用的监控项监控项原型 的属性。
selectTemplateGroups query 返回监控项原型使用的模版组的属性。
selectTemplates query 返回监控项原型使用的模版的属性。
filter object 仅返回指定筛选器完全匹配的结果。

接受一个对象,其中键是属性名,值是要匹配的单个值或值数组。

不支持文本数据类型的属性。

支持附加属性:
host - 图表原型所属主机的技术名称;
hostid - 图表原型所属主机的ID。
sortfield string/array 据给定的属性对结果进行排序。

可能的值: graphid, name, graphtype
countOutput boolean 这些参数是所有get方法的共同参数,在参考注释中有详细描述。
editable boolean
excludeSearch boolean
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean
selectGroups
(deprecated)
query 此参数已弃用,请改用selectHostGroups或者selectTemplateGroups
返回一个groups属性,其中包含图表原型所属的主机组和模板组。

返回值

返回 (integer/array) 其中之一:

  • 一个对象的数组;
  • 如果使用了 countOutput 参数,则为检索到的对象的数量。

示例

从 LLD 规则中检索图表原型

从一个 LLD 规则中检索所有的图表原型。

请求:

{
           "jsonrpc": "2.0",
           "method": "graphprototype.get",
           "params": {
               "output": "extend",
               "discoveryids": "27426"
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "graphid": "1017",
                   "parent_itemid": "27426",
                   "name": "Disk space usage {#FSNAME}",
                   "width": "600",
                   "height": "340",
                   "yaxismin": "0.0000",
                   "yaxismax": "0.0000",
                   "templateid": "442",
                   "show_work_period": "0",
                   "show_triggers": "0",
                   "graphtype": "2",
                   "show_legend": "1",
                   "show_3d": "1",
                   "percent_left": "0.0000",
                   "percent_right": "0.0000",
                   "ymin_type": "0",
                   "ymax_type": "0",
                   "ymin_itemid": "0",
                   "ymax_itemid": "0",
                   "discover": "0"
               }
           ],
           "id": 1
       }

另见

源码

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