graph.get

Description描述

integer/array 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.此方法支持如下参数

Parameter参数 Type类型 Description描述
图形ID graphids string/array 字符串型/数组型 Return only graphs with the given IDs.返回只含有指定ID的图形
主机组ID groupids string/array 字符串型/数组型 Return only graphs that belong to hosts in the given host groups.返回只属于指定主机组的主机的的图形。
模板ID templateids string/array 字符串型/数组型 Return only graph that belong to the given templates.返回只属于指定模板的图形。
主机ID hostids string/array 字符串型/数组型 Return only graphs that belong to the given hosts.返回只属于指定主机的图形。
监控项ID itemids string/array 字符串型/数组型 Return only graphs that contain the given items.返回只包含指定监控项的图形。
模板化的 templated boolean 布尔型 If set to true return only graphs that belong to templates.如果设置“true”返回只属于模板的图形。
继承的 inherited boolean 布尔型 If set to true return only graphs inherited from a template.如果设置“true”只返回从模板继承的图形。
展开名称 expandName flag 标记 Expand macros in the graph name.展开图形名称中的宏。
选择组 selectGroups query 询问 Return the host groups that the graph belongs to in the groups property.返回图形的“groups”参数的主机组。
选择模板 selectTemplates query 询问 Return the templates that the graph belongs to in the templates property.返回图形的“templates”参数的模板。
选择主机 selectHosts query 询问 Return the hosts that the graph belongs to in the hosts property.返回图形的“hosts”参数的主机。
选择监控项 selectItems query 询问 Return the items used in the graph in the items property.返回图形的“items”参数的监控项。
选择图形发现 selectGraphDiscovery query 询问 Return the graph discovery object in the graphDiscovery property. The graph discovery objects links the graph to a graph prototype from which it was created.返回在graphDiscovery参数中图形发现对象。图型发现对象链接图形与创建父图形的参数。 It has the following properties:它接受以下参数 graphid - (string) ID of the graph;图形ID graphid - (string字符串型) 图形ID; parent_graphid - (string) ID of the graph prototype from which the graph has been created.父图形ID parent_graphid - (string字符串型) 父图形的ID
选择图形项 selectGraphItems query 询问 Return the graph items used in the graph in the gitems property.返回图形的“gitems”参数的监控项。
选择发现规则 selectDiscoveryRule query 询问 Return the low-level discovery rule that created the graph in the discoveryRule property.返回创建图形的“discoverRule”参数中的低级发现规则。
过滤器 filter object 关联数组 Return 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.图形所属主机的ID
排序域 sortfield string 字符串型/array数组 Sort the result by the given properties.按指定的参数将结果排序 Possible values are:可用值 图形ID graphid, 名称 name and 图形类型 graphtype.
countOutput flagThese parameters being common for all get methods are described in detail in the reference commentary page. 这些参数对于所有get方法都是通用的,在附录1:参考中,查看详细描述。
editable boolean
excludeSearch flag
limit integer
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

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.