Zabbix自动删除无法访问的主机

我需要在zabbix中自动删除我的无法访问/停止的主机。 所有主机都使用活动代理进行监控,因此networking发现自动删除在我的情况下不方便/有用。

我已经写了一个小python脚本来使用zabbix-api从zabbix中删除/删除主机。 但是我想要实现的是如下:

1:如果主机无法连接超过2小时,请find所有主机

2:标记其状态并更新待删除主机的列表

3:24小时后删除所有这些主机。

如果在第二步不可能的情况下,我现在对第一步和第三步非常满意。

我无法findzabbix的正确api响应,以确定主机已停机或无法访问超过一个小时或xyz时间。

PS:我已经提到了URL1和URL2,但仍然没有运气。

我使用触发器值从zabbix中删除主机,checck如果下面的代码适合你:

from zabbix_api import ZabbixAPI, Already_Exists z = ZabbixAPI(server="https://zabbix.example.com/zabbix") z.login("exampleuser", "exampleuser") for trigger in z.trigger.get({"output": [ "triggerid", "description", "priority" ], "filter": { "value": 1 }, "sortfield": "priority", "sortorder": "DESC"}): if trigger["description"] == 'Zabbix agent on {HOST.NAME} is unreachable for 5 minutes': trigmsg = z.trigger.get({"triggerids": trigger["triggerid"], "selectHosts": "extend"}) for tm in trigmsg: for l in tm['hosts']: print l['name'], l['hostid'] print "Will kill host " + l['hostid'] + " " + l['host'] + trigger["description"] z.host.delete( [int(l['hostid'])] )