commit
392c80eb1b
13
.dockerignore
Normal file
13
.dockerignore
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.git
|
||||||
|
.github
|
||||||
|
extra
|
||||||
|
_config.yml
|
||||||
|
.dockerignore
|
||||||
|
.gitignore
|
||||||
|
Dockerfile
|
||||||
|
example.json
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
|
/target
|
||||||
|
**/*.rs.bk
|
||||||
|
*.vim
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
ARG ALPINE_VERSION=3.12
|
||||||
|
ARG RUST_VERSION=1-alpine${ALPINE_VERSION}
|
||||||
|
|
||||||
|
FROM rust:${RUST_VERSION} AS build
|
||||||
|
WORKDIR /usr/src/prometheus_wireguard_exporter
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
ARG ARCH=x86_64
|
||||||
|
RUN apk add --update -q --no-cache musl-dev
|
||||||
|
RUN rustup target add ${ARCH}-unknown-linux-musl
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
RUN mkdir src && \
|
||||||
|
echo "fn main() {}" > src/main.rs
|
||||||
|
RUN cargo build --release && \
|
||||||
|
rm -rf target/release/deps/prometheus_wireguard_exporter*
|
||||||
|
|
||||||
|
# Build the musl linked binary
|
||||||
|
COPY . .
|
||||||
|
RUN cargo build --release
|
||||||
|
RUN cargo install --target ${ARCH}-unknown-linux-musl --path .
|
||||||
|
|
||||||
|
FROM alpine:${ALPINE_VERSION}
|
||||||
|
EXPOSE 9586/tcp
|
||||||
|
RUN apk add --update -q --no-cache wireguard-tools-wg
|
||||||
|
COPY --from=build /usr/local/cargo/bin/prometheus_wireguard_exporter /usr/local/bin/prometheus_wireguard_exporter
|
||||||
|
ENTRYPOINT [ "prometheus_wireguard_exporter" ]
|
@ -29,6 +29,15 @@ A Prometheus exporter for [WireGuard](https://www.wireguard.com), written in Rus
|
|||||||
* You need [Rust](https://www.rust-lang.org/) to compile this code. Simply follow the instructions on Rust's website to install the toolchain. If you get weird errors while compiling please try and update your Rust version first (I have developed it on `rustc 1.42.0 (b8cedc004 2020-03-09)`).
|
* You need [Rust](https://www.rust-lang.org/) to compile this code. Simply follow the instructions on Rust's website to install the toolchain. If you get weird errors while compiling please try and update your Rust version first (I have developed it on `rustc 1.42.0 (b8cedc004 2020-03-09)`).
|
||||||
* You need [WireGuard](https://www.wireguard.com) *and* the `wg` CLI in the path. The tool will call `wg show <interface(s)>|all dump` and of course will fail if the `wg` executable is not found. If you want I can add the option of specifying the `wg` path in the command line, just open an issue for it.
|
* You need [WireGuard](https://www.wireguard.com) *and* the `wg` CLI in the path. The tool will call `wg show <interface(s)>|all dump` and of course will fail if the `wg` executable is not found. If you want I can add the option of specifying the `wg` path in the command line, just open an issue for it.
|
||||||
|
|
||||||
|
Alternatively, as long as you have Wireguard on your host kernel with some Wireguard interfaces running, you can use Docker. For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build -t prometheusWireguardExporter https://github.com/mindflavor/prometheus_wireguard_exporter
|
||||||
|
docker run -it --rm --init --net=host --cap-add=NET_ADMIN prometheusWireguardExporter
|
||||||
|
# Check it's up
|
||||||
|
docker run -it --rm alpine:3.12 wget -qO- http://localhost:9586/metrics
|
||||||
|
```
|
||||||
|
|
||||||
## Compilation
|
## Compilation
|
||||||
|
|
||||||
To compile the latest master version:
|
To compile the latest master version:
|
||||||
|
Loading…
Reference in New Issue
Block a user