- 1. 概要
- 2. 操作
- 3. 参考サイト
1. 概要
フィルタが有効かチェックするプログラムがあるようです。
特に自前のフィルタを作成したときには、実行してチェックしておきたい。
「fail2ban-regex」というプログラムのようです。
2. 操作
これは、チェックのみのためか、ログインユーザでも実行可能なようです。
fail2ban-regex /var/log/path/filename.log filter-name
新たに作成した、フィルタファイルがある場合は。
fail2ban-regex /var/log/path/filename.log /usr/local/etc/fail2ban/filter.d/filter-name.local
わたしの環境で実行してみました。
fail2ban-regex /var/log/mail/maillog postfix-sasl
Running tests
=============
Use jail : postfix-sasl
Use datepattern : {^LN-BEG} : Default Detectors
Use log file : /var/log/mail/maillog
Use encoding : UTF-8
Results
=======
Prefregex: 14047 total
| ^(?:\[\])?\s*(?:<[^.]+\.[^.]+>\s+)?(?:\S+\s+)?(?:kernel:\s?\[ *\d+\.\d+\]:?\s+)?(?:@vserver_\S+\s+)?(?:(?:(?:\[\d+\])?:\s+[\[\(]?postfix(-\w+)?/[^/\[:\s]+(?:/smtp[ds])?(?:\(\S+\))?[\]\)]?:?|[\[\(]?postfix(-\w+)?/[^/\[:\s]+(?:/smtp[ds])?(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:?)\s+)?(?:\[ID \d+ \S+\]\s+)?warning: (?P<content>.+)$
'-
Failregex: 3425 total
|- #) [# of hits] regular expression
| 1) [3425] ^[^[]*\[<HOST>\](?::\d+)?: SASL ((?i)LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed:(?! Connection lost to authentication server| Invalid authentication mechanism)
'-
Ignoreregex: 0 total
Date template hits:
|- [# of hits] date format
| [43921] {^LN-BEG}(?:DAY )?MON Day %k:Minute:Second(?:\.Microseconds)?(?: ExYear)?
'-
Lines: 43921 lines, 0 ignored, 3425 matched, 40496 missed
[processed in 3.11 sec]
Missed line(s): too many to print. Use --print-all-missed to print all 40496 lines
これは、「Lines: 43921」行あるログのうち、「3425 matched」3425件がヒットしたということになります。
3. 参考サイト
本ページは、「Gemini」伍長を参考にさせていただきました。
|
|