4.graph.get
描述
整数/数组 graph.get(object **parameters**)
此方法用于根据给定参数来获取图表。
参数
(对象) 定义所需输出的参数。
此方法支持以下参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| 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 | 在 groups 属性下,返回图表所属的主机组。 |
| selectTemplates | query | 在 templates 属性下,返回图表所属的模板。 |
| selectHosts | query | 在 hosts 属性下,返回图表所属的主机。 |
| selectItems | query | 在 items 属性下,返回图表使用的监控项。 |
| selectGraphDiscovery | query | 在 graphDiscovery 属性下,返回图表发现对象。图表发现对象将图表链接到创建它的图表原型。它具有以下参数: graphid - (string) 图表的ID;parent_graphid - (string) 已创建图表的图表原型的ID。 |
| selectGraphItems | query | 在 gitems 属性下,返回图表所使用的图表监控项。 |
| selectDiscoveryRule | query | 在 discoveryRule 属性下,返回创建此图表的低级别发现规则。 |
| filter | object | 仅返回完全匹配给定过滤规则的结果。 接受一个数组,其中键是属性名称,值是单个值或要匹配的值数组。 支持额外的过滤器: host - 图表所属主机的名称;hostid - 图表所属主机的ID。 |
| sortfield | string/array | 按给定属性将结果排序。 可能值: graphid, name and graphtype。 |
| countOutput | boolean | 以下参数为get方法通常参数,在参考注释有详细说明。 |
| editable | boolean | |
| excludeSearch | boolean | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean | |
Return values
返回值
(整数/级数) 返回:
一个数组对象;
如果使用了
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.0000","yaxismax": "100.0000","templateid": "439","show_work_period": "1","show_triggers": "1","graphtype": "0","show_legend": "1","show_3d": "0","percent_left": "0.0000","percent_right": "0.0000","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.0000","yaxismax": "100.0000","templateid": "433","show_work_period": "1","show_triggers": "1","graphtype": "0","show_legend": "1","show_3d": "0","percent_left": "0.0000","percent_right": "0.0000","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.0000","yaxismax": "100.0000","templateid": "387","show_work_period": "1","show_triggers": "0","graphtype": "1","show_legend": "1","show_3d": "0","percent_left": "0.0000","percent_right": "0.0000","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.0000","yaxismax": "0.0000","templateid": "0","show_work_period": "0","show_triggers": "0","graphtype": "2","show_legend": "1","show_3d": "1","percent_left": "0.0000","percent_right": "0.0000","ymin_type": "0","ymax_type": "0","ymin_itemid": "0","ymax_itemid": "0","flags": "4"}],"id": 1}
参考
来源
CGraph::get() in frontends/php/include/classes/api/services/CGraph.php.
