graph.get

描述

integer/array graph.get(object parameters)

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

此方法可供任何类型的用户使用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参阅User roles

参数

(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 返回一个groups属性,包含图形所属的主机组.
selectTemplates query 返回一个templates属性,包含图形所属的模板.
selectHosts query 返回一个hosts属性,包含图形所属的主机.
selectItems query 返回一个items属性,包含图形中使用的监控项.
selectGraphDiscovery query 返回一个graphDiscovery属性,包含图形发现object. 图形发现objects将图形与其创建来源的图形原型关联.

具有以下属性:
graphid - (string) 图形ID;
parent_graphid - (string) 创建该图形的图形原型ID.
selectGraphItems query 返回一个gitems属性,包含图形中使用的监控项.
selectDiscoveryRule query 返回一个discoveryRule属性,包含创建该图形的低级发现规则.
filter object 仅返回完全匹配给定过滤条件的结果.

接受一个array,其中键为属性名,值为要匹配的单个值或array值数组.

支持额外过滤器:
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) 返回以下两种情况之一:

  • 一个包含array的objects数组;
  • 检索到的objects数量,如果使用了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
}

另请参阅

来源

CGraph::get() 位于 ui/include/classes/api/services/CGraph.php 文件中。