summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2015-09-25 12:33:44 +0200
committerDavid Sommerseth <davids@redhat.com>2015-09-25 12:33:44 +0200
commit3811f32cc5acb563de15eaaa07f9cfdd5016bca8 (patch)
tree6bf555983fa1e681eea405aebda8c1eb67b67325
parenta6dd81ccb0c0bf2f0e3172b15b19274433df2d53 (diff)
downloadlogactio-3811f32cc5acb563de15eaaa07f9cfdd5016bca8.tar.gz
logactio-3811f32cc5acb563de15eaaa07f9cfdd5016bca8.tar.xz
logactio-3811f32cc5acb563de15eaaa07f9cfdd5016bca8.zip
Fix typo and catch any other dict key issues in ThreadWatch
Signed-off-by: David Sommerseth <davids@redhat.com>
-rw-r--r--LogActio/ThresholdWatch.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/LogActio/ThresholdWatch.py b/LogActio/ThresholdWatch.py
index 033109c..9c36c98 100644
--- a/LogActio/ThresholdWatch.py
+++ b/LogActio/ThresholdWatch.py
@@ -80,7 +80,6 @@ class ThresholdType_Exact(object):
self.__timeframe = params["timeframe"] and int(params["timeframe"]) or None
self.__ratelimit = params["ratelimit"] and int(params["ratelimit"]) or None
-
def __gen_hash(self, regexmatch):
return hashlib.sha384("|".join(regexmatch)).hexdigest()
@@ -104,12 +103,17 @@ class ThresholdType_Exact(object):
or now <= (lastevent["lastseen"] + self.__timeframe))
and (self.__ratelimit is None or now > (lastevent["lastsent"] + self.__ratelimit)))
- if (self.__timeframe and (lastevent["lastseen"] > 0)
- and (now >= (lastevent["lasteen"] + self.__timeframe))):
- # If the time-frame have timed out, reset it
- self.__lastseen = 0
- else:
+ try:
+ if (self.__timeframe and lastevent.has_key('lastseen')
+ and (lastevent["lastseen"] > 0)
+ and (now >= (lastevent["lastseen"] + self.__timeframe))):
+ # If the time-frame have timed out, reset it
+ self.__lastseen = 0
+ else:
+ self.__lastseen = now
+ except KeyError, e:
self.__lastseen = now
+
else:
# Not seen before, register it as a new one
self.__matchedgroups[rghash] = {