Open andrewlow opened 2 years ago
Just bumped into this. Seems to be related to a recent change that was not reflected in the docker image: https://github.com/MindFlavor/prometheus_wireguard_exporter/blob/master/README.md?plain=1#L110
The README.md change is this PR https://github.com/MindFlavor/prometheus_wireguard_exporter/pull/93
However, that is only the comment / documentation fix to address a previous change in behaviour. I think that this was back in this PR https://github.com/MindFlavor/prometheus_wireguard_exporter/pull/83
It was documented as a breaking change as well. The specific change that impacted the use of -a
appears to be here: https://github.com/MindFlavor/prometheus_wireguard_exporter/blame/72d3f7393e166fb3846c1b1cf2d50ff8dbea71d6/src/main.rs#L153
.arg(
Arg::with_name("prepend_sudo")
.short("a")
.long("prepend_sudo")
.env("PROMETHEUS_WIREGUARD_EXPORTER_PREPEND_SUDO_ENABLED")
.help("Prepend sudo to the wg show commands")
.default_value("false")
.takes_value(true),
The use of .takes_value(true)
I believe means that this command line argument MUST have a value.
This appears to be the clap library - https://docs.rs/clap/2.33.0/clap/index.html
While I've written some Rust - I'm not an expert. There may be a way to recode this to permit an optional value vs. forcing the use of a value - but it seems clear from the doc that takes_value
puts things into the situation where a value must be supplied.
I'm having this same issue with trying to start a container.
@garbelini @kramrm
Just run the container with that argument like this:
docker run -d --net=host --cap-add=NET_ADMIN mindflavor/prometheus-wireguard-exporter -a true
How would I do this via a docker-compose? The following doesn't seem to work.
---
version: '3'
services:
wg_metrics:
image: mindflavor/prometheus-wireguard-exporter
container_name: wg_metrics
environment:
TZ: 'America/Los_Angeles'
EXPORT_LATEST_HANDSHAKE_DELAY: 'true'
PROMETHEUS_WIREGUARD_EXPORTER_CONFIG_FILE_NAMES: '/etc/wireguard/wg0.conf'
PROMETHEUS_WIREGUARD_EXPORTER_PREPEND_SUDO_ENABLED: 'true'
cap_add:
- NET_ADMIN
network_mode: host
Try this:
version: '3'
services:
wg_metrics:
image: mindflavor/prometheus-wireguard-exporter
container_name: wg_metrics
command: -a true
cap_add:
- NET_ADMIN
network_mode: host
Thanks @hatamiarash7 that works!
@MindFlavor Could the above be added to the readme as an example of using docker compose
, in addition to the docker run
?
While the workaround is useful (fixed it for me!), I still think it's a bug that it seems to ignore the environment variable and only work when a command is specified.
Previously reported in https://github.com/MindFlavor/prometheus_wireguard_exporter/issues/89
I suspect that was closed because the original issue was dealt with - but this same issue was called out.
The Dockerfile has this line https://github.com/MindFlavor/prometheus_wireguard_exporter/blob/master/Dockerfile#L133
Which appears to make
-a
the default command line. Unfortunately - the-a
command line is invalid - it requires a parameter which is exactly the error that is being shown.Reproduce this using
granted, that's not a useful invocation of the container - but it does show the problem.
Adding a command line option fixes this
Alternatively - any valid command line will fix this
I suspect all active installations are using some version of the command line flags .. so they don't run into this default behaviour
Should be easy to fix by modifying the Dockerfile