我需要从我的 Zabbix Dashboard 中获取所有触发器。因此,如果有触发器,无论严重程度如何,我都需要得到这个。这是带有一个条目的触发器仪表板的屏幕截图:
单击它以放大它
因此,如果没有活动的触发器,则此列表为空。
我已经:
jsonObj.put("method", "trigger.get");
// Priority: 0 = Not classified | 1 = Information | 2 = Warning | 3 =
// Average | 4 = High | 5 = Disaster
jsonObj.put(
"params",
(new JSONObject().put(
"filter",
new JSONObject().put("priority", 1).put("group", "WZU-Server")).put(
"output", "extend")));
但这会给我带来很多旧的触发器,这些触发器不再活跃了。我真的只需要显示在仪表板上的触发器!
我怎样才能做到这一点?我用 zabbix api 几个小时都没有得到它......
INFO:
组 ID 为 7
此组中有不同的主机
如果触发器的状态为 OK,我不需要它。仅当有问题时。
编辑
我真的很接近我的目标。
我当前的代码如下所示:
int count = 2;
while (count <= 5){
jsonObj.put("jsonrpc", "2.0");
jsonObj.put("method", "trigger.get");
// Value: 0 = OK | 1 = PROBLEM | 2 = UNKNOWN
// Priority: 0 = Not classified | 1 = Information | 2 = Warning | 3 =
// Average | 4 = High | 5 = Disaster
// count = priority. It start with two and end with 5
jsonObj.put("params", (new JSONObject().put("filter", new JSONObject().put("priority", count).put("group", "WZU-Server").put("value", 1)).put("output", "extend")));
jsonObj.put("id", 0);
jsonObj.put("auth", "8ba6b9f29dd68e0c98cdea9ee01f2614");
putMethod.setRequestEntity(new StringRequestEntity(jsonObj.toString(), "application/json", "UTF-8"));
}
此时,我的仪表板是空的。所以我不应该得到这段代码的任何对象。
“警告”是空的,所以没关系。
“平均返回 8 个对象。所有对象都超过一周。糟糕!
“高”为空,所以没关系。
“灾难”返回 1 个对象。这个对象超过一周。糟糕!
那么我怎样才能实现我只获得仪表板的条目呢?