graph.get
描述
integer/array graph.get(object parameters)
该方法允许根据给定的参数检索图形。
此方法可供任何类型的用户使用。调用该方法的权限 可以在用户角色设置中撤销。更多信息请参见 User roles。
参数
(object) 定义所需输出的参数。
该方法支持以下参数。
| Parameter | Type | Description |
|---|---|---|
| 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 - (default) 图形已被发现, 1 - 图形不再被发现; ts_delete - (timestamp) 不再被发现的图形将被删除的时间。 |
| selectGraphItems | query | 返回一个 gitems 属性,其中包含图形中使用的监控项。 |
| selectDiscoveryRule | query | 返回一个 discoveryRule 属性,其中包含创建该图形的低级别发现规则。 |
| filter | object | 仅返回与给定过滤条件完全匹配的结果。 接受一个对象,其中键为属性名称,值可以是单个值或用于匹配的值数组。 不支持 text data type 类型的属性。支持附加属性: host - 图形所属主机的技术名称;hostid - 图形所属主机的 ID。 |
| sortfield | string/array | 按给定属性对结果排序。 可选值: graphid、name、graphtype。 |
| countOutput | boolean | 这些参数在 参考说明 中有描述。 |
| 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 或 selectTemplateGroups。返回一个 groups 属性,其中包含该图形所属的主机组和模板组。 |
返回值
(integer/array) 返回以下之一:
- array 的 objects;
- 如果使用了
countOutput参数,则为检索到的 objects 的数量。
示例
从主机检索图表
从 主机 "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
}
另请参见
来源
CGraph::get() 在 ui/include/classes/api/services/CGraph.php 中。