代码 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 server
roc.num[].avg(5m)}>300
第二步更改trigger的expression
client.call(
{
"jsonrpc": "2.0",
"method": "trigger.update",
"params": {
"triggerid": "13496",https://myip.kim/ https://birthdaywishes.onl/ https://elecpay.in/tneb/
// "status":0
"expression":"{Zabbix server
roc.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" ,"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}
请问如何找到这个expressionid 对应的信息如何获得,每次更改都改变。。
第一步获得 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 server
roc.num[].avg(5m)}>300第二步更改trigger的expression
client.call(
{
"jsonrpc": "2.0",
"method": "trigger.update",
"params": {
"triggerid": "13496",https://myip.kim/ https://birthdaywishes.onl/ https://elecpay.in/tneb/
// "status":0
"expression":"{Zabbix server
roc.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" ,"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}
请问如何找到这个expressionid 对应的信息如何获得,每次更改都改变。。