Logo Search packages:      
Sourcecode: fail2ban version File versions  Download package

def logreader::logreader::LogReader::getFailures (   self  ) 

Gets all the failure in the log file which are
      newer than time.time()-self.findTime.
      
      Returns a dict with the IP, the number of failure
      and the latest failure time.

Definition at line 126 of file logreader.py.

00126                            :
            """ Gets all the failure in the log file which are
                  newer than time.time()-self.findTime.
                  
                  Returns a dict with the IP, the number of failure
                  and the latest failure time.
            """
            ipList = dict()
            logSys.debug(self.logPath)
            logFile = self.openLogFile()
            self.setFilePos(logFile)
            lastLine = None
            for line in logFile:
                  if not self.hasTime(line):
                        # There is no valid time in this line
                        continue
                  lastLine = line
                  for element in self.findFailure(line):
                        ip = element[0]
                        unixTime = element[1]
                        if unixTime < time.time()-self.findTime:
                              break
                        if self.inIgnoreIPList(ip):
                              logSys.debug("Ignore "+ip)
                              continue
                        logSys.debug("Found "+ip)
                        if ipList.has_key(ip):
                              ipList[ip] = (ipList[ip][0]+1, unixTime)
                        else:
                              ipList[ip] = (1, unixTime)
            self.lastPos = logFile.tell()
            if lastLine:
                  self.lastDate = self.getTime(lastLine)
            logFile.close()
            return ipList

      def findFailure(self, line):


Generated by  Doxygen 1.6.0   Back to index