mirror of https://github.com/fail2ban/fail2ban
- Add log4py support
- Remove old verbose mode git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@18 a942ae1a-1317-0410-a47c-b1dcaea8d6050.6
parent
c286d56855
commit
a2ea1164b3
|
@ -28,12 +28,12 @@ import os, sys
|
|||
|
||||
class LogReader:
|
||||
|
||||
def __init__(self, logPath, findTime = 3600, verbose = False):
|
||||
def __init__(self, logPath, logSys, findTime = 3600):
|
||||
self.logPath = logPath
|
||||
self.findTime = findTime
|
||||
self.ignoreIpList = []
|
||||
self.lastModTime = 0
|
||||
self.verbose = verbose
|
||||
self.logSys = logSys
|
||||
|
||||
def addIgnoreIP(self, ip):
|
||||
self.ignoreIpList.append(ip)
|
||||
|
@ -45,7 +45,7 @@ class LogReader:
|
|||
try:
|
||||
fileHandler = open(self.logPath)
|
||||
except OSError:
|
||||
print "Unable to open", self.logPath
|
||||
self.logSys.error("Unable to open "+self.logPath)
|
||||
sys.exit(-1)
|
||||
return fileHandler
|
||||
|
||||
|
@ -53,14 +53,13 @@ class LogReader:
|
|||
try:
|
||||
logStats = os.stat(self.logPath)
|
||||
except OSError:
|
||||
print "Unable to get stat on", logPath
|
||||
self.logSys.error("Unable to get stat on "+self.logPath)
|
||||
sys.exit(-1)
|
||||
|
||||
if self.lastModTime == logStats.st_mtime:
|
||||
return False
|
||||
else:
|
||||
if self.verbose:
|
||||
print self.logPath, 'has been modified'
|
||||
self.logSys.debug(self.logPath+" has been modified")
|
||||
self.lastModTime = logStats.st_mtime
|
||||
return True
|
||||
|
||||
|
|
|
@ -41,11 +41,9 @@ class Metalog(LogReader):
|
|||
if unixTime < time.time()-self.findTime:
|
||||
continue
|
||||
if self.inIgnoreIPList(ip):
|
||||
if self.verbose:
|
||||
print 'Ignore', ip
|
||||
self.logSys.debug("Ignore "+ip)
|
||||
continue
|
||||
if self.verbose:
|
||||
print 'Found', ip, 'at', unixTime
|
||||
self.logSys.debug("Found "+ip)
|
||||
if ipList.has_key(ip):
|
||||
ipList[ip] = (ipList[ip][0]+1, unixTime)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue