graph.get

描述

integer/array graph.get(object parameters)

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

此方法可供任何类型的用户使用。调用该方法的权限 可以在用户角色设置中撤销。更多信息请参见 User roles

参数

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

该方法支持以下参数。

参数 数据类型 描述
graphids ID/array 仅返回具有指定 ID 的图表。
groupids ID/array 仅返回属于给定 主机 或模板组的 主机 组或模板组中的图表。
templateids ID/array 仅返回属于给定模板的图表。
hostids ID/array 仅返回属于给定主机的图表。
itemids ID/array 仅返回包含给定监控项的图表。
templated boolean 如果设置为 true,则仅返回属于模板的图表。
inherited boolean 如果设置为 true,则仅返回从模板继承的图表。
expandName flag 在图形名称中展开宏。
selectHostGroups query 返回一个包含该图表所属的 主机 组的 hostgroups 属性。
selectTemplateGroups query 返回一个包含该图表所属模板组的 templategroups 属性。
selectTemplates query 返回一个包含该图表所属模板的 templates 属性。
selectHosts query 返回一个 hosts 属性,该属性包含此图表所属的 主机。
selectItems query 返回一个包含图中使用的 监控项 的 items 属性。
selectGraphDiscovery query 返回一个包含图表发现 object 的 graphDiscovery 属性。图表发现 objects 将图表链接到创建它的图表原型。

它具有以下属性:
graphid - 图表的 (ID) ID;
parent_graphid - 创建该图表的图表原型的 (ID) ID;
lastcheck - 图表最后一次被发现的 (timestamp) 时间;
status - 图表发现的 (int) 状态:
0 - (默认) 图表已被发现,
1 - 图表不再被发现;
ts_delete - 不再被发现的图表将被删除的 (timestamp) 时间。
selectGraphItems query 返回一个包含图中使用的 监控项 的 gitems 属性。
selectDiscoveryRule query 返回一个 discoveryRule 属性,该属性包含创建此图表的低级别自动发现规则。
filter object 仅返回与给定过滤条件完全匹配的结果。

接受一个object,其中键为属性名,值为单个值或一个array值集合用于匹配。

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

支持额外属性:
host - 图形所属主机的技术名称;
hostid - 图形所属主机的ID。
sortfield string/array 按照给定属性对结果进行排序。

可能的值:graphidnamegraphtype
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 此参数已弃用,请改用 selectHostGroupsselectTemplateGroups
返回一个 groups 属性,包含该图表所属的 主机 组和模板组。

返回值

(integer/array) 返回以下之一:

  • array 的 objects;
  • 如果使用了 countOutput 参数,则为检索到的 objects 的数量。

示例

从主机检索图表

从 主机 "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
       }

另请参阅

来源

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