Module: check_mk
Branch: master
Commit: 29888734dbd07c32560c797365ac8a9b46682d9a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=29888734dbd07c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue May 31 10:09:22 2016 +0200
3582 FIX check_mail: Fixed issue with processing multipart mails
When the check is configured to forward mails to the event console,
it was unable to parse multipart mails. This has been fixed. The
events now get the contents of the first text/plain part added until
the configured body limit.
---
.werks/3582 | 13 +++++++++++++
ChangeLog | 1 +
doc/treasures/active_checks/check_mail | 9 +++++++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.werks/3582 b/.werks/3582
new file mode 100644
index 0000000..2427dd8
--- /dev/null
+++ b/.werks/3582
@@ -0,0 +1,13 @@
+Title: check_mail: Fixed issue with processing multipart mails
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1464681864
+
+When the check is configured to forward mails to the event console,
+it was unable to parse multipart mails. This has been fixed. The
+events now get the contents of the first text/plain part added until
+the configured body limit.
diff --git a/ChangeLog b/ChangeLog
index 1023a0c..a6d8f53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -246,6 +246,7 @@
* 3624 FIX: oracle_asm_diskgroup: fixed dismounted disk handling
* 3625 FIX: zfs_arc_cache: fixed data handling if hits and misses are missing
* 3626 FIX: dell_eql_storage: fixed scan function if sysDescr is empty
+ * 3582 FIX: check_mail: Fixed issue with processing multipart mails...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/doc/treasures/active_checks/check_mail
b/doc/treasures/active_checks/check_mail
index 85b9dad..fecf5cf 100755
--- a/doc/treasures/active_checks/check_mail
+++ b/doc/treasures/active_checks/check_mail
@@ -300,8 +300,13 @@ def forward_to_ec(mails):
log_line = subject
# Now add the body to the event
if msg.is_multipart():
- for payload in msg.get_payload():
- log_line += '|' + payload.get_payload()[:body_limit]
+ # only care for the first text/plain element
+ for part in msg.walk():
+ content_type = part.get_content_type()
+ disposition = str(part.get('Content-Disposition'))
+ if content_type == 'text/plain' and 'attachment' not in
disposition:
+ log_line += '|' + part.get_payload()[:body_limit]
+ break
else:
log_line += '|' + msg.get_payload()[:body_limit]
log_line = log_line.replace('\r\n', '\0')