Module: check_mk
Branch: master
Commit: f913c02449ce58473e8e97496955a40479fc3343
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f913c02449ce58…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jan 30 16:19:08 2015 +0100
#1988 FIX Gracefully handline invalid empty bulk notification files from previous buggy
versions
---
.werks/1988 | 10 ++++++++++
ChangeLog | 1 +
modules/notify.py | 19 +++++++++++++++----
3 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/.werks/1988 b/.werks/1988
new file mode 100644
index 0000000..d7ad40a
--- /dev/null
+++ b/.werks/1988
@@ -0,0 +1,10 @@
+Title: Gracefully handline invalid empty bulk notification files from previous buggy
versions
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1422631128
+
+
diff --git a/ChangeLog b/ChangeLog
index 6cce05e..c81e3ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -193,6 +193,7 @@
* 1664 FIX: mknotifyd: further performance improvements for notification forwarding
* 1205 FIX: RBN: Fixed match contactgroup condition...
* 1810 FIX: Rule based notifications: Fixed output of non contact mail recipient
address in analyze table...
+ * 1988 FIX: Gracefully handline invalid empty bulk notification files from previous
buggy versions
BI:
* 1784 FIX: Fix exception in BI Boxes when parents are being used
diff --git a/modules/notify.py b/modules/notify.py
index bc28896..5ea4064 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -1601,13 +1601,21 @@ def notify_bulk(dirname, uuids):
old_params = None
unhandled_uuids = []
for mtime, uuid in uuids:
- params, context = eval(file(dirname + "/" + uuid).read())
+ try:
+ params, context = eval(file(dirname + "/" + uuid).read())
+ except Exception, e:
+ if opt_debug:
+ raise
+ notify_log(" Deleting corrupted or empty bulk file %s/%s: %s" %
(dirname, uuid, e))
+ continue
+
if old_params == None:
old_params = params
elif params != old_params:
notify_log(" Parameters are different from previous, postponing into
separate bulk")
unhandled_uuids.append((mtime, uuid))
continue
+
bulk_context.append("\n")
for varname, value in context.items():
bulk_context.append("%s=%s\n" % (varname,
value.replace("\r", "").replace("\n", "\1")))
@@ -1618,9 +1626,12 @@ def notify_bulk(dirname, uuids):
plugin_name = "bulk " + (plugin or "plain email")
core_notification_log(plugin_name, context)
- parameter_context = create_bulk_parameter_context(old_params)
- context_text = "".join(parameter_context + bulk_context)
- call_bulk_notification_script(plugin, context_text)
+ if bulk_context: # otherwise: only corrupted files
+ parameter_context = create_bulk_parameter_context(old_params)
+ context_text = "".join(parameter_context + bulk_context)
+ call_bulk_notification_script(plugin, context_text)
+ else:
+ notify_log("No valid notification file left. Skipping this bulk.")
# Remove sent notifications
for mtime, uuid in uuids: