diff options
author | David Sommerseth <davids@redhat.com> | 2015-11-12 15:14:12 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2015-11-12 15:16:19 +0100 |
commit | 601ef99ca66f694c1c7e27c97be0554572f5b6ad (patch) | |
tree | 8ce98bf8a196d095df15cab30e84eb6e8bb0227d /LogActio | |
parent | eea95bcc2850a1370b50e2db7506bb3f9aaec557 (diff) | |
download | logactio-601ef99ca66f694c1c7e27c97be0554572f5b6ad.tar.gz logactio-601ef99ca66f694c1c7e27c97be0554572f5b6ad.tar.xz logactio-601ef99ca66f694c1c7e27c97be0554572f5b6ad.zip |
Improve the message passing to the Reporter modules
The message sent to the Reporter modules contained a string of
each regex match group values separated by a pipe (|). This was
not flexible enough, so this change will send all the regex match
groups as a Python list to the Reporter.
The existing Reporter modules have currently just been modified
to stitch together the message list as a string identical to the
old behaviour now, to ensure backwards compatibility for now.
Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'LogActio')
-rw-r--r-- | LogActio/Reporters/HTTPreporter.py | 2 | ||||
-rw-r--r-- | LogActio/Reporters/QpidReporter.py | 2 | ||||
-rw-r--r-- | LogActio/Reporters/SMTPreporter.py | 2 | ||||
-rw-r--r-- | LogActio/__init__.py | 5 |
4 files changed, 4 insertions, 7 deletions
diff --git a/LogActio/Reporters/HTTPreporter.py b/LogActio/Reporters/HTTPreporter.py index 12dfca3..3e5150c 100644 --- a/LogActio/Reporters/HTTPreporter.py +++ b/LogActio/Reporters/HTTPreporter.py @@ -97,7 +97,7 @@ class HTTPreporter(ReporterQueue.ReporterQueue): def ProcessEvent(self, logfile, prefix, msg, count, threshold): # Format the report message msg = {"prefix": prefix, "count": count, "threshold": threshold, - "message": msg, "logfile": logfile} + "message": "|".join(msg), "logfile": logfile} # Queue the message for sending self._QueueMsg(0, msg) diff --git a/LogActio/Reporters/QpidReporter.py b/LogActio/Reporters/QpidReporter.py index 3295616..6c05df5 100644 --- a/LogActio/Reporters/QpidReporter.py +++ b/LogActio/Reporters/QpidReporter.py @@ -114,7 +114,7 @@ class QpidReporter(LogActio.ReporterQueue.ReporterQueue): def ProcessEvent(self, logfile, prefix, msg, count, threshold): # Format the report message msg = {"prefix": prefix, "count": count, "threshold": threshold, - "message": msg, "logfile": logfile} + "message": "|".join(msg), "logfile": logfile} # Queue the message for sending self._QueueMsg(0, json.dumps(msg)) diff --git a/LogActio/Reporters/SMTPreporter.py b/LogActio/Reporters/SMTPreporter.py index bf042f9..802a36a 100644 --- a/LogActio/Reporters/SMTPreporter.py +++ b/LogActio/Reporters/SMTPreporter.py @@ -133,7 +133,7 @@ class SMTPreporter(ReporterQueue.ReporterQueue): LogActio have detected %s events in the %s log file since it started running.\n The following information was extracted:\n %s -""" % (count, logfile, "\n".join(msg.split("|")))} +""" % (count, logfile, "\n".join(msg))} # Queue the message for sending self._QueueMsg(0, msg) diff --git a/LogActio/__init__.py b/LogActio/__init__.py index 8e3582a..b969232 100644 --- a/LogActio/__init__.py +++ b/LogActio/__init__.py @@ -122,15 +122,12 @@ class WatcherThread(threading.Thread): # a report it is 'rate-limit seconds' since last report. if alert["threshold"].CheckThreshold(alert, regexmatch): alert["alerts_sent"] += 1 - info = "|".join(regexmatch) # Gather regex exctracted info - if len(info) == 0: - info = None # Send the alert event to be processed, prioritise the # rule specific reporter over the default reporter rep = alert.has_key("reporters") and alert["reporters"] or self.__reporters for r in rep: - r.ProcessEvent(self.__logfile, alert["prefix"], info, + r.ProcessEvent(self.__logfile, alert["prefix"], regexmatch, alert["threshold"].GetCurrentCount(regexmatch)+1, alert["threshold"].GetThreshold()) # If reset-rule-rate-limits is set, make a note to reset these |