graphprototype.get

描述

integer/array graphprototype.get(object parameters)

该方法允许根据给定的参数检索图形原型。

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

参数

(object) 定义所需输出的参数。

该方法支持以下参数。

Parameter Type Description
discoveryids ID/array 仅返回属于给定发现规则的图形原型。
graphids ID/array 仅返回具有给定 ID 的图形原型。
groupids ID/array 仅返回属于给定主机组或模板组中的主机或模板的图形原型。
hostids ID/array 仅返回属于给定主机的图形原型。
inherited boolean 如果设置为 true,则仅返回从模板继承的图形原型。
itemids ID/array 仅返回包含给定监控项原型的图形原型。
templated boolean 如果设置为 true,则仅返回属于模板的图形原型。
templateids ID/array 仅返回属于给定模板的图形原型。
selectDiscoveryRule query 返回一个 discoveryRule 属性,其中包含该图形原型所属的 LLD 规则。
selectGraphItems query 返回一个 gitems 属性,其中包含图形原型中使用的图形项。
selectHostGroups query 返回一个 hostgroups 属性,其中包含该图形原型所属的主机组。
selectHosts query 返回一个 hosts 属性,其中包含该图形原型所属的主机。
selectItems query 返回一个 items 属性,其中包含图形原型中使用的 items 和 item prototypes。
selectTemplateGroups query 返回一个 templategroups 属性,其中包含该图形原型所属的模板组。
selectTemplates query 返回一个 templates 属性,其中包含该图形原型所属的模板。
filter object 仅返回与给定过滤器完全匹配的结果。

接受一个对象,其中键为属性名称,值为要匹配的单个值或值数组。

不支持 text data type 的属性。

支持附加属性:
host - 图形原型所属主机的技术名称;
hostid - 主机的 ID。
sortfield string/array 按给定属性对结果排序。

可选值:graphid、name、graphtype、discovered。
countOutput boolean 这些参数在 reference commentary 中有说明。
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 的数量。

示例

从LLD规则检索图形原型

从LLD规则中检索所有图形原型。

执行请求:

{
    "jsonrpc": "2.0",
    "method": "graphprototype.get",
    "params": {
        "output": "extend",
        "discoveryids": "27426"
    },
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "graphid": "1017",
            "name": "Disk space usage {#FSNAME}",
            "width": "600",
            "height": "340",
            "yaxismin": "0.0000",
            "yaxismax": "0.0000",
            "templateid": "442",
            "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",
            "discover": "0"
        }
    ],
    "id": 1
}

另请参见

来源

CGraphPrototype::get() 在 ui/include/classes/api/services/CGraphPrototype.php 中。