Skip to content

Commit db0b302

Browse files
committed
1 parent 99eccb8 commit db0b302

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Nagstamon/Servers/Zabbix.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ def _get_status(self):
182182
'filter': {'value': 1},
183183
})
184184

185+
# https://github.com/HenriWahl/Nagstamon/issues/826 Zabbix 5.0 may have an empty list for
186+
# the 'lastEvent' key if the trigger has no associated events
187+
for service in services:
188+
if service['lastEvent'] == []:
189+
service['lastEvent'] = {
190+
'eventid': -1,
191+
'acknowledged': '0',
192+
'name': service['description'],
193+
'severity': 'UNKN'
194+
}
195+
elif isinstance(service['lastEvent'], list):
196+
service['lastEvent'] = service['lastEvent'][0]
197+
185198
except ZabbixAPIException:
186199
# FIXME Is there a cleaner way to handle this? I just borrowed
187200
# this code from 80 lines ahead. -- AGV
@@ -499,9 +512,13 @@ def _set_acknowledge(self, host, service, author, comment, sticky, notify, persi
499512
for host_service in get_host.services:
500513
host_service = get_host.services[host_service]
501514
if host_service.name == s:
502-
eventids.add(host_service.eventid)
515+
eventid = host_service.eventid
516+
# https://github.com/HenriWahl/Nagstamon/issues/826 we may have set eventid = -1 earlier if there was no associated event
517+
if eventid == -1:
518+
continue
519+
eventids.add(eventid)
503520
if not host_service.allow_manual_close:
504-
unclosable_events.add(host_service.eventid)
521+
unclosable_events.add(eventid)
505522

506523
# If events pending of acknowledge, execute ack
507524
if len(eventids) > 0:

0 commit comments

Comments
 (0)