7 files changed
+69
-62
No files matched your search
@@ -1,2 +1,3 @@
|
||||
openvpn_exporter
|
||||
.idea
|
||||
dist
|
||||
@@ -0,0 +1,21 @@
|
||||
# This is an example goreleaser.yaml file with some sane defaults.
|
||||
# Make sure to check the documentation at http://goreleaser.com
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goarch:
|
||||
- amd64
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
dockers:
|
||||
- image_templates:
|
||||
- "kumina/openvpn_exporter:latest"
|
||||
- "kumina/openvpn_exporter:{{ .Tag }}"
|
||||
build_flag_templates:
|
||||
- "--label=org.label-schema.schema-version=1.0"
|
||||
- "--label=org.label-schema.version={{ .Version }}"
|
||||
- "--label=org.label-schema.name={{ .ProjectName }}"
|
||||
+4
-42
@@ -1,42 +1,4 @@
|
||||
# BUILD:
|
||||
# docker build --force-rm=true -t openvpn_exporter .
|
||||
|
||||
# RUN:
|
||||
# docker run -it -p 9176:9176 -v /path/to/openvpn_server.status:/etc/openvpn_exporter/server.status openvpn_exporter
|
||||
|
||||
FROM golang as builder
|
||||
|
||||
RUN mkdir /app
|
||||
RUN mkdir /go/src/app
|
||||
ADD . /go/src/app
|
||||
WORKDIR /go/src/app
|
||||
|
||||
# Go dep
|
||||
RUN go get -d ./...
|
||||
|
||||
# Build a standalone binary
|
||||
RUN set -ex && \
|
||||
CGO_ENABLED=0 go build \
|
||||
-tags netgo \
|
||||
-o /app/openvpn_exporter \
|
||||
-v -a \
|
||||
-ldflags '-extldflags "-static"' && \
|
||||
ls
|
||||
|
||||
# Create the second stage with a basic image.
|
||||
# this will drop any previous
|
||||
# stages (defined as `FROM <some_image> as <some_name>`)
|
||||
# allowing us to start with a fat build image and end up with
|
||||
# a very small runtime image.
|
||||
|
||||
FROM busybox
|
||||
|
||||
# add compiled binary
|
||||
COPY --from=builder /app/openvpn_exporter /openvpn_exporter
|
||||
|
||||
# add a default file to be processed
|
||||
ADD examples/server2.status /etc/openvpn_exporter/server.status
|
||||
|
||||
# run
|
||||
EXPOSE 9176
|
||||
CMD ["/openvpn_exporter", "-openvpn.status_paths", "/etc/openvpn_exporter/server.status"]
|
||||
FROM scratch
|
||||
COPY openvpn_exporter /bin/openvpn_exporter
|
||||
ENTRYPOINT ["/bin/openvpn_exporter"]
|
||||
CMD [ "-h" ]
|
||||
@@ -56,7 +56,8 @@ openvpn_server_connected_clients 1
|
||||
## Usage
|
||||
|
||||
Usage of openvpn_exporter:
|
||||
```
|
||||
|
||||
```sh
|
||||
-openvpn.status_paths string
|
||||
Paths at which OpenVPN places its status files. (default "examples/client.status,examples/server2.status,examples/server3.status")
|
||||
-web.listen-address string
|
||||
@@ -66,33 +67,24 @@ Usage of openvpn_exporter:
|
||||
```
|
||||
|
||||
E.g:
|
||||
```
|
||||
|
||||
```sh
|
||||
openvpn_exporter -openvpn.status_paths /etc/openvpn/openvpn-status.log
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
Build the image:
|
||||
```
|
||||
docker build --force-rm=true -t openvpn_exporter .
|
||||
```
|
||||
|
||||
The final image is around 8MB. A temporary image has been downloaded(Golang) to make the final one. Once built, this temporary image become orphan, you can delete it:
|
||||
```
|
||||
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")
|
||||
```
|
||||
|
||||
To use with docker you must mount your status file to `/etc/openvpn_exporter/server.status`.
|
||||
```
|
||||
docker run -it -p 9176:9176 -v /path/to/openvpn_server.status:/etc/openvpn_exporter/server.status openvpn_exporter
|
||||
|
||||
```sh
|
||||
docker run -p 9176:9176 \
|
||||
-v /path/to/openvpn_server.status:/etc/openvpn_exporter/server.status \
|
||||
kumina:openvpn_exporter -openvpn.status_paths /etc/openvpn_exporter/server.status
|
||||
```
|
||||
|
||||
Metrics should be available on your host IP: http://<host_ip>:9176/metrics. E.g: http://10.39.9.94:9176/metrics
|
||||
|
||||
Metrics should be available at http://localhost:9176/metrics.
|
||||
|
||||
## Get a standalone executable binary
|
||||
|
||||
Use the docker image to copy the built binary into a mounted volume
|
||||
```bash
|
||||
docker run -it -v /local/empty/folder:/volume openvpn_exporter cp openvpn_exporter /volume
|
||||
```
|
||||
You can download the pre-compiled binaries from the
|
||||
[releases page](https://github.com/kumina/openvpn_exporter/releases).
|
||||
@@ -0,0 +1,13 @@
|
||||
module github.com/kumina/openvpn_exporter
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
|
||||
github.com/gogo/protobuf v1.1.1 // indirect
|
||||
github.com/golang/protobuf v1.2.0 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/prometheus/client_golang v0.9.1
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
|
||||
github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39 // indirect
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/prometheus/client_golang v0.9.1 h1:K47Rk0v/fkEfwfQet2KWhscE0cJzjgCCDBG2KHZoVno=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39 h1:Cto4X6SVMWRPBkJ/3YHn1iDGDGc/Z+sW+AEMKHMVvN4=
|
||||
github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d h1:GoAlyOgbOEIFdaDqxJVlbOQ1DtGmZWs/Qau0hIlk+WQ=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
File renamed without changes.
Reference in new issue
Block a user