ZABBIX Forums  

Go Back   ZABBIX Forums > Zabbix in Your Language > 中文论坛

Reply
 
Thread Tools Display Modes
  #1  
Old 23-02-2017, 10:48
Charles.Wang Charles.Wang is offline
Junior Member
 
Join Date: Feb 2017
Posts: 3
Question 请问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 对应的信息如何获得,每次更改都改变。。
Reply With Quote
  #2  
Old 24-02-2017, 05:16
Charles.Wang Charles.Wang is offline
Junior Member
 
Join Date: Feb 2017
Posts: 3
Default

已经解决了
需要在查询的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}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:51.