Ad Widget

Collapse

请问trigger中expression的id代表的内容在哪里找

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 请问trigger中expression的id代表的内容在哪里找

    代码 nodejs 想实现通过JSON-RPC更改trigger的阈值
    第一步获得 trigger的所有内容
    client.call(
    {
    "jsonrpc": "2.0",
    "method": "trigger.get",
    "params": {
    "output": "extend",
    "hostids": 10084,
    "search": {
    "description": "Too many processes on {HOST.NAME}"
    }
    },
    "auth": authid,
    "id": 1
    },//itemid = 13083?
    function (err, res) {
    if (err) {
    console.log(err)
    }
    else {
    console.log("got trigger info"+JSON.stringify(res));
    }
    }
    );
    得到返回的JSON:
    got trigger info{"jsonrpc":"2.0","result":[{"triggerid":"13496","expression":"{13083}>300","d escription":"Too many processes on {HOST.NAME}","url":"","status":"0","value":"1","pr iority":"3","lastchange":"1487751972","comments":" ","error":"","templateid":"10190","type":"0","stat e":"0","flags":"0"}],"id":1}
    这里的{13083}>300 其实是 {Zabbix serverroc.num[].avg(5m)}>300
    第二步更改trigger的expression
    client.call(
    {
    "jsonrpc": "2.0",
    "method": "trigger.update",
    "params": {
    "triggerid": "13496",
    // "status":0
    "expression":"{Zabbix serverroc.num[].avg(5m)}>600"
    },
    "auth": authid,
    "id": 1
    } ,
    function (err,res){
    if(err){console.log(err);}
    else{
    console.log("update1"+JSON.stringify(res));
    }
    }
    );
    返回更改成功的信息,但是再次去查询这个trigger信息的时候expression的id 变了。。。。
    got trigger info{"jsonrpc":"2.0","result":[{"triggerid":"13496","expression":"{13171}>600","description":"Too many processes on {HOST.NAME}","url":"","status":"0","value":"1","pr iority":"3","lastchange":"1487751972","comments":" ","error":"","templateid":"10190","type":"0","stat e":"0","flags":"0"}],"id":1}

    请问如何找到这个expressionid 对应的信息如何获得,每次更改都改变。。

  • Charles.Wang
    replied
    已经解决了
    需要在查询的JSON中添加一个flag,代码如下
    client.call(
    {
    "jsonrpc": "2.0",
    "method": "trigger.get",
    "params": {
    "output": "extend",
    "hostids": 10084,
    "expandExpression":"extend",
    "search": {
    "description": "Too many processes on {HOST.NAME}"
    }
    },
    "auth": authid,
    "id": 1
    },//itemid = 13083?
    function (err, res) {
    if (err) {
    console.log(err)
    }
    else {
    console.log("trigger info = "+JSON.stringify(res));
    }
    }
    );
    返回的JSON中的表达式已经正常显示了
    trigger info ={"jsonrpc":"2.0","result":[{"triggerid":"13496","expression":"{Zabbix serverroc.num[].avg(5m)}>300","description":"Too many processes on {HOST.NAME}","url":"","status":"0","value":"1","pr iority":"3","lastchange":"1487751972","comments":" ","error":"","templateid":"10190","type":"0","stat e":"0","flags":"0"}],"id":1}

    Leave a comment:

Announcement

Collapse
No announcement yet.
Working...
X