我目前正在尝试使用Zabbix 2.4 json api并且可以连接获取警报和触发器,但是我很难找到一种方法来检查给定的主机组是否包含没有打开的错误,从而是健康的。检查这个doenst的简单方法似乎存在?我搜索了stackoverflow,google和Zabbix文档。解决这个问题的任何线索?以下reuqest给出了错误,但没有办法判断错误是否仍然存在。
{
"jsonrpc": "2.0",
"method": "alert.get",
"params": {
"output": "extend",
"groupids": "83",
"time_from": "1441065600"
},
"auth": "ZZZZZZZZZZZZZZZZZZZZZZZZZ",
"id": 1
}
更新:(已解决)
$resource = "http://zabbix/api_jsonrpc.php"
$body = '
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"active": 1,
"only_true": "1",
"monitord": 1,
"selectGroups": 1,
"output": "extend",
"expandDescription": "1",
"selectGroups": "1",
"groupids": 83, <---- this field changes :)
"filter": {
"value": 1,
"priority": [3,4,5] <----- filter off low prios
},
"sortfield": "priority",
"sortorder": "DESC"
},
"auth": "ZZZZZZZZZZZZZZZZZZZZZZZZZ",
"id": 1
}
'
$result = Invoke-RestMethod -Method Post -Uri $resource -Body $body -ContentType "application/json"
$result.result
答案 0 :(得分:0)
使用主机/组的主动触发器。我使用的一些代码:
zapi.trigger.get(only_true=1,
skipDependent=1,
monitored=1,
active=1,
output='extend',
expandDescription=1,
selectGroups=1,
expandData='host',
hostids=<host_id>,
sortfield='priority',
sortorder='DESC',
filter={"value": 1, "priority": ['4','5']}
)
https://www.zabbix.com/documentation/2.4/manual/api/reference/trigger/get