首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >fail2ban是否监视旋转的日志文件?

fail2ban是否监视旋转的日志文件?
EN

Server Fault用户
提问于 2013-03-21 16:38:15
回答 3查看 5.7K关注 0票数 11

fail2ban是否继续监视旋转的日志文件?

例如,我有一个规则监视/var/log/fail2ban.log,它每周(7天)由系统自动旋转。我想有一个规则,监测被禁止的I在日志中,以寻找重复的罪犯,谁已经被禁止了5次在过去10天。这有可能吗?

EN

回答 3

Server Fault用户

回答已采纳

发布于 2013-03-21 18:32:35

是的,fail2ban继续监视旋转的日志文件。来自server/filter.py

代码语言:javascript
运行
复制
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.
票数 1
EN

Server Fault用户

发布于 2017-03-10 14:18:48

可以通过两种方式(或组合)中的一种指定多个日志。您可以使用文件全局(通配符)来匹配要监视的日志文件(即logpath = /var/log/*somefile.log)或用空格(空格、制表符、换行符)分隔的日志文件列表,例如

代码语言:javascript
运行
复制
    logpath = /var/log/auth.log /var/log/auth.log.1

代码语言:javascript
运行
复制
    logpath = /var/log/auth.log
              /var/log/auth.log.1
票数 7
EN

Server Fault用户

发布于 2015-12-04 17:02:17

以上接受的答案对于你的问题是不正确的。FileContainer只使用文件日志旋转检测将日志读取重置为文件的开始,而不使用从上次偏移量继续的标准过程:

代码语言:javascript
运行
复制
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)

在那里没有代码去寻找旋转的文件也解析通过。

票数 5
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/490138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档