integer/array itemprototype.get(object parameters)
该方法允许根据给定的参数检索监控项原型。
任何类型的用户都可以使用此方法。权限可以在用户角色设置中撤消调用该方法。了解更多信息可以参见用户角色。
(object)
定义所需输出的参数。
该方法支持以下参数。
参数 | 类型 | 描述 |
---|---|---|
discoveryids | ID/数组 | 仅返回属于给定LLD规则的项目原型。 |
graphids | ID/数组 | 仅返回在给定图表原型中使用的项目原型。 |
hostids | ID/数组 | 仅返回属于给定主机的项目原型。 |
inherited | 布尔值 | 如果设置为true ,仅返回从模板继承的项目原型。 |
itemids | ID/数组 | 仅返回具有给定ID的项目原型。 |
monitored | 布尔值 | 如果设置为true ,仅返回属于受监控主机的已启用项目原型。 |
templated | 布尔值 | 如果设置为true ,仅返回属于模板的项目原型。 |
templateids | ID/数组 | 仅返回属于给定模板的项目原型。 |
triggerids | ID/数组 | 仅返回在给定触发器原型中使用的项目原型。 |
selectDiscoveryRule | 查询 | 返回一个discoveryRule 属性,其中包含项目原型所属的低级发现规则。 |
selectGraphs | 查询 | 返回一个graphs 属性,其中包含项目原型使用的图表原型。支持 count 。 |
selectHosts | 查询 | 返回一个hosts 属性,其中包含项目原型所属的主机数组。 |
selectTags | 查询 | 返回项目原型标签在tags 属性中。 |
selectTriggers | 查询 | 返回一个triggers 属性,其中包含项目原型使用的触发器原型。支持 count 。 |
selectPreprocessing | 查询 | 返回一个preprocessing 属性,其中包含项目原型预处理选项。 |
selectValueMap | 查询 | 返回一个valuemap 属性,其中包含项目原型值映射。 |
filter | 对象 | 仅返回与给定过滤器完全匹配的结果。 接受一个对象,其中键是属性名称,值要么是一个单一值,要么是一个与之匹配的值数组。 不支持 text 数据类型的属性。支持额外属性: host - 项目原型所属主机的技术名称。 |
limitSelects | 整数 | 限制子选择返回的记录数。 适用于以下子选择: selectGraphs - 结果将按name 排序;selectTriggers - 结果将按description 排序。 |
sortfield | 字符串/数组 | 根据给定属性对结果进行排序。 可能的值: itemid ,name ,key_ ,delay ,type ,status ,history ,trends ,discovered 。 |
countOutput | 布尔值 | 这些参数在参考说明中描述。 |
editable | 布尔值 | |
excludeSearch | 布尔值 | |
limit | 整数 | |
output | 查询 | |
preservekeys | 布尔值 | |
search | 对象 | |
searchByAny | 布尔值 | |
searchWildcardsEnabled | 布尔值 | |
sortorder | 字符串/数组 | |
startSearch | 布尔值 |
(integer/array)
返回其中之一:
countOutput
参数,返回被检索对象的数量。检索特定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",
"logtimefmt": "",
"templateid": "0",
"valuemapid": "0",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"interfaceid": "0",
"description": "",
"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": "",
"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": "",
"logtimefmt": "",
"templateid": "0",
"valuemapid": "0",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"interfaceid": "0",
"description": "The processor load is calculated as system CPU load divided by number of CPU cores.",
"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": "",
"parameters": []
}
],
"id": 1
}
为特定监控项ID查找一个依赖监控项。
请求:
{
"jsonrpc": "2.0",
"method": "item.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": "",
"logtimefmt": "",
"templateid": "0",
"valuemapid": "0",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"interfaceid": "0",
"description": "",
"evaltype": "0",
"master_itemid": "25545",
"jmx_endpoint": "",
"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": "",
"parameters": []
}
],
"id": 1
}
通过指定主机id的请求头部方法查找HTTP代理监控项原型。
请求:
{
"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": "",
"logtimefmt": "",
"templateid": "28255",
"valuemapid": "0",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"flags": "2",
"interfaceid": "2",
"description": "",
"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": "",
"parameters": []
}
],
"id": 1
}
CItemPrototype::get() in ui/include/classes/api/services/CItemPrototype.php.