这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.

更新

说明

object discoveryrule.update(object/array lldRules)

此方法允许更新已存在的LLD规则。

参数

(object/array) 要更新的LLD规则属性。

每个LLD规则的itemid属性必须被定义,其他属性为可选。值传递要被更新的属性,其他属性保持不变。

另外见标准的LLD规则属性,此方法接受如下参数。

属性 类 描述
filter object LLD规则LLD规则的过滤对象
preprocessing array LLD规则预处理选项
lld_macro_paths array LLD规则预处理选项
overrides array LLD规则覆盖选项

返回值

(object)itemids属性下返回一个包含被更新的LLD规则的IDs。

示例

为LLD规则添加一个筛选器

添加一个过滤器,以便{#FSTYPE}宏的内容与lld发现规则 @File systems for discovery的正则表达式匹配。

请求:

{
           "jsonrpc": "2.0",
           "method": "discoveryrule.update",
           "params": {
               "itemid": "22450",
               "filter": {
                   "evaltype": 1,
                   "conditions": [
                       {
                           "macro": "{#FSTYPE}",
                           "value": "@File systems for discovery"
                       }
                   ]
               }
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "22450"
               ]
           },
           "id": 1
       }

禁用trapping

禁用LLD trapping 发现规则。

请求:

{
           "jsonrpc": "2.0",
           "method": "discoveryrule.update",
           "params": {
               "itemid": "22450",
               "lld_macro_paths": [
                   {
                       "lld_macro": "{#MACRO1}",
                       "path": "$.json.path"
                   }
               ]
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

响应:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "28336"
               ]
           },
           "id": 36
       }

来源

CDiscoveryRule::update() in frontends/php/include/classes/api/services/CDiscoveryRule.php.

Updating LLD rule preprocessing options

Update an LLD rule with preprocessing rule “JSONPath”.

Request:

{
           "jsonrpc": "2.0",
           "method": "discoveryrule.update",
           "params": {
               "itemid": "44211",
               "preprocessing": [
                   {
                       "type": "12",
                       "params": "$.path.to.json",
                       "error_handler": "2",
                       "error_handler_params": "5"
                   }
               ]
           },
           "auth": "700ca65537074ec963db7efabda78259",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "itemids": [
                   "44211"
               ]
           },
           "id": 1
       }

Source

CDiscoveryRule::update() in ui/include/classes/api/services/CDiscoveryRule.php.