update readme with new -h output & update dockerfile

This commit is contained in:
Hector 2022-01-30 19:01:42 +00:00
parent 315ecf4271
commit 94db2ec3de
3 changed files with 30 additions and 31 deletions

View File

@ -38,23 +38,22 @@ See the [releases page](https://gitlab.com/hectorjsmith/fail2ban-prometheus-expo
**Usage** **Usage**
``` ```
$ fail2ban-prometheus-exporter -h $ fail2ban-prometheus-exporter -h
usage: exporter [<flags>]
-collector.textfile Flags:
enable the textfile collector -h, --help Show context-sensitive help (also try --help-long and --help-man).
-collector.textfile.directory string --version show version info and exit
directory to read text files with metrics from --port=9191 port to use for the metrics server
-port int --web.listen-address="0.0.0.0"
port to use for the metrics server (default 9191) address to use for the metrics server
-socket string --socket="" path to the fail2ban server socket
path to the fail2ban server socket --collector.textfile enable the textfile collector
-version --collector.textfile.directory=""
show version info and exit directory to read text files with metrics from
-web.basic-auth.password string --web.basic-auth.username=""
password to use to protect endpoints with basic auth username to use to protect endpoints with basic auth
-web.basic-auth.username string --web.basic-auth.password=""
username to use to protect endpoints with basic auth password to use to protect endpoints with basic auth
-web.listen-address string
address to use for the metrics server (default "0.0.0.0")
``` ```
**Example** **Example**

View File

@ -15,6 +15,6 @@ fi
# Start the exporter (use exec to support graceful shutdown) # Start the exporter (use exec to support graceful shutdown)
# Inspired by: https://akomljen.com/stopping-docker-containers-gracefully/ # Inspired by: https://akomljen.com/stopping-docker-containers-gracefully/
exec /app/fail2ban-prometheus-exporter \ exec /app/fail2ban-prometheus-exporter \
-socket "$socket_path" \ --socket "$socket_path" \
-collector.textfile=$textfile_enabled \ --collector.textfile=$textfile_enabled \
-collector.textfile.directory="$textfile_dir" --collector.textfile.directory="$textfile_dir"

View File

@ -10,11 +10,11 @@ import (
const ( const (
minServerPort = 1000 minServerPort = 1000
maxServerPort = 65535 maxServerPort = 65535
portEnvName = "F2B_WEB_PORT"
addressEnvName = "F2B_WEB_LISTEN_ADDRESS"
socketEnvName = "F2B_COLLECTOR_SOCKET" socketEnvName = "F2B_COLLECTOR_SOCKET"
fileCollectorEnabledEnvName = "F2B_COLLECTOR_TEXT" fileCollectorEnabledEnvName = "F2B_COLLECTOR_TEXT"
fileCollectorPathEnvName = "F2B_COLLECTOR_TEXT_PATH" fileCollectorPathEnvName = "F2B_COLLECTOR_TEXT_PATH"
portEnvName = "F2B_WEB_PORT"
addressEnvName = "F2B_WEB_LISTEN_ADDRESS"
basicAuthUserEnvName = "F2B_WEB_BASICAUTH_USER" basicAuthUserEnvName = "F2B_WEB_BASICAUTH_USER"
basicAuthPassEnvName = "F2B_WEB_BASICAUTH_PASS" basicAuthPassEnvName = "F2B_WEB_BASICAUTH_PASS"
) )
@ -45,16 +45,6 @@ func readParamsFromCli(settings *AppSettings) {
Flag("version", "show version info and exit"). Flag("version", "show version info and exit").
Default("false"). Default("false").
Bool() Bool()
port := kingpin.
Flag("port", "port to use for the metrics server").
Default("9191").
Envar(portEnvName).
Int()
address := kingpin.
Flag("web.listen-address", "address to use for the metrics server").
Default("0.0.0.0").
Envar(addressEnvName).
String()
socketPath := kingpin. socketPath := kingpin.
Flag("socket", "path to the fail2ban server socket"). Flag("socket", "path to the fail2ban server socket").
Default(""). Default("").
@ -70,6 +60,16 @@ func readParamsFromCli(settings *AppSettings) {
Default(""). Default("").
Envar(fileCollectorPathEnvName). Envar(fileCollectorPathEnvName).
String() String()
port := kingpin.
Flag("port", "port to use for the metrics server").
Default("9191").
Envar(portEnvName).
Int()
address := kingpin.
Flag("web.listen-address", "address to use for the metrics server").
Default("0.0.0.0").
Envar(addressEnvName).
String()
rawBasicAuthUsername := kingpin. rawBasicAuthUsername := kingpin.
Flag("web.basic-auth.username", "username to use to protect endpoints with basic auth"). Flag("web.basic-auth.username", "username to use to protect endpoints with basic auth").
Default(""). Default("").