integer/array discoveryrule.get(object parameters)
此方法允许根据给定的参数获取LLD规则。
(object)
参数定义期望输出。
此方法支持如下参数。
属性 类 | 描述 | |
---|---|---|
itemids | string/array | 返回给定IDs的LLD规则。 |
groupids | string/array | 只返回属于来自给定组的主机的LLD规则。 |
hostids | string/array | 返回属于给定主机的LLD规则。 |
inherited | boolean | 如果设为true ,返回自称自某模板的LLD规则。 |
interfaceids | string/array | 返回使用给定主机接口的LLD规则。 |
monitored | boolean | 如果设为true ,返回已经启用的属于已监控主机的LLD规则。 |
templated | boolean | 如果设为true ,返回属于(多个)模板的LLD规则。 |
templateids | string/array | 返回属于给定给定模板的LLD规则。 |
selectFilter | query | 在filter 中返回LLD使用的筛选器。 |
selectGraphs | query | 在graphs 属性中返回属于LLD规则的图表原型。Supports count . |
selectHostPrototypes | query | 在hostPrototypes 属性中返回属于该LLD规则的主机原型。Supports count . |
selectHosts | query | 在hosts 属性下以数组形式返回属于该LLD规则的主机。 |
selectItems | query | 在items 下返回属于该LLD规则的item。Supports count . |
selectTriggers | query | 在triggers 属性下返回属于该触发器原型。Supports count . |
selectApplicationPrototypes | query | 返回一个applicationPrototypes 属性,其中的应用程序原型属于属于此LLD规则的所有项原型。 |
selectLLDMacroPaths | query | 返回一个lld_macro_paths 属性,其中包含LLD宏列表和分配给每个相应宏的值的路径。 |
selectPreprocessing | query | 返回“预处理”属性中的项目预处理选项。 它具有以下特性: type - (string) 预处理选项类型:1 -自定义乘数; 2 -右纵倾; 3 -左纵倾; 4 -修剪; 5 -正则表达式匹配; 6 -布尔值到小数; 7 -八进制到十进制; 8—十六进制到十进制; 9 -简单的改变; 10 -每秒变化; 11 - XML XPath; 12 - JSONPath; 13 - In范围; 14 -匹配正则表达式; 15 -不匹配正则表达式; 16 -检查JSON中的错误 17 -检查XML中的错误; 18 -使用正则表达式检查错误; 19 -丢弃不变的; 20 -不改变心跳丢弃; 21 - JavaScript; 22 -普罗米修斯模式; 23 -普罗米修斯到JSON; 24 - CSV到JSON; 25 -替换 params - (string) 预处理选项使用的附加参数。多个参数以LF (\n)字符分隔。error_handler - (string) 预处理步骤失败时使用的动作类型:0 -错误信息被Zabbix服务器设置; 1 -弃值; 2 -设置自定义值; 3 -设置自定义错误信息。 error_handler_params - (string) 错误处理程序参数。 |
selectOverrides | query | 返回lld_rule_overrides 属性,其中包含在prototype对象上执行的覆盖过滤器、条件和操作的列表 |
filter | object | 仅返回紧缺匹配给定筛选条件的结果。 接受一个数组,这些数组的键为属性名称,值是一个或数组中的值的要匹配的值。 Supports additional filters: host - LLD规则所属主机的技术名称。 |
limitSelects | integer | 限制子选择返回的结果的数量。 适用于以下子选择: selctItems ;selectGraphs ;selectTriggers . |
sortfield | string/array | 根据给定的属性把结果进行排序。 可能的值是: itemid , name , key_ , delay , type and status . |
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)
返回:
获取主机“10202”所有的发现规则。
请求:
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "27425",
"type": "0",
"snmp_oid": "",
"hostid": "10202",
"name": "Network interface discovery",
"key_": "net.if.discovery",
"delay": "1h",
"state": "0",
"status": "0",
"trapper_hosts": "",
"error": "",
"templateid": "22444",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"interfaceid": "119",
"description": "Discovery of network interfaces as defined in global regular expression \"Network interfaces for discovery\".",
"lifetime": "30d",
"jmx_endpoint": "",
"master_itemid": "0",
"timeout": "3s",
"url": "",
"query_fields": [],
"posts": "",
"status_codes": "200",
"follow_redirects": "1",
"post_type": "0",
"http_proxy": "",
"headers": [],
"retrieve_mode": "0",
"request_method": "0",
"ssl_cert_file": "",
"ssl_key_file": "",
"ssl_key_password": "",
"verify_peer": "0",
"verify_host": "0",
"allow_traps": "0"
},
{
"itemid": "27426",
"type": "0",
"snmp_oid": "",
"hostid": "10202",
"name": "Mounted filesystem discovery",
"key_": "vfs.fs.discovery",
"delay": "1h",
"state": "0",
"status": "0",
"trapper_hosts": "",
"error": "",
"templateid": "22450",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"interfaceid": "119",
"description": "Discovery of file systems of different types as defined in global regular expression \"File systems for discovery\".",
"lifetime": "30d",
"jmx_endpoint": "",
"master_itemid": "0",
"timeout": "3s",
"url": "",
"query_fields": [],
"posts": "",
"status_codes": "200",
"follow_redirects": "1",
"post_type": "0",
"http_proxy": "",
"headers": [],
"retrieve_mode": "0",
"request_method": "0",
"ssl_cert_file": "",
"ssl_key_file": "",
"ssl_key_password": "",
"verify_peer": "0",
"verify_host": "0",
"allow_traps": "0"
}
],
"id": 1
}
检索LLD规则“24681”的名称及其过滤条件。筛选器使用“and”求值类型,因此“formula”属性为空,并自动生成“eval_formula”。
请求:
{
"jsonrpc": "2.0",
"method": "discoveryrule.get",
"params": {
"output": [
"name"
],
"selectFilter": "extend",
"itemids": ["24681"]
},
"auth": "038e1d7b1735c6a5436ee9eae095879e",
"id": 1
}
响应:
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "24681",
"name": "Filtered LLD rule",
"filter": {
"evaltype": "1",
"formula": "",
"conditions": [
{
"macro": "{#MACRO1}",
"value": "@regex1",
"operator": "8",
"formulaid": "A"
},
{
"macro": "{#MACRO2}",
"value": "@regex2",
"operator": "8",
"formulaid": "B"
},
{
"macro": "{#MACRO3}",
"value": "@regex3",
"operator": "8",
"formulaid": "C"
}
],
"eval_formula": "A and B and C"
}
}
],
"id": 1
}
根据主机的规则URL字段值获取LLD规则。仅返回精确匹配定义的URL字符串的规则。
请求:
{
"jsonrpc": "2.0",
"method": "discoveryrule.get",
"params": {
"hostids": "10257",
"filter": {
"type": "19",
"url": "http://127.0.0.1/discoverer.php"
}
},
"id": 39,
"auth": "d678e0b85688ce578ff061bd29a20d3b"
}
响应:
{
"jsonrpc": "2.0",
"result": [
{
"itemid": "28336",
"type": "19",
"snmp_oid": "",
"hostid": "10257",
"name": "API HTTP agent",
"key_": "api_discovery_rule",
"delay": "5s",
"history": "90d",
"trends": "0",
"status": "0",
"value_type": "4",
"trapper_hosts": "",
"units": "",
"error": "",
"logtimefmt": "",
"templateid": "0",
"valuemapid": "0",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"flags": "1",
"interfaceid": "5",
"description": "",
"inventory_link": "0",
"lifetime": "30d",
"state": "0",
"jmx_endpoint": "",
"master_itemid": "0",
"timeout": "3s",
"url": "http://127.0.0.1/discoverer.php",
"query_fields": [
{
"mode": "json"
},
{
"elements": "2"
}
],
"posts": "",
"status_codes": "200",
"follow_redirects": "1",
"post_type": "0",
"http_proxy": "",
"headers": {
"X-Type": "api",
"Authorization": "Bearer mF_A.B5f-2.1JcM"
},
"retrieve_mode": "0",
"request_method": "1",
"ssl_cert_file": "",
"ssl_key_file": "",
"ssl_key_password": "",
"verify_peer": "0",
"verify_host": "0",
"allow_traps": "0"
}
],
"id": 39
}
CDiscoveryRule::get() in frontends/php/include/classes/api/services/CDiscoveryRule.php.
CDiscoveryRule::get() in ui/include/classes/api/services/CDiscoveryRule.php.