# fritzbox_exporter (C)2022 M. Konstapel https://www.meezenest.nl/mees 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 a FRITZ!Box via its SOAP api. It outputs the data to stdout in JSON format. It can also be used from the command line to get the following data: - 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 ```text usage: fritz-api.sh [-f ] [-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 ``` ### Dependencies - 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: ```text - job_name: 'FritzBox' static_configs: - targets: ['localhost:9001'] ``` Start program as background process: ```text python3 ./fritzbox_exporter.py & ``` Use Graphana to display the data. ### Configuration It can be configured via the file config.yml. ```text # Set port (default: 9000) port: 9001 # Set scrape frequency (default: 15 seconds) scrape_frequency: 60 ``` ### Dependencies - Python 3 - subprocess - json - pyyaml - prometheus_client