Zabbix Json Api 获取主机或主机组的健康状况
Zabbix Json Api get health of host or hostgroup
我目前正在试用 Zabbix 2.4 json api 并且可以连接获取警报和触发器,但我无法找到一种方法来检查给定的主机组是否包含未打开的错误并且是从而健康。似乎存在一种检查此问题的简单方法?我搜索了 Whosebug、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
使用 host/group 的活动触发器。我使用的一些代码:
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
我目前正在试用 Zabbix 2.4 json api 并且可以连接获取警报和触发器,但我无法找到一种方法来检查给定的主机组是否包含未打开的错误并且是从而健康。似乎存在一种检查此问题的简单方法?我搜索了 Whosebug、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
使用 host/group 的活动触发器。我使用的一些代码:
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