这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

获取

描述

integer/array graph.get(object parameters)

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

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

参数

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

该方法支持以下参数。

参数 类型 描述
graphids string/array 只返回具有给定ID的图表。
groupids string/array 只返回属于给定主机组中的主机的图表。
templateids string/array 只返回属于给定模板的图表。
hostids string/array 只返回属于给定主机的图表。
itemids string/array 只返回包含给定监控项的图表。
templated boolean 如果设置为true,只返回属于模板的图表。
inherited boolean 如果设置为true,只返回从模板继承的图表。
expandName flag 在图表名称中扩展宏。
selectGroups query 返回一个属性,其中包含该图表所属的主机组。
selectTemplates query 返回一个模板属性,其中包含该图表所属的模板。
selectHosts query 返回一个主机属性,其中包含该图表所属的主机。
selectItems query 返回一个监控项属性,其中包含该图表中使用的监控项。
selectGraphDiscovery query 返回一个 graphDiscovery 属性和图表发现对象。图表发现对象将图表和创建图标的原型联系起来。

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

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

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

可用值: graphid, namegraphtype
countOutput boolean 这些参数对所有的 "get "方法均是通用的,在参考说明页面中有详细描述。
editable boolean
excludeSearch boolean
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

返回值

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

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

示例

从主机上检索图表

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

请求:

{
           "jsonrpc": "2.0",
           "method": "graph.get",
           "params": {
               "output": "extend",
               "hostids": 10107,
               "sortfield": "name"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "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
       }

另见

来源

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