|
|
|
@ -134,11 +134,13 @@ class LogReader:
|
|
|
|
|
logSys.debug(self.logPath)
|
|
|
|
|
logFile = self.openLogFile()
|
|
|
|
|
self.setFilePos(logFile)
|
|
|
|
|
lastLine = ''
|
|
|
|
|
lastLine = None
|
|
|
|
|
for line in logFile:
|
|
|
|
|
if not self.hasTime(line):
|
|
|
|
|
# There is no valid time in this line
|
|
|
|
|
continue
|
|
|
|
|
lastLine = line
|
|
|
|
|
failList = self.findFailure(line)
|
|
|
|
|
for element in failList:
|
|
|
|
|
for element in self.findFailure(line):
|
|
|
|
|
ip = element[0]
|
|
|
|
|
unixTime = element[1]
|
|
|
|
|
if unixTime < time.time()-self.findTime:
|
|
|
|
@ -152,6 +154,7 @@ class LogReader:
|
|
|
|
|
else:
|
|
|
|
|
ipList[ip] = (1, unixTime)
|
|
|
|
|
self.lastPos = logFile.tell()
|
|
|
|
|
if lastLine:
|
|
|
|
|
self.lastDate = self.getTime(lastLine)
|
|
|
|
|
logFile.close()
|
|
|
|
|
return ipList
|
|
|
|
@ -175,6 +178,15 @@ class LogReader:
|
|
|
|
|
failList.append([ip, date])
|
|
|
|
|
return failList
|
|
|
|
|
|
|
|
|
|
def hasTime(self, line):
|
|
|
|
|
""" Return true if the line contains a date
|
|
|
|
|
"""
|
|
|
|
|
timeMatch = re.search(self.timeregex, line)
|
|
|
|
|
if timeMatch:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def getTime(self, line):
|
|
|
|
|
""" Gets the time of a log message.
|
|
|
|
|
"""
|
|
|
|
|