获取

描述

integer/array graph.get(object parameters)

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

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

参数

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

该方法支持以下参数。

参数类型描述
graphidsID/array仅返回具有给定ID的图表。
groupidsID/array仅返回属于给定主机组或模板组中的主机或模板的图表。
templateidsID/array仅返回属于给定模板的图表。
hostidsID/array仅返回属于给定主机的图表。
itemidsID/array仅返回包含给定监控项的图表。
templatedboolean如果设置为true,仅返回属于模板的图表。
inheritedboolean如果设置为true,仅返回从模板继承的图表。
expandNameflag图表名称中的扩展宏。
selectHostGroupsquery返回一个hostgroups属性,其中包含该图表所属的主机组。
selectTemplateGroupsquery返回一个templategroups属性,其中包含该图表所属的模板组。
selectTemplatesquery返回一个templates属性,其中包含该图表所属的模板。
selectHostsquery返回一个hosts属性,其中包含该图表所属的主机。
selectItemsquery返回一个items属性,其中包含该图表中使用的监控项。
selectGraphDiscoveryquery返回带有图表发现对象的graphDiscovery属性。图表发现对象将图表链接到创建图表的图表原型。

它具有以下属性:
graphid - (ID) 图表的ID;
parent_graphid - (ID) 创建图表的图表原型的ID;
lastcheck - (timestamp) 上次发现图表的时间;
status - (int) 图表发现状态:
0 - (默认) 发现了图形,
1 - 图表不再被发现;
ts_delete - (timestamp) 不再被发现的图表将被删除的时间。
selectGraphItemsquery返回一个gitems属性,其中包含该图表中使用的监控项。
selectDiscoveryRulequery返回一个graphDiscovery属性,其中包含创建该图表的低级发现规则。
filterobject仅返回那些与给定过滤器完全匹配的结果。

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

不支持text 数据类型属性。

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

可能值: graphid, namegraphtype
countOutputboolean这些参数对于所有的 get 方法都是通用的,详细描述请参见 参考说明
editableboolean
excludeSearchboolean
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean
selectGroups
(deprecated)
query此参数已弃用,请使用selectHostGroups or selectTemplateGroups 代替。
返回带有图表所属的主机组和模板组的groups属性。

返回值

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

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

示例

从主机上检索图表

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

请求

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

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "graphid": "612",
  6. "name": "CPU jumps",
  7. "width": "900",
  8. "height": "200",
  9. "yaxismin": "0",
  10. "yaxismax": "100",
  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",
  18. "percent_right": "0",
  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",
  31. "yaxismax": "100",
  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",
  39. "percent_right": "0",
  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",
  52. "yaxismax": "100",
  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",
  60. "percent_right": "0",
  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",
  73. "yaxismax": "0",
  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",
  81. "percent_right": "0",
  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. }

参见

来源

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