Skip to content

do8pgg/FritzBox-monitor

 
 

Repository files navigation

MIT license PRs Welcome made-with-python Python application

FritzBox-monitor

Monitor FritzBox metrics via a telegraf/influxdb/grafana stack that reads data from TR-064

What you get....

Grafana dashboard

  • Includes current DSL rates, possible line rates (over time)
  • Traffic on DSL line and LAN port (seems to only register LAN1 in TR-064)
  • Packets per second on WLAN, LAN and DSL
  • Clients associated in WLAN2.4 / WLAN 5 & WLAN guest
  • DECT clients, active VOIP numbers

Details

  • I decided that I want to parse the Fritzbox info via a single telegraf input.
  • Consequently, the checkfritz.py returns a json which can be easily disgested as array

Background

I have a FritzBox 7490 at home, which is connected to a vDSL 100/40 line - I was wondering regarding my traffic patterns, as well as things like connected WiFi clients, DSL line capacity and so on.

My use case

The special thing to mention is:

  • TR-064 is only accessible from the LAN (for good reasons, in terms of security)
  • My monitoring stack of influxDB etc runs on my server in Frankfurt - so the metrics need to get there safely and securely.
  • Another open port on my server, e.g. for InfluxDB etc was not deemed acceptable
  • For security considerations, I prefer a "direct pull" of metrics, e.g. by telegraf
  • So, the actual monitoring collector needs from a decoy host in the LAN, namely my diskstation or one of the raspis
  • I did not want to run an ssh command for every value
  • LAN hosts can be securely / directly accessed by IPv6, and thanks to DNS updates, also carry AAAA entries.

References

I started looking around, and found a good number of projects and descriptions, on how to do it...

All of those needed quite some extra work, or did not fit my use case directly... FritzBoxShell did not completely fetch all the information available, as described by https://avm.de/service/schnittstellen/, and the scripts provided with fritzconnection did need modification as well, the collectd plugin (based on FritzConnection) requires an collectd somewhere in LAN - and an accessible sink.

Installation

Pre-requisites

FritzBox

Diskstation extras

  • Have a Python 3 installation (install Python package) and fritzconnection running (this is quite a task):
    • Install opkg as your package manager, probably best via EasyBootstrapInstaller (see: https://community.synology.com/enu/forum/1/post/127148 )
    • Have "python3-pip" and "python3-lxml" (to tackle the TR-064 SOAP) ready and installed (either installed via opkg, or via pip-bootstrap - have fun getting lxml running on the diskstation without opkg... as the headers are missing)
    • Make sure you have the fritzconnection module: pip install fritzconnections
  • Create a monitoring user via web-ui, have this one be an admin user (otherwise ssh-login does not work)
  • Add your monitoring servers telegraf ssh key to ~monitoring/.ssh/authorized_keys

Monitoring server (in the internet)

  • Have a recent telegraf installation running
  • Have the local output configured, e.g. [[outputs.influxdb]]
  • Have grafana ready, to be able to read from said output
  • Configure telegraf to be able to ssh out with key-auth
    • Create an ssh-key for ~telegraf , probably in /etc/telegraf/.ssh/id_rsa without passphrase, so it can be called from telegraf directly.
    • Check whether telegraf can log in to your diskstation (in the LAN) via keyauth

Actual installation

  • Copy checkfritz.py to your decoy host
    • Adjust credentials
    • Check it is executable & works: Log in to decoy host as the user, and ./checkfritz.py
  • Integrate telegraf-fritzbox.conf into server grafana installation
    • Test the config: telegraf --filter inputs.exec --test
    • Restart grafana, and start collecting data
  • Add grafana-fritzbox-dashboard.json to your server grafana installation

About

Monitor FritzBox metrics via a telegraf/influxdb/grafana stack that reads data from TR-064

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%