获取

描述

integer/array graph.get(object parameters)

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

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

参数

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

该方法支持以下参数。

参数类型描述
graphidsstring/array只返回具有给定ID的图表。
groupidsstring/array只返回属于给定主机组中的主机的图表。
templateidsstring/array只返回属于给定模板的图表。
hostidsstring/array只返回属于给定主机的图表。
itemidsstring/array只返回包含给定监控项的图表。
templatedboolean如果设置为true,只返回属于模板的图表。
inheritedboolean如果设置为true,只返回从模板继承的图表。
expandNameflag在图表名称中扩展宏。
selectGroupsquery返回一个属性,其中包含该图表所属的主机组。
selectTemplatesquery返回一个模板属性,其中包含该图表所属的模板。
selectHostsquery返回一个主机属性,其中包含该图表所属的主机。
selectItemsquery返回一个监控项属性,其中包含该图表中使用的监控项。
selectGraphDiscoveryquery返回一个 graphDiscovery 属性和图表发现对象。图表发现对象将图表和创建图标的原型联系起来。

它具有以下属性:
graphid - (string) 图表的ID;
parent_graphid - (string) 创建图表的图表原型的ID。
selectGraphItemsquery返回一个图表监控项属性,其中包含该图表中使用的监控项。
selectDiscoveryRulequery返回一个发现规则属性,其中包含创建该图表的低级发现规则。
filterobject只返回那些与给定过滤器完全匹配的结果。

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

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

可用值: graphid, namegraphtype
countOutputboolean这些参数对所有的 “get “方法均是通用的,在参考说明页面中有详细描述。
editableboolean
excludeSearchboolean
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

返回 (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. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

响应:

  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()。