graph.get

Description

描述

integer/array graph.get(object parameters) 整数/数组 graph.get(object parameters)

The method allows to retrieve graphs according to the given parameters. 此方法用于根据给定的参数来获取图表。

Parameters

参数

(object) Parameters defining the desired output. (对象) 定义所需输出的参数.

The method supports the following parameters. 此方法支持以下参数

ParameterTypeDescription
graphidsstring/arrayReturn only graphs with the given IDs.
groupidsstring/arrayReturn only graphs that belong to hosts in the given host groups.
templateidsstring/arrayReturn only graph that belong to the given templates.
hostidsstring/arrayReturn only graphs that belong to the given hosts.
itemidsstring/arrayReturn only graphs that contain the given items.
templatedbooleanIf set to true return only graphs that belong to templates.
inheritedbooleanIf set to true return only graphs inherited from a template.
expandNameflagExpand macros in the graph name.
selectGroupsqueryReturn the host groups that the graph belongs to in the groups property.
selectTemplatesqueryReturn the templates that the graph belongs to in the templates property.
selectHostsqueryReturn the hosts that the graph belongs to in the hosts property.
selectItemsqueryReturn the items used in the graph in the items property.
selectGraphDiscoveryqueryReturn the graph discovery object in the graphDiscovery property. The graph discovery objects links the graph to a graph prototype from which it was created.

It has the following properties:
graphid - (string) ID of the graph;
parent_graphid - (string) ID of the graph prototype from which the graph has been created.
selectGraphItemsqueryReturn the graph items used in the graph in the gitems property.
selectDiscoveryRulequeryReturn the low-level discovery rule that created the graph in the discoveryRule property.
filterobjectReturn only those results that exactly match the given filter.

Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against.

Supports additional filters:
host - technical name of the host that the graph belongs to;
hostid - ID of the host that the graph belongs to.
sortfieldstring/arraySort the result by the given properties.

Possible values are: graphid, name and graphtype.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary page.
editableboolean
excludeSearchboolean
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean
参数 类描述
graphidsstring/array仅返回含有给定ID的图表.
groupidsstring/array仅返回属于给定主机组的主机的图表.
templateidsstring/array仅返回属于给定模板的图表.
hostidsstring/array仅返回属于给定主机的图表.
itemidsstring/array仅返回包含给定监控项的图表.
templatedboolean如果设置为 真(true),仅返回属于模板的图表.
inheritedboolean如果设置为 真(true),仅返回从模板继承的图表.
expandNameflag在图表名称中展开宏.
selectGroupsquerygroups 属性下,返回图表所属的主机组.
selectTemplatesquerytemplates 属性下,返回图表所属的模板.
selectHostsqueryhosts 属性下,返回图表所属的主机.
selectItemsqueryitems 属性下,返回图表使用的监控项.
selectGraphDiscoveryquerygraphDiscovery 属性下,返回图表发现对象. 图表发现对象将图表链接到创建它的图表原型.

它具有以下参数:
graphid - (string) 图表的ID;
parent_graphid - (string) 已创建图表的图表原型的ID.
selectGraphItemsquerygitems 属性下,返回图表所使用的图表监控项.
selectDiscoveryRulequerydiscoveryRule 属性下,返回创建此图表的低级别发现规则.
filterobject仅返回完全匹配给定过滤规则的结果.

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

支持额外的过滤器:
host - 图表所属主机的名称;
hostid - 图表所属主机的ID.
sortfieldstring/array按给定属性将结果排序.

可能值: graphid, name and graphtype.
countOutputboolean以下参数为get方法通常参数,在参考注释有详细说明..
editableboolean
excludeSearchboolean
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

返回值

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

(整数/级数) 返回:

  • 一个数组对象;
  • 如果使用了 countOutput 参数,返回获取的对象的数量.

Examples

例子

Retrieving graphs from hosts

从主机中获取图表

Retrieve all graphs from host “10107” and sort them by name. 从主机”10107”中获取所有图表,并依据名称进行排序。

Request: 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "graph.get",
  4. "params": {
  5. "output": "extend",
  6. "hostids": 10107,
  7. "sortfield": "name"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response: 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "graphid": "612",
  6. "name": "CPU jumps",
  7. "width": "900",
  8. "height": "200",
  9. "yaxismin": "0.0000",
  10. "yaxismax": "100.0000",
  11. "templateid": "439",
  12. "show_work_period": "1",
  13. "show_triggers": "1",
  14. "graphtype": "0",
  15. "show_legend": "1",
  16. "show_3d": "0",
  17. "percent_left": "0.0000",
  18. "percent_right": "0.0000",
  19. "ymin_type": "0",
  20. "ymax_type": "0",
  21. "ymin_itemid": "0",
  22. "ymax_itemid": "0",
  23. "flags": "0"
  24. },
  25. {
  26. "graphid": "613",
  27. "name": "CPU load",
  28. "width": "900",
  29. "height": "200",
  30. "yaxismin": "0.0000",
  31. "yaxismax": "100.0000",
  32. "templateid": "433",
  33. "show_work_period": "1",
  34. "show_triggers": "1",
  35. "graphtype": "0",
  36. "show_legend": "1",
  37. "show_3d": "0",
  38. "percent_left": "0.0000",
  39. "percent_right": "0.0000",
  40. "ymin_type": "1",
  41. "ymax_type": "0",
  42. "ymin_itemid": "0",
  43. "ymax_itemid": "0",
  44. "flags": "0"
  45. },
  46. {
  47. "graphid": "614",
  48. "name": "CPU utilization",
  49. "width": "900",
  50. "height": "200",
  51. "yaxismin": "0.0000",
  52. "yaxismax": "100.0000",
  53. "templateid": "387",
  54. "show_work_period": "1",
  55. "show_triggers": "0",
  56. "graphtype": "1",
  57. "show_legend": "1",
  58. "show_3d": "0",
  59. "percent_left": "0.0000",
  60. "percent_right": "0.0000",
  61. "ymin_type": "1",
  62. "ymax_type": "1",
  63. "ymin_itemid": "0",
  64. "ymax_itemid": "0",
  65. "flags": "0"
  66. },
  67. {
  68. "graphid": "645",
  69. "name": "Disk space usage /",
  70. "width": "600",
  71. "height": "340",
  72. "yaxismin": "0.0000",
  73. "yaxismax": "0.0000",
  74. "templateid": "0",
  75. "show_work_period": "0",
  76. "show_triggers": "0",
  77. "graphtype": "2",
  78. "show_legend": "1",
  79. "show_3d": "1",
  80. "percent_left": "0.0000",
  81. "percent_right": "0.0000",
  82. "ymin_type": "0",
  83. "ymax_type": "0",
  84. "ymin_itemid": "0",
  85. "ymax_itemid": "0",
  86. "flags": "4"
  87. }
  88. ],
  89. "id": 1
  90. }

See also

参考

Source

来源

CGraph::get() in frontends/php/include/classes/api/services/CGraph.php.