I made it possible to publicly output and check fail2ban reports on a weekly basis

3 min

language: ja bn en es hi pt ru zh-cn zh-tw

Fail2ban Reports

image

It is output like this.

fail2ban-report

GitHub - haturatu/f2b-report: f2b-report reads fail2ban-client status <jail> output from stdin and writes a simple HTML report to stdout. · GitHub

I have published it above.
In terms of demand, it's quite niche.

Automation

It converts the output of fail2ban-client status <jail> received from standard input into a simple HTML format.
Additionally, this output process is fully automated. In my case, since I have two server machines acting as cache servers, I need to synchronize the output.

This is because otherwise, the HTML file might only exist on one of the Nginx servers.

The mechanism works as follows:

Create a git repository containing the synchronization shell script, static files, and HTML.

git pull to synchronize the repository

Get rule names from fail2ban-client status

Pipe fail2ban-client statsu <jail> for existing rules into f2b-report to generate HTML files

Generate index.html from the *.html files in the current directory

Copy to the f2b-report directory under /usr/local/www/

Run git commit && git push

Just set this up in cron and you're done.
Also, the name passed as the first argument to this shell script is used as a prefix to generate the html file.

As for environment variables, I execute it by passing the path to the f2b-report executable and the destination copy path together.

Related Posts