integer/array graph.get(object parameters)
该方法允许根据给定的参数来检索图表。
此方法对任何类型的用户可用。可以在用户角色设置中撤销调用该方法的权限。参见用户角色 了解更多信息。
(object) 参数定义了所需的输出。
该方法支持以下参数。
| 参数 | 类型 | 描述 |
|---|---|---|
| graphids | ID/array | 仅返回具有给定ID的图表。 |
| groupids | ID/array | 仅返回属于给定主机组或模板组中的主机或模板的图表。 |
| templateids | ID/array | 仅返回属于给定模板的图表。 |
| hostids | ID/array | 仅返回属于给定主机的图表。 |
| itemids | ID/array | 仅返回包含给定监控项的图表。 |
| templated | boolean | 如果设置为true,仅返回属于模板的图表。 |
| inherited | boolean | 如果设置为true,仅返回从模板继承的图表。 |
| expandName | flag | 图表名称中的扩展宏。 |
| selectHostGroups | query | 返回一个hostgroups属性,其中包含该图表所属的主机组。 |
| selectTemplateGroups | query | 返回一个templategroups属性,其中包含该图表所属的模板组。 |
| selectTemplates | query | 返回一个templates属性,其中包含该图表所属的模板。 |
| selectHosts | query | 返回一个hosts属性,其中包含该图表所属的主机。 |
| selectItems | query | 返回一个items属性,其中包含该图表中使用的监控项。 |
| selectGraphDiscovery | query | 返回带有图表发现对象的graphDiscovery属性。图表发现对象将图表链接到创建图表的图表原型。它具有以下属性: graphid - (ID) 图表的ID;parent_graphid - (ID) 创建图表的图表原型的ID;lastcheck - (timestamp) 上次发现图表的时间;status - (int) 图表发现状态:0 - (默认) 发现了图形, 1 - 图表不再被发现; ts_delete - (timestamp) 不再被发现的图表将被删除的时间。 |
| selectGraphItems | query | 返回一个gitems属性,其中包含该图表中使用的监控项。 |
| selectDiscoveryRule | query | 返回一个graphDiscovery属性,其中包含创建该图表的低级发现规则。 |
| filter | object | 仅返回那些与给定过滤器完全匹配的结果。 接受一个对象,其中键是属性名,值是要匹配的单个值或值数组。 不支持 text 数据类型属性。支持额外的属性: host - 图表所属主机的技术名称;hostid - 图表所属主机的ID。 |
| sortfield | string/array | 按给定的属性对结果进行排序。 可能值: graphid, name 和 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 | |
| selectGroups (deprecated) |
query | 此参数已弃用,请使用selectHostGroups or selectTemplateGroups 代替。返回带有图表所属的主机组和模板组的 groups属性。 |
(integer/array) 返回其中之一:
countOutput 参数,则为检索到的对象的数量。检索主机 "10107 "的所有图表,并按名称排序。
请求:
{
"jsonrpc": "2.0",
"method": "graph.get",
"params": {
"output": "extend",
"hostids": 10107,
"sortfield": "name"
},
"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()。