Exports statistics from FritzBox to Prometheus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
marcel b2de356334 First commit 2 years ago
LICENSE Initial commit 2 years ago
README.md First commit 2 years ago
config.yml First commit 2 years ago
fritz-api.sh First commit 2 years ago
fritzbox_exporter.py First commit 2 years ago

README.md

fritzbox_exporter

Collects data from FRITZ!Box via its SOAP api and exports it to Prometheus via http.

The program is split up into two parts:

Bash script

Collects various information from your FRITZ!Box via its SOAP api. It outputs the data to stdout in JSON format.

It can also be used from the command line. Script can output:

  • link uptime
  • connection status
  • maximum upstream sync speed on current connection
  • maximum downstream sync speed on current connection
  • Current downstream bandwidth usage
  • Current upstream bandwidth usage
  • Total download usage on current connection
  • Total upload usage on current connection

This bash script is taken from https://github.com/mrwhale/fritzbox-api

Requirement

The Universal Plug & Play (UPnP) service must be enabled.

You can do that in the settings: Home Network » Network » Network Settings

Enable "Transmit status information over UPnP"

Usage

usage: fritz-api.sh [-f <function>] [-h hostname] [-b rate] [-j] [-d]
  -f: function to be executed [Default: bandwidthdown]
  -h: hostname or IP of the FRITZ!Box [Default: fritz.box]
  -b: rate to display. b, k, m. all in  bytes
  -j: JSON output
      Does not accept any functions.
      Will display all output in JSON format.
      Useful for running in cron and ingesting into another program
  -d: enable debug output

functions:
  linkuptime     connection time in seconds
  connection     connection status
  downstream     maximum downstream on current connection (Downstream Sync)
  upstream       maximum upstream on current connection (Upstream Sync)
  bandwidthdown  current bandwidth down
  bandwidthup    current bandwidth up
  totalbwdown    total downloads
  totalbwup      total uploads

Example: fritz-api.sh -f downstream -h 192.168.100.1 -b m

Dependancies

  • curl
  • bc

Python program

This is the actual exporter. It takes the output from the bash script, processes it and exposes it via http (default port 9000) to Prometheus.

Usage

Configure prometheus.yml:

- job_name: 'FritzBox'

static_configs:
- targets: ['localhost:9001']

Start program as background process:

python3 ./fritzbox_exporter.py &

Use Graphana to display the data.

Configuration

It can be configured via the file config.yml.

# Set port (default: 9000)
port: 9001
# Set scrape frequency (default: 15 seconds)
scrape_frequency: 60

Dependancies

  • Python 3
  • subprocess
  • json
  • pyyaml
  • prometheus_client