A wrapper for fail2ban-client
go gather
fail2ban metrics and export
them for Prometheus.
For each enabled fail2ban jail, the following metrics will be exposed:
fail2ban_<jail>_banned_total
fail2ban_<jail>_failed_total
fail2ban_<jail>_banned
fail2ban_<jail>_failed
- fail2ban
- Python 3
Run install.sh
and fail2ban_exporter will be installed as a Systemd service.
$ fail2ban_exporter --help
usage: fail2ban_exporter [-h] [-a ADDR] [-p PORT] [-d] [-i IGNORED_JAILS]
optional arguments:
-h, --help show this help message and exit
-a ADDR, --addr ADDR Listen on this address
-p PORT, --port PORT Listen on this port
-d, --debug Debug mode
-i IGNORED_JAILS, --ignore-jail IGNORED_JAILS
Ignore a jail. This argument can appear many times.
LISTEN_ADDRESS
. Default:0.0.0.0
LISTEN_PORT
. Default:9180
EXEC_PATH
. Default:/usr/bin/
Install Tox:
$ sudo apt update
$ sudo apt install tox
Run Tox tasks for a given Python environment:
$ tox -e py39
Run Tox tasks for a given Python environment and force its (re)creation:
$ tox -e py39 -r
Create and activate a Python virtualenv:
$ python3 -m venv ~/.local/share/virtualenvs/fail2ban_exporter
$ source ~/.local/share/virtualenvs/fail2ban_exporter/bin/activate
Install fail2ban_exporter
in development mode; this will create a symlink to
the local development workspace:
$ python setup.py develop
Install lint and test dependencies:
$ pip install -r requirements_tests.txt
Run linters:
$ black --check --diff
$ pytest --pylint
Run unitary tests and show code coverage:
$ pytest --cov=fail2ban_exporter