获取

描述

integer/array graph.get(object parameters)

该方法允许根据给定的参数来检索图表。

此方法对任何类型的用户可用。可以在用户角色设置中撤销调用该方法的权限。参见用户角色 了解更多信息。

参数

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

该方法支持以下参数。

参数 类型 描述
graphids ID/数组 仅返回具有给定ID的图表。
groupids ID/数组 仅返回属于给定主机组或模板组中的主机或模板的图表。
templateids ID/数组 仅返回属于给定模板的图表。
hostids ID/数组 仅返回属于给定主机的图表。
itemids ID/数组 仅返回包含给定监控项的图表。
templated 布尔值 如果设置为true,仅返回属于模板的图表。
inherited 布尔值 如果设置为true,仅返回从模板继承的图表。
expandName 标记 展开图表名称中的宏。
selectHostGroups 查询 返回一个hostgroups属性,包含图表所属的主机组。
selectTemplateGroups 查询 返回一个templategroups属性,包含图表所属的模板组。
selectTemplates 查询 返回一个templates属性,包含图表所属的模板。
selectHosts 查询 返回一个hosts属性,包含图表所属的主机。
selectItems 查询 返回一个items属性,包含图表中使用的监控项。
selectGraphDiscovery 查询 返回一个graphDiscovery属性,包含图表发现对象。图表发现对象将图表链接到创建它的图表原型。

它具有以下属性:
graphid - (ID) 图表的ID;
parent_graphid - (ID) 创建图表的图表原型的ID;
lastcheck - (时间戳) 图表上次发现的时间;
status - (整数) 图表发现状态:
0 - (默认) 图表已发现,
1 - 图表不再被发现;
ts_delete - (时间戳) 不再被发现的图表将被删除的时间。
selectGraphItems 查询 返回一个gitems属性,包含图表中使用的监控项。
selectDiscoveryRule 查询 返回一个discoveryRule属性,包含创建图表的低级发现规则。
filter 对象 仅返回完全匹配给定过滤器的结果。

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

不支持text数据类型的属性。

支持额外属性:
host - 图表所属主机的技术名称;
hostid - 图表所属主机的ID。
sortfield 字符串/数组 根据给定属性对结果进行排序。

可能的值:graphidnamegraphtype
countOutput 布尔值 这些参数在参考说明中有描述。
editable 布尔值
excludeSearch 布尔值
limit 整数
output 查询
preservekeys 布尔值
search 对象
searchByAny 布尔值
searchWildcardsEnabled 布尔值
sortorder 字符串/数组
startSearch 布尔值
selectGroups
(已废弃)
查询 此参数已废弃,请改用selectHostGroupsselectTemplateGroups
返回一个groups属性,包含图表所属的主机组和模板组。

返回值

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

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

示例

从主机上检索图表

检索主机 "10107 "的所有图表,并按名称排序。

请求

{
           "jsonrpc": "2.0",
           "method": "graph.get",
           "params": {
               "output": "extend",
               "hostids": 10107,
               "sortfield": "name"
           },
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "graphid": "612",
                   "name": "CPU jumps",
                   "width": "900",
                   "height": "200",
                   "yaxismin": "0",
                   "yaxismax": "100",
                   "templateid": "439",
                   "show_work_period": "1",
                   "show_triggers": "1",
                   "graphtype": "0",
                   "show_legend": "1",
                   "show_3d": "0",
                   "percent_left": "0",
                   "percent_right": "0",
                   "ymin_type": "0",
                   "ymax_type": "0",
                   "ymin_itemid": "0",
                   "ymax_itemid": "0",
                   "flags": "0"
               },
               {
                   "graphid": "613",
                   "name": "CPU load",
                   "width": "900",
                   "height": "200",
                   "yaxismin": "0",
                   "yaxismax": "100",
                   "templateid": "433",
                   "show_work_period": "1",
                   "show_triggers": "1",
                   "graphtype": "0",
                   "show_legend": "1",
                   "show_3d": "0",
                   "percent_left": "0",
                   "percent_right": "0",
                   "ymin_type": "1",
                   "ymax_type": "0",
                   "ymin_itemid": "0",
                   "ymax_itemid": "0",
                   "flags": "0"
               },
               {
                   "graphid": "614",
                   "name": "CPU utilization",
                   "width": "900",
                   "height": "200",
                   "yaxismin": "0",
                   "yaxismax": "100",
                   "templateid": "387",
                   "show_work_period": "1",
                   "show_triggers": "0",
                   "graphtype": "1",
                   "show_legend": "1",
                   "show_3d": "0",
                   "percent_left": "0",
                   "percent_right": "0",
                   "ymin_type": "1",
                   "ymax_type": "1",
                   "ymin_itemid": "0",
                   "ymax_itemid": "0",
                   "flags": "0"
               },
               {
                   "graphid": "645",
                   "name": "Disk space usage /",
                   "width": "600",
                   "height": "340",
                   "yaxismin": "0",
                   "yaxismax": "0",
                   "templateid": "0",
                   "show_work_period": "0",
                   "show_triggers": "0",
                   "graphtype": "2",
                   "show_legend": "1",
                   "show_3d": "1",
                   "percent_left": "0",
                   "percent_right": "0",
                   "ymin_type": "0",
                   "ymax_type": "0",
                   "ymin_itemid": "0",
                   "ymax_itemid": "0",
                   "flags": "4"
               }
           ],
           "id": 1
       }

参见

来源

ui/include/classes/api/services/CGraph.php 中的 CGraph::get()。