fail2ban监视器是否旋转了日志文件?

fail2ban是否继续监视轮换的日志文件?

例如,我有一个规则监控/var/log/fail2ban.log,系统每周(7天)自动轮换。 我想有一个规则,监视该日志中的被禁止的IP地址,以找出在过去10天内被禁止5次的重犯。 那可能吗?

是的,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. 

可以用两种方法之一(或组合)指定多个日志。 您可以使用文件globs(通配符)来匹配要监视的日志文件(例如, 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 

以上答案在你的问题上是不正确的。 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) 

那里没有代码在寻找旋转的文件也parsing。