Module: check_mk
Branch: master
Commit: 7132c994fec7f655015d3d55ea826af932217902
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7132c994fec7f6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 16 10:13:24 2014 +0200
livedump-mail-fetch: Now supporting either quoted-printable or non encoded mails
The tool livedump-mail-fetch which can be used to receive livedump results by fetching
them from a mailbox e.g. via POP3 always assumed incoming mails to be encoded as
quoted-printable.
This change makes the mail parsing configurable. The default is still quoted printable,
but can be set to "None" to assume plain text mails.
---
.werks/1058 | 13 +++++++++++++
ChangeLog | 1 +
doc/treasures/livedump/livedump-mail-fetch | 15 ++++++++++++---
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/.werks/1058 b/.werks/1058
new file mode 100644
index 0000000..0aa25c2
--- /dev/null
+++ b/.werks/1058
@@ -0,0 +1,13 @@
+Title: livedump-mail-fetch: Now supporting either quoted-printable or non encoded mails
+Level: 1
+Component: checks
+Version: 1.2.5i5
+Date: 1405498288
+Class: feature
+
+The tool livedump-mail-fetch which can be used to receive livedump results by fetching
+them from a mailbox e.g. via POP3 always assumed incoming mails to be encoded as
+quoted-printable.
+
+This change makes the mail parsing configurable. The default is still quoted printable,
+but can be set to "None" to assume plain text mails.
diff --git a/ChangeLog b/ChangeLog
index 6516fc1..a94f5f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@
* 0999 allnet_ip_sensoric.pressure: New Check for Pressure Sensors in ALLNET IP
Sensoric devices
* 1082 windows agent: now also available as msi installer...
* 0179 check_dns: It is now possible to use the local dns server in wato
configuration...
+ * 1058 livedump-mail-fetch: Now supporting either quoted-printable or non encoded
mails...
* 0994 FIX: agent plugin smart: fixed syntax error
* 0989 FIX: logwatch.ec: Fix forwarding multiple messages via syslog/TCP...
* 0943 FIX: if.include: fixed incorrect traffic percentage values in the check output
of if checks...
diff --git a/doc/treasures/livedump/livedump-mail-fetch
b/doc/treasures/livedump/livedump-mail-fetch
index af9a85b..d3b8f7f 100755
--- a/doc/treasures/livedump/livedump-mail-fetch
+++ b/doc/treasures/livedump/livedump-mail-fetch
@@ -24,6 +24,9 @@ omd_root = os.environ.get('OMD_ROOT')
pop_server = "pop.yourmailserver.com"
pop_user = "your-username(a)domain.com"
pop_pass = "secretpassword"
+# By default the mail body is treated to be encoded as "quoted-printable".
+# In the other case no decoding is not performed.
+encoding = "quoted-printable"
M = poplib.POP3_SSL(pop_server)
M.user(pop_user)
@@ -56,16 +59,22 @@ if config_mails:
mail_index, ident = config_mails[-1]
code, mail, num = M.retr(mail_index)
body_start_index = mail.index('')
- body = quopri.decodestring('\n'.join(mail[body_start_index:]))
+ if encoding == 'quoted-printable':
+ body = quopri.decodestring('\n'.join(mail[body_start_index:]))
+ else:
+ body = '\n'.join(mail[body_start_index:])
- file("%s/etc/nagios/conf.d/remote-%s.cfg" %
+ file("%s/etc/nagios/conf.d/remote-%s.cfg" %
(omd_root, ident), "w").write(body)
if status_mails:
for index in status_mails:
code, mail, code = M.retr(index)
body_start_index = mail.index('')
- body = quopri.decodestring('\n'.join(mail[body_start_index:]))
+ if encoding == 'quoted-printable':
+ body = quopri.decodestring('\n'.join(mail[body_start_index:]))
+ else:
+ body = '\n'.join(mail[body_start_index:])
fd, path = tempfile.mkstemp('', 'c',
"%s/tmp/nagios/checkresults" % omd_root)
os.write(fd, body)