summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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] = {