Module: check_mk
Branch: master
Commit: 77b01ae1809e9fd40a709796eaa21f0151e284e1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=77b01ae1809e9f…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Oct 27 15:53:59 2014 +0100
#1425 New section header option "encoding"
If you write your own check plugins you might know that a section
header can contain additional options separated by a colon.<br>
For example
<tt><<<lnx_distro:sep(124):persist(141442125)>>></tt><br><br>
An additional option <tt>encoding</tt> has been introduced.
Generally all check plugins should output valid utf-8 encoded text.
In some instances this is not possible, because the plugin itself
has its own hardcoded encoding. With the encoding option you can specify
the encoding for this entire section.<br>
Check_MK will decode the given section output and recode it into utf-8 for
further processing.
---
.werks/1425 | 19 +++++++++++++++++++
ChangeLog | 1 +
modules/check_mk_base.py | 10 ++++++++++
3 files changed, 30 insertions(+)
diff --git a/.werks/1425 b/.werks/1425
new file mode 100644
index 0000000..0a91837
--- /dev/null
+++ b/.werks/1425
@@ -0,0 +1,19 @@
+Title: New section header option "encoding"
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1414421080
+Class: feature
+
+If you write your own check plugins you might know that a section
+header can contain additional options separated by a colon.<br>
+For example
<tt><<<lnx_distro:sep(124):persist(141442125)>>></tt><br><br>
+
+An additional option <tt>encoding</tt> has been introduced.
+Generally all check plugins should output valid utf-8 encoded text.
+In some instances this is not possible, because the plugin itself
+has its own hardcoded encoding. With the encoding option you can specify
+the encoding for this entire section.<br>
+Check_MK will decode the given section output and recode it into utf-8 for
+further processing.
diff --git a/ChangeLog b/ChangeLog
index ff01a77..ac6c6e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -81,6 +81,7 @@
* 1191 Linux agent now also sends information about tmpfs...
* 1424 mknotifyd: now able to check if its still listening for telegrams...
* 1193 ps: Manual Checks can now use RegEx for user matching...
+ * 1425 New section header option "encoding"...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 795c989..750349f 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -757,6 +757,7 @@ def parse_info(lines, hostname):
section = []
section_options = {}
separator = None
+ encoding = None
for line in lines:
if line[:4] == '<<<<' and line[-4:] ==
'>>>>':
host = line[4:-4]
@@ -799,7 +800,16 @@ def parse_info(lines, hostname):
until = int(section_options["persist"])
persist[section_name] = ( until, section )
+ # The section data might have a different encoding
+ encoding = section_options.get("encoding")
+
elif line != '':
+ if encoding:
+ try:
+ decoded_line = line.decode(encoding)
+ line = decoded_line.encode('utf-8')
+ except:
+ pass
section.append(line.split(separator))
return info, piggybacked, persist