Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
cd8b71e
Merge pull request #13 from RenWal/master
ma4nn Oct 6, 2021
2966bf9
run pylint check also for pull requests
ma4nn Oct 6, 2021
0b879fb
improved code styles
ma4nn Oct 6, 2021
4fe0603
added unit test for connection uptime module, fixed code styles for c…
ma4nn Oct 8, 2021
fec1417
added unit test for dsl module
ma4nn Oct 8, 2021
9fd7fb6
added unit test for ecostat module
ma4nn Oct 8, 2021
bc296ff
added unit test for energy module
ma4nn Oct 8, 2021
975dbf1
added unit test for traffic module
ma4nn Oct 8, 2021
bb5c247
made unit test suite work and moved all tests into subdirectory
ma4nn Oct 8, 2021
669e814
Merge branch 'RenWal:master' into master
ma4nn Jan 30, 2023
a29ddf4
Merge pull request #14 from RenWal/master
ma4nn Sep 28, 2023
432b03f
improved some code styles
ma4nn Sep 28, 2023
e5d4b20
Merge remote-tracking branch 'origin/master'
ma4nn Sep 28, 2023
280f5d7
switched to pytest for test suite (much easier parametrization), adap…
ma4nn Sep 28, 2023
b3dc545
renamed test base class to contain test_ prefix in order for pytest t…
ma4nn Sep 28, 2023
a068d17
renamed github action a bit
ma4nn Sep 28, 2023
f797a7e
renamed camelCased files according to pylint
ma4nn Sep 28, 2023
8fcd80c
minor refactorings
ma4nn Sep 28, 2023
cf204c2
fixed error in github action
ma4nn Sep 28, 2023
1222579
added timeout to requests, minor code improvements
ma4nn Sep 28, 2023
6c74cca
refactored tests to use pytest output assertions, default certificate…
ma4nn Sep 29, 2023
d5a34c8
fixed typo in github actions
ma4nn Sep 29, 2023
3b0b4cd
removed old python version 3.9 (added only for testing reasons) in gi…
ma4nn Sep 29, 2023
53cf590
Create dependabot.yml
ma4nn Sep 29, 2023
d2ec6f9
replaced test base class by using pytest conftest.py, raised pylint m…
ma4nn Sep 29, 2023
9a1a4ab
renamed file to better reflect its purpose
ma4nn Sep 29, 2023
4690216
Merge remote-tracking branch 'origin/master'
ma4nn Sep 29, 2023
eefffdc
renamed file to better reflect its purpose, used MagicMock instead of…
ma4nn Sep 29, 2023
7821e34
implemented munin interface class and unified print_* methods
ma4nn Sep 29, 2023
4032300
unified main_handler
ma4nn Sep 29, 2023
943e735
some minor refactorings and content updates
ma4nn Sep 29, 2023
9e5b3c6
Update fritzbox_file_session.py
wvogel Dec 11, 2023
e9aaef5
Update and rename fritzbox_smart_home_temperature.py to fritzbox_smar…
wvogel Dec 11, 2023
d76642f
Update README.md
wvogel Dec 11, 2023
94c88f2
made scripts compatible with Python 3.9 (this is the default in Raspb…
ma4nn Dec 12, 2023
5373b85
improved code style a bit
ma4nn Dec 13, 2023
77ed926
Merge pull request #17 from ma4nn/python39_compatibility
ma4nn Dec 13, 2023
015eb20
Merge branch 'master' into wvogel/master
ma4nn Dec 13, 2023
46d4998
minor code refactoring to remove pylint warnings
ma4nn Dec 13, 2023
970ef63
added unit tests for smart home plugin
ma4nn Dec 13, 2023
87ebca6
Merge branch 'add_unit_tests_for_smart_home' into wvogel/master
ma4nn Dec 13, 2023
49401bf
updated unit tests
ma4nn Dec 13, 2023
1d4ff22
used new FritzHomeAutomation object
ma4nn Dec 14, 2023
5784643
Merge pull request #18 from ma4nn/add_unit_tests_for_smart_home
ma4nn Dec 14, 2023
1d42cff
Merge branch 'wvogel/master' into refactor_link_saturation
ma4nn Dec 14, 2023
43fc243
refactored link saturation module
ma4nn Dec 14, 2023
3068f97
added 7530ax as fixture and supported fritzbox model, started refacto…
ma4nn Jun 2, 2024
0f99ff1
added python 3.12 to github action, disabled tls by default to avoid …
ma4nn Jun 2, 2024
dd4386a
updated deprecated github actions
ma4nn Jun 2, 2024
59ed1cf
updated deprecated github actions
ma4nn Jun 2, 2024
5cd097d
minor readme update
ma4nn Aug 31, 2024
d31ef14
updated readme to include latest fritzos update
ma4nn Oct 23, 2024
f05ec64
added factory methods to simplify handling with Fritz* classes
ma4nn Jul 31, 2025
55f1d22
added python 3.13
ma4nn Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
23 changes: 0 additions & 23 deletions .github/workflows/pylint.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/verify-plugin-scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Verify Plugin Scripts

on: [push,workflow_dispatch,pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint --errors-only $(find src/ -name "*.py" | xargs)
- name: Running tests
run: |
pytest --cov
- name: Archive production artifacts
if: ${{ matrix.python-version == '3.12' }}
uses: actions/upload-artifact@v4
with:
name: fritzbox-munin-plugins
path: src/fritzbox*.py
8 changes: 5 additions & 3 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## fritzbox-munin-fast contributors
## fritzbox-munin-fast Contributors

Special thanks to all the people who had helped this project so far:

- Bob van de Vijver ([bobvandevijver](https://github.com/bobvandevijver))
- Framps ([framps](https://github.com/framps))
- Christian Stade-Schuldt
- Christian Stade-Schuldt ([Tafkas](https://github.com/Tafkas))
- Oliver Edelmann
- Rene Walendy ([RenWal](https://github.com/RenWal))
- Christoph Massmann ([christophmassmann](https://github.com/christophmassmann))
- Christoph Massmann ([ma4nn](https://github.com/ma4nn))
80 changes: 53 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
# Munin Plugins for FritzBox
# Munin Plugins for FRITZ!Box

A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a FRITZ!Box 7590 running FRITZ!OS 7.50 and a FRITZ!WLAN Repeater 1750E running FRITZ!OS 7.27.
![build status](https://github.com/ma4nn/fritzbox-munin-fast/actions/workflows/verify-plugin-scripts.yml/badge.svg)

If you are using the scripts on a different FRITZ!Box model please let me know by
A collection of [Munin](https://munin-monitoring.org) plugins to monitor your [AVM FRITZ!Box](https://avm.de/produkte/fritzbox/) router.
The values are retrieved via the [fritzconnection](https://pypi.org/project/fritzconnection/) project.

So far the following FRITZ!Box models have been confirmed working:

- opening an issue
- submitting a pull request
| Model | Fritz!OS Version(s) |
|------------------|---------------------|
| FritzBox 7590 | 7.28 - 7.57 |
| FritzBox 7530 AX | 7.80 - 8.02 |

If you are using the scripts on a different FRITZ!Box model please let me know by

These python scripts are [Munin](http://munin-monitoring.org) plugins for monitoring the [FRITZ!Box](https://avm.de/produkte/fritzbox/) router by AVM.
- Opening an issue
- Submitting a pull request

## Purpose of this Fork

The scripts are build upon the original [fritzbox-munin](https://github.com/Tafkas/fritzbox-munin) with the goal to make use of the modern APIs that FRITZ!OS 7 provides.
These scripts are build upon the original [fritzbox-munin](https://github.com/Tafkas/fritzbox-munin) with the goal to make
use of the more modern APIs that Fritz!OS 7 provides.

The main differences to the original version are:
- Compatibility with latest FRITZ!OS version using username/password authentication
- No HTML Scraping is used
- Compatibility with latest Fritz!OS version using username/password authentication
- No HTML scraping
- All data is fetched either through the TR-064 interface or the JSON API
- Contrary to the original version this fork uses multigraphs: this removes the need to query the same API endpoint multiple times, all multigraph plugins have configuration options to switch individual graphs on and off
- Support for Smart Home devices, e.g. for measuring temperature
- Complete refactoring of the Python code base to make it more robust, use modern language features like type hinting and reuse identical code
- Add possibility to connect to FRITZ!Box via TLS
- Complete refactoring of the Python code base to make it more robust, use modern language features like type hinting, tests and remove code duplication
- Added possibility to connect to FRITZ!Box via TLS
- Added automated testing via GitHub Actions

## Requirements
- FRITZ!Box router with FRITZ!OS >= 07.50 (if you are on an older FRITZ!OS version, select an older version of fritzbox-munin-fast by browsing the tags in this repository)
- FRITZ!Box router with FRITZ!OS >= 7.50 (if you are on an older FRITZ!OS version, select an older version of fritzbox-munin-fast by browsing the tags in this repository)
- Munin 1.4.0 or later is required
- Python 3.x
- Python >= 3.9

## Available Plugins

Expand All @@ -50,8 +61,14 @@ Multigraph plugin, showing:
- CPU load
- CPU temperature

### Smart Home Temperature
Plugin: `fritzbox_smart_home_temperature.py`
### Smart Home
Plugin: `fritzbox_smart_home.py`
Multigraph plugin, showing:
- temperature sensors
- switch states
- power values
- energy consumption values

![Smart Home Temperature](doc/smart_home_temperature.png)

### Energy
Expand All @@ -77,38 +94,39 @@ Multigraph plugin, showing for 2.4GHz and 5GHz

## Installation & Configuration

1. Pre-requisites for the `fritzbox_traffic` and `fritzbox_connection_uptime` plugins are the [fritzconnection](https://pypi.python.org/pypi/fritzconnection) and [requests](https://pypi.python.org/pypi/requests) package. To install run
1. To install requirements run

pip install -r requirements.txt

1. Make sure the FRITZ!Box has UPnP status information enabled. (web interface: _Home Network > Network > Network Settings > Universal Plug & Play (UPnP)_)
1. Make sure the FRITZ!Box has UPnP status information enabled. (web interface: _Home Network Network Network Settings Universal Plug & Play (UPnP)_)

1. Copy all the scripts from `src/` folder to `/usr/share/munin/plugins`
1. Copy all the scripts from the [published release](https://github.com/ma4nn/fritzbox-munin-fast/releases) to `/usr/share/munin/plugins`

1. (optional) If you want to connect to FRITZ!Box using SSL, download the Fritz certificate (web interface: _Internet > Freigaben > FritzBox Dienste > Zertifikat > Zertifikat herunterladen_) and save it to `/etc/munin/box.cer`.
1. (optional) If you want to connect to FRITZ!Box using SSL, download the Fritz certificate (web interface: _Internet → Freigaben → FritzBox Dienste → Zertifikat → Zertifikat herunterladen_) and save it to `/etc/munin/box.cer`.
The certificate might change after a FRITZ!Box Update.

1. Create entry in `/etc/munin/plugin-conf.d/munin-node`:

[fritzbox_*]
env.fritzbox_password <fritzbox_password>
env.fritzbox_user <fritzbox_user>
env.fritzbox_password <fritzbox_password>
env.fritzbox_use_tls true
host_name fritzbox

See the plugin files for plugin-specific configuration options.

1. For each plugin you want to activate, create a symbolic link to `/etc/munin/plugins`, e.g.:
1. For each plugin you want to activate, create a symbolic link to `/etc/munin/plugins` and make it executable, e.g.:
```
ln -s fritzbox_dsl.py /etc/munin/plugins/fritzbox_dsl.py
ln -s fritzbox_dsl.py /etc/munin/plugins/fritzbox_dsl.py && chmod +x /etc/munin/plugins/fritzbox_dsl.py
```

1. Restart the munin-node daemon: `service munin-node restart`.

1. Done. You should now start to see the charts on the Munin pages!
1. Done. You should now start to see the charts on the Munin pages🥳

## Localization

The `fritzbox_energy` script depends on the language selected in your FRITZ!Box. Currently, two locales are
The `fritzbox_energy.py` script depends on the language selected in your FRITZ!Box. Currently, two locales are
supported:

1. German: `de` (default)
Expand All @@ -128,7 +146,6 @@ You can split the graphs of your FRITZ!Box from the localhost graphs by followin
address 127.0.0.1
use_node_name yes


[home.yourhost.net;fritzbox]
address 127.0.0.1
use_node_name no
Expand All @@ -137,7 +154,16 @@ You can split the graphs of your FRITZ!Box from the localhost graphs by followin

## Testing

To test a plugin use
### Manual Testing

To manually test a plugin use
```
munin-run --pidebug fritzbox_connection_uptime.py
```

### Unit Tests

Run all unit tests with
```
munin-run --debug fritzbox_connection_uptime.py
pytest --cov
```
3 changes: 2 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ disable=raw-checker-failed,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead
use-symbolic-message-instead,
line-too-long

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
3 changes: 3 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pylint
pytest
pytest-cov
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fritzconnection>=1.3.0
fritzconnection>=1.12.0
requests
lxml
26 changes: 0 additions & 26 deletions src/FritzboxConfig.py

This file was deleted.

47 changes: 0 additions & 47 deletions src/FritzboxFileSession.py

This file was deleted.

18 changes: 18 additions & 0 deletions src/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest.mock import patch
import pytest
from test_response_mock import ResponseMock
from test_fritzconnection_mock import FritzConnectionMock

# @see https://docs.pytest.org/en/7.3.x/example/parametrize.html#indirect-parametrization


@pytest.fixture(autouse=True)
def fixture_version(request): # request param is fixture
with patch('requests.request', side_effect=ResponseMock) as mock_requests:
mock_requests.side_effect.version = request.param if hasattr(request, "param") else None
yield


@pytest.fixture(autouse=True)
def connection(request):
return FritzConnectionMock(version=request.param if hasattr(request, "param") else None)
Loading