Module: check_mk
Branch: master
Commit: 9540bf31186d96c55b99df3b94adfd908d9eebdb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9540bf31186d96…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 16 16:00:39 2018 +0200
Fixed possible exception when playing sounds is enabled
When a host / service reports a state code that is not a normal
monitoring state (e.g. 126), then an exception could occur when
playing sounds is enabled.
Change-Id: If1fce996b389a72a99a7a49ecc697dbbe0083a12
---
web/htdocs/views.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index d1016ce..5966ac9 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2037,8 +2037,15 @@ def save_state_for_playing_alarm_sounds(row):
for state_map, state in [
(host_state_map, row.get("host_hard_state",
row.get("host_state"))),
(service_state_map, row.get("service_last_hard_state",
row.get("service_state"))) ]:
- if state != None:
- g_alarm_sound_states.add(state_map[int(state)])
+ if state is None:
+ continue
+
+ try:
+ state_name = state_map[int(state)]
+ except KeyError:
+ continue
+
+ g_alarm_sound_states.add(state_name)
def play_alarm_sounds():