fail2ban是否继续监视旋转的日志文件?
例如,我有一个规则监视/var/log/fail2ban.log,它每周(7天)由系统自动旋转。我想有一个规则,监测被禁止的I在日志中,以寻找重复的罪犯,谁已经被禁止了5次在过去10天。这有可能吗?
发布于 2013-03-21 18:32:35
是的,fail2ban继续监视旋转的日志文件。来自server/filter.py
439 ##
440 # FileContainer class.
441 #
442 # This class manages a file handler and takes care of log rotation detection.
443 # In order to detect log rotation, the hash (MD5) of the first line of the file
444 # is computed and compared to the previous hash of this line.
发布于 2017-03-10 14:18:48
可以通过两种方式(或组合)中的一种指定多个日志。您可以使用文件全局(通配符)来匹配要监视的日志文件(即logpath = /var/log/*somefile.log
)或用空格(空格、制表符、换行符)分隔的日志文件列表,例如
logpath = /var/log/auth.log /var/log/auth.log.1
或
logpath = /var/log/auth.log
/var/log/auth.log.1
发布于 2015-12-04 17:02:17
以上接受的答案对于你的问题是不正确的。FileContainer只使用文件日志旋转检测将日志读取重置为文件的开始,而不使用从上次偏移量继续的标准过程:
class FileContainer:
...
def open(self):
self.__handler = open(self.__filename, 'rb')
...
# Compare hash and inode
if self.__hash != myHash or self.__ino != stats.st_ino:
logSys.info("Log rotation detected for %s" % self.__filename)
self.__hash = myHash
self.__ino = stats.st_ino
self.__pos = 0
# Sets the file pointer to the last position.
self.__handler.seek(self.__pos)
在那里没有代码去寻找旋转的文件也解析通过。
https://serverfault.com/questions/490138
复制相似问题