Module: check_mk
Branch: master
Commit: 32e6594e1d5c775726107ad6fa1b934779a66fef
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=32e6594e1d5c77…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 9 10:06:47 2013 +0100
FIX Escaping several unwanted chars from incoming log messages
There are several kind of chars which are not wanted to be included
in log messages. For example the null byte is nothing to be expected
in log messages. We simply remove those chars now from the log messages.
Single log lines do not contain new line chars (\n), since they are
already processed as single lines. But snmp traps might contain those
chars, which might break e.g. processing the log history (resulting
in error messages "Invalid line XX in history file..."). The newline
chars are now simply removed from the incoming data.
This might change incoming values, but this seems to be better than
before. In future, when trap the parsing/processing code is extended
by single value matching etc., we might be able to clean this up.
---
.werks/304 | 19 +++++++++++++++++++
ChangeLog | 1 +
mkeventd/bin/mkeventd | 8 ++++----
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/.werks/304 b/.werks/304
new file mode 100644
index 0000000..f4fa08c
--- /dev/null
+++ b/.werks/304
@@ -0,0 +1,19 @@
+Title: Escaping several unwanted chars from incoming log messages
+Level: 1
+Component: ec
+Version: 1.2.3i8
+Date: 1386579742
+Class: fix
+
+There are several kind of chars which are not wanted to be included
+in log messages. For example the null byte is nothing to be expected
+in log messages. We simply remove those chars now from the log messages.
+
+Single log lines do not contain new line chars (\n), since they are
+already processed as single lines. But snmp traps might contain those
+chars, which might break e.g. processing the log history (resulting
+in error messages "Invalid line XX in history file..."). The newline
+chars are now simply removed from the incoming data.
+This might change incoming values, but this seems to be better than
+before. In future, when trap the parsing/processing code is extended
+by single value matching etc., we might be able to clean this up.
diff --git a/ChangeLog b/ChangeLog
index 18881cd..1a67109 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,7 @@
Event Console:
* 0301 Handling messages of special syslog format correctly...
* 0303 FIX: Old log entries were shown in event history first...
+ * 0304 FIX: Escaping several unwanted chars from incoming log messages...
1.2.3i7:
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 1e5665e..f81abfa 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -959,11 +959,11 @@ class EventServer:
# once we got here we have a real parsed trap which we convert to an event now
event = {
'time' : time.time(),
- 'host' : host,
+ 'host' : host.replace('\n', ''),
'priority' : 5, # notice
'facility' : 31, # not used by syslog -> we use this for all
traps
- 'application' : application,
- 'text' : ', '.join([ '%s: %s' % item for item
in trap ])
+ 'application' : application.replace('\n', ''),
+ 'text' : ', '.join([ '%s: %s' % (item[0],
str(item[1]).replace('\n', '')) for item in trap ])
}
self.process_event(event)
@@ -1121,7 +1121,7 @@ class EventServer:
def process_raw_lines(self, data, address = None):
lines = data.splitlines()
for line in lines:
- line = line.rstrip()
+ line = line.rstrip().replace('\0', '')
# Convert to Unicode, first assume UTF-8, then latin-1
try:
line = line.decode("utf-8")