Skip to content

feat(inputs.fritzbox): Add plugin #16390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
429aae8
feat(inputs.fritzbox): Initial implementation
hdecarne Jan 10, 2025
7f5a310
feat(inputs.fritzbox): Fix linter issues
hdecarne Jan 10, 2025
956766c
feat(inputs.fritzbox): Improve tag names
hdecarne Jan 15, 2025
ccd459a
feat(inputs.fritzbox): Remove plugin Debug flag and use log level ins…
hdecarne Jan 15, 2025
fd007fc
feat(inputs.fritzbox): Rework plugin log output to emit proper line p…
hdecarne Jan 16, 2025
bdc7789
feat(inputs.fritzbox): go mod tidy
hdecarne Jan 16, 2025
8777e74
feat(inputs.fritzbox): Rename plugin option devices to URLs
hdecarne Jan 16, 2025
4921179
feat(inputs.fritzbox): Rework testing code
hdecarne Jan 17, 2025
ac19a13
feat(inputs.fritzbox): Remove unnecessary logging
hdecarne Jan 17, 2025
9ffdb53
feat(inputs.fritzbox): Reworked plugin configuration
hdecarne Jan 17, 2025
6974a96
feat(inputs.fritzbox): Fix Errorf format
hdecarne Jan 17, 2025
779ebfa
feat(inputs.fritzbox): Fixed double conversion
hdecarne Jan 18, 2025
21f1990
feat(inputs.fritzbox): Use Telegraf functions for configuration test …
hdecarne Jan 20, 2025
8976c29
feat(inputs.fritzbox): Retrieve sent/recv stats via wancommonifconfig…
hdecarne Jan 20, 2025
6043a4f
feat(inputs.fritzbox): Query devices in parallel
hdecarne Jan 20, 2025
8e18f42
feat(inputs.fritzbox): Comment out collect defaults
hdecarne Jan 20, 2025
20a60e5
feat(inputs.fritzbox): Query devices in parallel
hdecarne Jan 21, 2025
1ada7a8
feat(inputs.fritzbox): Re-work after PR review
hdecarne Mar 4, 2025
42a96f1
feat(inputs.fritzbox): Make errors unique
hdecarne Mar 4, 2025
fb3d584
Merge branch 'master' into fritzbox-plugin
hdecarne Mar 6, 2025
3ec8583
Merge branch 'influxdata:master' into fritzbox-plugin
hdecarne Mar 8, 2025
a3b25ca
feat(inputs.fritzbox): Re-work after PR review
hdecarne Mar 9, 2025
53ea309
feat(inputs.fritzbox): Re-work after PR review
hdecarne Mar 9, 2025
a22c37a
feat(inputs.fritzbox): Re-work after PR review
hdecarne Mar 9, 2025
297c0b8
feat(inputs.fritzbox): Re-work after PR review
hdecarne Mar 18, 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
1 change: 0 additions & 1 deletion EXTERNAL_PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Pull requests welcome.
- [db2](https://github.com/bonitoo-io/telegraf-input-db2) - Gather the statistic data from DB2 RDBMS
- [apt](https://github.com/x70b1/telegraf-apt) - Check Debian for package updates.
- [knot](https://github.com/x70b1/telegraf-knot) - Collect stats from Knot DNS.
- [fritzbox](https://github.com/hdecarne-github/fritzbox-telegraf-plugin) - Gather statistics from [FRITZ!Box](https://avm.de/produkte/fritzbox/) router and repeater
- [linux-psi-telegraf-plugin](https://github.com/gridscale/linux-psi-telegraf-plugin) - Gather pressure stall information ([PSI](https://facebookmicrosites.github.io/psi/)) from the Linux Kernel
- [huebridge](https://github.com/hdecarne-github/huebridge-telegraf-plugin) - Gather smart home statistics from [Hue Bridge](https://www.philips-hue.com/) devices
- [nsdp](https://github.com/hdecarne-github/nsdp-telegraf-plugin) - Gather switch network statistics via [Netgear Switch Discovery Protocol](https://en.wikipedia.org/wiki/Netgear_Switch_Discovery_Protocol)
Expand Down
1 change: 1 addition & 0 deletions docs/LICENSE_OF_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ following works:
- github.com/stoewer/go-strcase [MIT License](https://github.com/stoewer/go-strcase/blob/master/LICENSE)
- github.com/stretchr/objx [MIT License](https://github.com/stretchr/objx/blob/master/LICENSE)
- github.com/stretchr/testify [MIT License](https://github.com/stretchr/testify/blob/master/LICENSE)
- github.com/tdrn-org/go-tr064 [Apache License 2.0](https://github.com/tdrn-org/go-tr064/blob/main/LICENSE)
- github.com/testcontainers/testcontainers-go [MIT License](https://github.com/testcontainers/testcontainers-go/blob/main/LICENSE)
- github.com/thomasklein94/packer-plugin-libvirt [Mozilla Public License 2.0](https://github.com/thomasklein94/packer-plugin-libvirt/blob/main/LICENSE)
- github.com/tidwall/gjson [MIT License](https://github.com/tidwall/gjson/blob/master/LICENSE)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/tdrn-org/go-tr064 v0.2.0
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/tinylru v1.2.1 // indirect
Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,20 @@ github.com/t3rm1n4l/go-mega v0.0.0-20240219080617-d494b6a8ace7 h1:Jtcrb09q0AVWe3
github.com/t3rm1n4l/go-mega v0.0.0-20240219080617-d494b6a8ace7/go.mod h1:suDIky6yrK07NnaBadCB4sS0CqFOvUK91lH7CR+JlDA=
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 h1:Oj2e7Sae4XrOsk3ij21QjjEgAcVSeo9nkp0dI//cD2o=
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw=
github.com/tdrn-org/go-tr064 v0.1.6 h1:5Y/1/VzkQws8LAxWeKW8bH6FcAMToQQTBsqkItR+zY0=
github.com/tdrn-org/go-tr064 v0.1.6/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0=
github.com/tdrn-org/go-tr064 v0.1.7 h1:YdKRg9OG4aAppIiWfDqOC5g/6LCOXWMIkdOz5y9tts4=
github.com/tdrn-org/go-tr064 v0.1.7/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0=
github.com/tdrn-org/go-tr064 v0.1.8 h1:9bvf85Pa30pcrlYHsgZUZ54aGu0UCj+U7K9jroGSLsU=
github.com/tdrn-org/go-tr064 v0.1.8/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0=
github.com/tdrn-org/go-tr064 v0.1.9 h1:HGRiBsgvmSlFxcnlVVllMRewrHKpQFq0O13bEvwfaSQ=
github.com/tdrn-org/go-tr064 v0.1.9/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0=
github.com/tdrn-org/go-tr064 v0.1.10 h1:TIU7P+KoxBpjyQ6B7H9Yf4DxDK/6td6tc4lZNasYQwc=
github.com/tdrn-org/go-tr064 v0.1.10/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0=
github.com/tdrn-org/go-tr064 v0.1.11 h1:LFjJjfU7NdGXnqrNZ+dxaxCt4EndJISknTL1VGNcGBY=
github.com/tdrn-org/go-tr064 v0.1.11/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0=
github.com/tdrn-org/go-tr064 v0.2.0 h1:n2Dz8UdUlZm8jS0coiXl6eRVB4qSz8fcbrHJhPyNVfk=
github.com/tdrn-org/go-tr064 v0.2.0/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0=
github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0=
github.com/testcontainers/testcontainers-go v0.34.0 h1:5fbgF0vIN5u+nD3IWabQwRybuB4GY8G2HHgCkbMzMHo=
github.com/testcontainers/testcontainers-go v0.34.0/go.mod h1:6P/kMkQe8yqPHfPWNulFGdFHTD8HB2vLq/231xY2iPQ=
Expand Down
5 changes: 5 additions & 0 deletions plugins/inputs/all/fritzbox.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !custom || inputs || inputs.fritzbox

package all

import _ "github.com/influxdata/telegraf/plugins/inputs/fritzbox" // register plugin
179 changes: 179 additions & 0 deletions plugins/inputs/fritzbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Fritzbox Input Plugin

This input plugin gathers status from [AVM][1] devices (routers, repeaters,
...). It uses the device's [TR-064][2] interfaces to retrieve the status.

[1]: https://avm.de/
[2]: https://avm.de/service/schnittstellen/

Retrieved status are:

- Device info (model, HW/SW version, uptime, ...)
- WAN info (bit rates, transferred bytes, ...)
- PPP info (bit rates, connection uptime, ...)
- DSL info (bit rates, DSL statistics, ...)
- WLAN info (numbrer of clients per network, ...)
- Hosts info (mesh nodes, bit rates, ...)

## Global configuration options <!-- @/docs/includes/plugin_config.md -->

In addition to the plugin-specific configuration settings, plugins support
additional global and plugin configuration settings. These settings are used to
modify metrics, tags, and field or create aliases and configure ordering, etc.
See the [CONFIGURATION.md][CONFIGURATION.md] for more details.

[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins

## Configuration

```toml @sample.conf
# Gather fritzbox status
[[inputs.fritzbox]]
## The devices to query. For each device the corresponding URL including the
## user and passwort needed to login must be set.
## E.g.
## devices = [
## "http://boxuser:boxpassword@fritz.box:49000/",
## "http://:repeaterpassword@fritz.repeater:49000/",
## ]
devices = [
]

## The information to query (see README for further details).
## Hosts info is disabled by default, as it generates an extensive amount
## of data.
# device_info = true
# wan_info = true
# ppp_info = true
# dsl_info = true
# wlan_info = true
# hosts_info = false

## Some metric queries are time-consuming and not collected on every query
## cycle. This counter defines how often these low-traffic queries
## are excuted. The default value 30 means, on every 30th query corresponding
## to every 5 minutes (assuming the standard query interval of 10s).
## If this option is set to 1 or below, all metrics are collected on every
## query cycle.
# full_query_cycle = 30

## The http timeout to use.
# timeout = "10s"

## Skip TLS verification. Is needed to query devices with the default
## self-signed certificate.
# tls_skip_verify = false

## Enable debug output
# debug = false
```

## Metrics

By default field names are directly derived from the corresponding [interface
specification][1].

- `fritzbox_device`
- tags
- `fritz_device` - The device name (this metric has been queried from)
- `fritz_service` - The service id used to query this metric
- fields
- `uptime` (uint) - Device's uptime in seconds.
- `model_name` (string) - Device's model name.
- `serial_number` (string) - Device's serial number.
- `hardware_version` (string) - Device's hardware version.
- `software_version` (string) - Device's software version.
- `fritzbox_wan`
- tags
- `fritz_device` - The device name (this metric has been queried from)
- `fritz_service` - The service id used to query this metric
- fields
- `layer1_upstream_max_bit_rate` (uint) - The WAN interface's maximum upstream bit rate (bits/sec)
- `layer1_downstream_max_bit_rate` (uint) - The WAN interface's maximum downstream bit rate (bits/sec)
- `upstream_current_max_speed` (uint) - The WAN interface's current maximum upstream transfer rate (bytes/sec)
- `downstream_current_max_speed` (uint) - The WAN interface's current maximum downstream data rate (bytes/sec)
- `total_bytes_sent` (uint) - The total number of bytes sent via the WAN interface (bytes)
- `total_bytes_received` (uint) - The total number of bytes received via the WAN interface (bytes)
- `fritzbox_ppp`
- tags
- `fritz_device` - The device name (this metric has been queried from)
- `fritz_service` - The service id used to query this metric
- fields
- `uptime` (uint) - The current uptime of the PPP connection in seconds
- `upstream_max_bit_rate` (uint) - The current maximum upstream bit rate negotiated for the PPP connection (bits/sec)
- `downstream_max_bit_rate` (uint) - The current maximum downstream bit rate negotiated for the PPP connection (bits/sec)
- `fritzbox_dsl`
- tags
- `fritz_device` - The device name (this metric has been queried from)
- `fritz_service` - The service id used to query this metric
- fields
- `upstream_curr_rate` (uint) - Current DSL upstream rate (kilobits/sec)
- `downstream_curr_rate` (uint) - Current DSL downstream rate (kilobits/sec)
- `upstream_max_rate` (uint) - Maximum DSL upstream rate (kilobits/sec)
- `downstream_max_rate` (uint) - Maximum DSL downstream rate (kilobits/sec)
- `upstream_noise_margin` (uint) - Upstream noise margin (db)
- `downstream_noise_margin` (uint) - Downstream noise margin (db)
- `upstream_attenuation` (uint) - Upstream attenuation (db)
- `downstream_attenuation` (uint) - Downstream attenuation (db)
- `upstream_power` (uint) - Upstream power
- `downstream_power` (uint) - Downstream power
- `receive_blocks` (uint) - Received blocks
- `transmit_blocks` (uint) - Transmitted blocks
- `cell_delin` (uint) - Cell delineation count
- `link_retrain` (uint) - Link retrains
- `init_errors` (uint) - Initialization errors
- `init_timeouts` (uint) - Initialization timeouts
- `loss_of_framing` (uint) - Loss of frame errors
- `errored_secs` (uint) - Continuous seconds with errors
- `severly_errored_secs` (uint) - Continuous seconds with severe errors
- `fec_errors` (uint) - Local (Modem) FEC (Forward Error Correction) errors
- `atuc_fec_errors` (uint) - Remote (DSLAM) FEC (Forward Error Correction) errors
- `hec_errors` (uint) - Local (Modem) HEC (Header Error Control) errors
- `atuc_hec_errors` (uint) - Remote (DSLAM) HEC (Header Error Control) errors
- `crc_errors` (uint) - Local (Modem) CRC (Cyclic Redundancy Check) error
- `atuc_crc_errors` (uint) - Remote (DSLAM) CRC (Cyclic Redundancy Check) errors
- `fritzbox_wlan`
- tags
- `fritz_device` - The device name (this metric has been queried from)
- `fritz_service` - The service id used to query this metric
- `fritz_wlan` - The WLAN SSID (name)
- `fritz_wlan_channel` - The channel used by this WLAN
- `fritz_wlan_band` - The band (in MHz) used by this WLAN
- fields
- `total_associations` (uint) - The number of devices connected to this WLAN.
- `fritzbox_host`
- tags
- `fritz_device` - The device name (this metric has been queried from)
- `fritz_service` - The service id used to query this metric
- `fritz_host` - The host connected to the network
- `fritz_host_role` - The host's role ("master" = mesh master, "slave" = mesh slave, "client") in the network
- `fritz_host_peer` - The name of the peer this host is connected to
- `fritz_host_peer_role` - The peer's role ("master" = mesh master, "slave" = mesh slave, never "client") in the network
- `fritz_link_type` - The link type ("WLAN" or "LAN") of the peer connection
- `fritz_link_name` - The link name of the connection
- fields
- `max_data_rate_tx` (uint) - The connection's maximum transmit rate (kilobits/sec)
- `max_data_rate_rx` (uint) - The connection's maximum receive rate (kilobits/sec)
- `cur_data_rate_tx` (uint) - The connection's maximum transmit rate (kilobits/sec)
- `cur_data_rate_rx` (uint) - The connection's current receive rate (kilobits/sec)

## Example Output

<!-- markdownlint-disable MD013 -->

```text
fritzbox_device,fritz_device=127.0.0.1,fritz_service=DeviceInfo1 model_name=Mock 1234,serial_number=123456789,hardware_version=Mock 1234,software_version=1.02.03,uptime=2058438 1736529975

fritzbox_wan,fritz_device=127.0.0.1,fritz_service=WANCommonInterfaceConfig1 total_bytes_received=554484531337,layer1_upstream_max_bit_rate=48816000,layer1_downstream_max_bit_rate=253247000,upstream_current_max_speed=511831,downstream_current_max_speed=1304268,total_bytes_sent=129497283207 1736530024

fritzbox_ppp,fritz_device=127.0.0.1,fritz_service=WANPPPConnection1 uptime=369434,upstream_max_bit_rate=44213433,downstream_max_bit_rate=68038668 1736530058

fritzbox_dsl,fritz_device=127.0.0.1,fritz_service=WANDSLInterfaceConfig1 downstream_noise_margin=60,upstream_power=498,downstream_power=513,upstream_curr_rate=46719,downstream_curr_rate=249065,upstream_max_rate=48873,downstream_max_rate=249065,upstream_noise_margin=80,severly_errored_secs=0,upstream_attenuation=80,transmit_blocks=254577751,init_timeouts=0,atuc_crc_errors=13,receive_blocks=490282831,errored_secs=25,fec_errors=0,atuc_hec_errors=0,atuc_fec_errors=0,hec_errors=0,crc_errors=53,downstream_attenuation=140,cell_delin=0,link_retrain=2,init_errors=0,loss_of_framing=0 1736530092

fritzbox_wlan,fritz_device=127.0.0.1,fritz_service=WLANConfiguration1,fritz_wlan=MOCK1234,fritz_wlan_channel=13,fritz_wlan_band=2400 total_associations=11 1736530130

fritzbox_host,fritz_host_peer_role=master,fritz_link_type=WLAN,fritz_link_name=AP:2G:0,fritz_device=127.0.0.1,fritz_service=Hosts1,fritz_host=device#17,fritz_host_role=slave,fritz_host_peer=device#1 max_data_rate_tx=216000,max_data_rate_rx=216000,cur_data_rate_tx=216000,cur_data_rate_rx=216000 1736530165
fritzbox_host,fritz_device=127.0.0.1,fritz_service=Hosts1,fritz_host=device#24,fritz_host_role=client,fritz_host_peer=device#17,fritz_host_peer_role=slave,fritz_link_type=LAN,fritz_link_name=LAN:1 cur_data_rate_tx=0,cur_data_rate_rx=0,max_data_rate_tx=1000000,max_data_rate_rx=1000000 1736530165
```

<!-- markdownlint-enable MD013 -->.
Loading
Loading