Module: check_mk
Branch: master
Commit: c1ca2a3c2bd99a24d1dd8c6b70981d29e56a48e5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c1ca2a3c2bd99a…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Mar 11 15:40:39 2014 +0100
FIX mkeventd: fixed encoding of unicode characters in the snmptrap receiver
Messages coming in via the build-in snmptrap receiver and containing unicode characters
never matched any rule because the matching algorithm threw an exception. This
has been fixed.
---
.werks/590 | 10 ++++++++++
ChangeLog | 1 +
mkeventd/bin/mkeventd | 8 +++++++-
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/.werks/590 b/.werks/590
new file mode 100644
index 0000000..20753cf
--- /dev/null
+++ b/.werks/590
@@ -0,0 +1,10 @@
+Title: mkeventd: fixed encoding of unicode characters in the snmptrap receiver
+Level: 2
+Component: ec
+Version: 1.2.5i1
+Date: 1394548319
+Class: fix
+
+Messages coming in via the build-in snmptrap receiver and containing unicode characters
+never matched any rule because the matching algorithm threw an exception. This
+has been fixed.
diff --git a/ChangeLog b/ChangeLog
index 8ea63d9..e71ac16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -345,6 +345,7 @@
* 0679 FIX: Allow non-Ascii characters in generated events
* 0680 FIX: Do not allow spaces in host names in event simulator...
* 0672 FIX: Service item of "Check event state in event console" checks can
now be configured...
+ * 0590 FIX: mkeventd: fixed encoding of unicode characters in the snmptrap
receiver...
Livestatus:
* 0337 New header for limiting the execution time of a query...
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index b00f40f..c9673a1 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -957,13 +957,19 @@ class EventServer:
return # dropping unhandled snmp version
# once we got here we have a real parsed trap which we convert to an event now
+ text = ', '.join([ '%s: %s' % (item[0],
str(item[1]).replace('\n', '')) for item in trap ])
+ # Convert to Unicode, first assume UTF-8, then latin-1
+ try:
+ text = text.decode("utf-8")
+ except:
+ text = text.decode("latin-1")
event = {
'time' : time.time(),
'host' : host.replace('\n', ''),
'priority' : 5, # notice
'facility' : 31, # not used by syslog -> we use this for all
traps
'application' : application.replace('\n', ''),
- 'text' : ', '.join([ '%s: %s' % (item[0],
str(item[1]).replace('\n', '')) for item in trap ])
+ 'text' : text
}
self.process_event(event)