【问题标题】:Zabbix Json Api get health of host or hostgroupZabbix Json Api 获取主机或主机组的健康状况
【发布时间】:2015-10-28 15:59:46
【问题描述】:

我目前正在尝试 Zabbix 2.4 json api 并且可以连接获取警报和触发器,但我无法找到一种方法来检查给定主机组是否不包含打开的错误并且因此是健康的。似乎存在一种简单的检查方法?我搜索了 stackoverflow、google 和 Zabbix 文档。关于解决这个问题的任何线索?以下请求给了我错误,但无法判断错误是否仍然存在。

{
"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

【问题讨论】:

    标签: json api zabbix


    【解决方案1】:

    使用主机/组的活动触发器。我使用的一些代码:

    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

    【讨论】:

    • 谢谢,我已成功将您的示例转换为 powershell 发起的 json 请求,我已经更新了我的工作示例
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多