integer/array graph.get(object parameters)
该方法允许根据给定参数检索图表。
该方法对所有类型的用户可用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参阅User roles。
(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 | 展开图表名称中的宏. |
selectDiscoveryData | query | 返回包含图表发现object数据的discoveryData 属性。图表发现object将发现的图表与其来源的图表原型建立关联。该属性具有以下字段: parent_graphid - 生成该图表的原型图表(ID) ID;lastcheck - 图表最后一次被发现时的(timestamp) 时间戳;status - 图表发现状态(int) :0 - (默认) 图表处于被发现状态, 1 - 图表不再被发现; ts_delete - 不再被发现的图表将被删除的(timestamp) 时间戳。 |
selectDiscoveryRule | query | 返回包含创建该图形的低级发现规则的discoveryRule 属性。 |
selectDiscoveryRulePrototype | query | 返回一个discoveryRulePrototype 属性,该属性包含创建该图形的父级LLD规则原型。 |
selectHostGroups | query | 返回包含图表所属hostgroups 属性及主机分组的对象。 |
selectTemplateGroups | query | 返回一个包含图表所属模板组的templategroups 属性。 |
selectTemplates | query | 返回包含图表所属模板的templates 属性。 |
selectHosts | query | 返回一个hosts 属性,包含该图表所属的主机。 |
selectItems | query | 返回包含图表中使用的items 属性的监控项。 |
selectGraphDiscovery | query | 返回带有图形发现object的graphDiscovery 属性. 图形发现objects将图形链接到创建它的图形原型.此query已弃用, 请改用 selectDiscoveryData . |
selectGraphItems | query | 返回包含图表中使用的gitems 属性的监控项。 |
filter | object | 仅返回与给定筛选条件完全匹配的结果。 接受一个object,其中键为属性名称,值为单个值或用于匹配的array。 不支持 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 |
(integer/array)
返回以下两种结果之一:
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 文件中。