获取

描述

integer/array itemprototype.get(object parameters)

该方法允许根据给定的参数检索监控项原型。

任何类型的用户都可以使用此方法。权限可以在用户角色设置中撤消调用该方法。了解更多信息可以参见用户角色

参数

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

该方法支持以下参数。

参数 类型 说明
discoveryids ID/array 仅返回属于给定 LLD 规则的监控项原型。
graphids ID/array 仅返回在给定图形原型中使用的监控项原型。
hostids ID/array 仅返回属于给定主机的监控项原型。
inherited boolean 如果设置为 true,则仅返回从模板继承的监控项原型。
itemids ID/array 仅返回具有给定 ID 的监控项原型。
monitored boolean 如果设置为 true,则仅返回属于已监控主机的已启用监控项原型。
templated boolean 如果设置为 true,则仅返回属于模板的监控项原型。
templateids ID/array 仅返回属于给定模板的监控项原型。
triggerids ID/array 仅返回在给定触发器原型中使用的监控项原型。
selectDiscoveryData query 返回 discoveryData 属性,其中包含监控项原型发现对象数据。监控项原型发现对象将已发现的监控项原型链接到发现它的监控项原型。

它具有以下属性:
parent_itemid - (string) 创建该监控项原型所依据的监控项原型 ID;
key_ - (string) 监控项原型的键值;
status - (int) 监控项原型发现状态:
0 - (默认) 监控项原型已发现,
1 - 监控项原型不再被发现;
ts_delete - (timestamp) 不再被发现的监控项原型将被删除的时间;
ts_disable - (timestamp) 不再被发现的监控项原型将被禁用的时间;
disable_source - (int) 指示监控项原型是由 LLD 规则还是手动禁用:
0 - (默认) 自动禁用,
1 - 由 LLD 规则禁用。
selectDiscoveryRule query 返回 discoveryRule 属性,其中包含该监控项原型所属的低级别发现规则。
selectDiscoveryRulePrototype query 返回 discoveryRulePrototype 属性,其中包含该监控项原型所属的父 LLD 规则原型。
selectGraphs query 返回 graphs 属性,其中包含使用该监控项原型的图形原型。

支持 count
selectHosts query 返回 hosts 属性,其中包含该监控项原型所属主机的数组。
selectInheritedTags query 返回 inheritedTags 属性,其中包含模板/主机/已链接模板上的标签。
selectTags query tags 属性中返回监控项原型标签。
selectTriggers query 返回 triggers 属性,其中包含使用该监控项原型的触发器原型。

支持 count
selectPreprocessing query 返回 preprocessing 属性,其中包含监控项原型预处理选项。
selectValueMap query 返回 valuemap 属性,其中包含监控项原型值映射。
filter object 仅返回与给定过滤条件完全匹配的结果。

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

不支持 text 数据类型 的属性。

支持附加属性:
host - 该监控项原型所属主机的技术名称。
limitSelects integer 限制子选择返回的记录数。

适用于以下子选择:
selectGraphs - 结果将按 name 排序;
selectTriggers - 结果将按 description 排序。
sortfield string/array 按给定属性对结果进行排序。

可选值:itemidnamekey_delaytypestatushistorytrendsdiscovered
countOutput boolean 这些参数在参考说明中进行了描述。
editable boolean
excludeSearch boolean
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

返回值

(integer/array) 返回其中之一:

  • 一个对象数组;
  • 如果使用countOutput参数,返回被检索对象的数量。

示例

从 LLD 规则中检索监控项原型

检索指定 LLD 规则 ID 的所有监控项原型。

请求:

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

响应:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "23077",
            "type": "0",
            "snmp_oid": "",
            "hostid": "10079",
            "name": "Incoming network traffic on en0",
            "key_": "net.if.in[en0]",
            "delay": "1m",
            "history": "1w",
            "trends": "365d",
            "status": "0",
            "value_type": "3",
            "trapper_hosts": "",
            "units": "bps",
            "formula": "",
            "logtimefmt": "",
            "templateid": "0",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "2",
            "interfaceid": "0",
            "description": "",
            "inventory_link": "0",
            "lifetime": "7d",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "discover": "0",
            "uuid": "",
            "lifetime_type": "0",
            "enabled_lifetime_type": "2",
            "enabled_lifetime": "0",
            "parameters": []
        },
        {
            "itemid": "10010",
            "type": "0",
            "snmp_oid": "",
            "hostid": "10001",
            "name": "Processor load (1 min average per core)",
            "key_": "system.cpu.load[percpu,avg1]",
            "delay": "1m",
            "history": "1w",
            "trends": "365d",
            "status": "0",
            "value_type": "0",
            "trapper_hosts": "",
            "units": "",
            "formula": "",
            "logtimefmt": "",
            "templateid": "0",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "2",
            "interfaceid": "0",
            "description": "The processor load is calculated as system CPU load divided by number of CPU cores.",
            "inventory_link": "0",
            "lifetime": "7d",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "discover": "0",
            "uuid": "",
            "lifetime_type": "0",
            "enabled_lifetime_type": "2",
            "enabled_lifetime": "0",
            "parameters": []
        }
    ],
    "id": 1
}

查找依赖监控项

为指定的监控项 ID 查找一个依赖监控项。

请求

{
    "jsonrpc": "2.0",
    "method": "itemprototype.get",
    "params": {
        "output": "extend",
        "filter": {
            "type": 18,
            "master_itemid": "25545"
        },
        "limit": "1"
    },
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "25547",
            "type": "18",
            "snmp_oid": "",
            "hostid": "10116",
            "name": "Seconds",
            "key_": "apache.status.uptime.seconds",
            "delay": "0",
            "history": "90d",
            "trends": "365d",
            "status": "0",
            "value_type": "3",
            "trapper_hosts": "",
            "units": "",
            "formula": "",
            "logtimefmt": "",
            "templateid": "0",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "0",
            "description": "",
            "inventory_link": "0",
            "lifetime": "7d",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "25545",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "discover": "0",
            "uuid": "",
            "lifetime_type": "0",
            "enabled_lifetime_type": "2",
            "enabled_lifetime": "0",
            "parameters": []
        }
    ],
    "id": 1
}

查找 HTTP agent 监控项原型

查找指定主机 ID 中请求方法为 HEAD 的 HTTP agent 监控项原型。

请求

{
    "jsonrpc": "2.0",
    "method": "itemprototype.get",
    "params": {
        "hostids": "10254",
        "filter": {
            "type": 19,
            "request_method": 3
        }
    },
    "id": 1
}

响应:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "28257",
            "type": "19",
            "snmp_oid": "",
            "hostid": "10254",
            "name": "discovered",
            "key_": "item[{#INAME}]",
            "delay": "{#IUPDATE}",
            "history": "90d",
            "trends": "30d",
            "status": "0",
            "value_type": "3",
            "trapper_hosts": "",
            "units": "",
            "formula": "",
            "logtimefmt": "",
            "templateid": "28255",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "2",
            "interfaceid": "2",
            "description": "",
            "inventory_link": "0",
            "lifetime": "7d",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "{#IURL}",
            "query_fields": [],
            "posts": "",
            "status_codes": "",
            "follow_redirects": "0",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "3",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "discover": "0",
            "uuid": "",
            "lifetime_type": "0",
            "enabled_lifetime_type": "2",
            "enabled_lifetime": "0",
            "parameters": []
        }
    ],
    "id": 1
}

另请参阅

来源

CItemPrototype::get() in ui/include/classes/api/services/CItemPrototype.php.