Browse Source

Merge 709549c26e into 4d5b0d2095

pull/5/merge
Lukas Wolfsteiner 4 years ago
committed by GitHub
parent
commit
c81ac044b2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      Dockerfile
  2. 33
      README.md
  3. 21
      docker-compose.yml
  4. 75
      k8s-fritzbox.yaml

14
Dockerfile

@ -0,0 +1,14 @@
FROM golang:rc-alpine3.13 AS builder
RUN go get github.com/sberk42/fritzbox_exporter/
FROM alpine:latest
ENV USERNAME username
ENV PASSWORD password
ENV GATEWAY_URL http://fritz.box:49000
ENV LISTEN_ADDRESS 0.0.0.0:9042
WORKDIR /root/
COPY --from=builder /go/bin/fritzbox_exporter .
COPY metrics.json metrics-lua.json ./
EXPOSE 9042
ENTRYPOINT [ "./fritzbox_exporter" ]
CMD ./fritzbox_exporter -username $USERNAME -password $PASSWORD -gateway-url ${GATEWAY_URL} -listen-address ${LISTEN_ADDRESS}

33
README.md

@ -35,6 +35,39 @@ Other changes:
In the configuration of the Fritzbox the option "Statusinformationen über UPnP übertragen" in the dialog "Heimnetz > In the configuration of the Fritzbox the option "Statusinformationen über UPnP übertragen" in the dialog "Heimnetz >
Heimnetzübersicht > Netzwerkeinstellungen" has to be enabled. Heimnetzübersicht > Netzwerkeinstellungen" has to be enabled.
### Using docker
First you have to build the container: `docker build --tag fritzbox-prometheus-exporter:latest .`
Then start the container:
```bash
$ docker run -e 'USERNAME=your_fritzbox_username' \
-e 'PASSWORD=your_fritzbox_password' \
-e 'GATEWAY_URL="http://192.168.0.1:49000"' \
-e 'LISTEN_ADDRESS="0.0.0.0:9042"' \
fritzbox-prometheus-exporter:latest
```
I've you're getting `no such host` issues, define your FritzBox as DNS server for your docker container like this:
```bash
$ docker run --dns YOUR_FRITZBOX_IP \
-e 'USERNAME=your_fritzbox_username' \
-e 'PASSWORD=your_fritzbox_password' \
-e 'GATEWAY_URL="http://192.168.0.1:49000"' \
-e 'LISTEN_ADDRESS="0.0.0.0:9042"' \
fritzbox-prometheus-exporter:latest
```
### Using docker-compose
Set your environment variables within the [docker-compose.yml](docker-compose.yml) file.
Then start up the container using `docker-compose up -d`.
### Using the binary
Usage: Usage:
$GOPATH/bin/fritzbox_exporter -h $GOPATH/bin/fritzbox_exporter -h

21
docker-compose.yml

@ -0,0 +1,21 @@
version: '3'
services:
fritzbox-prometheus-exporter:
hostname: fritzbox-prometheus-exporter
build:
context: .
dockerfile: Dockerfile
container_name: fritzbox-prometheus-exporter
# for dns issues like "dial tcp: lookup fritz.box on 127.0.0.11:53: no such host"
# uncomment and fill the following line:
# dns: YOUR_FRITZBOX_IP
ports:
- "9042:9042"
#expose:
# - "9042"
restart: unless-stopped
environment:
USERNAME: your_fritzbox_username
PASSWORD: your_fritzbox_password
GATEWAY_URL: http://192.168.0.1:49000
LISTEN_ADDRESS: 0.0.0.0:9042

75
k8s-fritzbox.yaml

@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: fritzbox-exporter
name: fritzbox-exporter
namespace: metrics-app
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: fritzbox-exporter
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: fritzbox-exporter
name: fritzbox-exporter
spec:
containers:
- env:
- name: GWURL
value: 'http://ip-fritzbox:49000'
- name: USERNAME
value: 'username'
- name: PASSWORD
value: 'password'
image: alexxanddr/fritzbox-exporter:latest
imagePullPolicy: Always
name: fritzbox-exporter
resources: {}
securityContext:
privileged: false
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
hostAliases:
- hostnames:
- fritz.box
ip: 'ip-fritzbox'
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/path: /metrics
prometheus.io/port: "9042"
prometheus.io/scrape: "true"
labels:
app: fritzbox-exporter
name: fritzbox-exporter
namespace: metrics-app
spec:
clusterIP:
ports:
- name: tcp
port: 9042
protocol: TCP
targetPort: 9042
selector:
app: fritzbox-exporter
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
Loading…
Cancel
Save