Skip to content
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

feat(inputs.fritzbox): Make inputs.fritzbox an internal plugin #16390

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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.2
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
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,8 @@ 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.2.2 h1:rDybEK1m2xfV5QPWHtnIJOt+xG4GFSkQSwA6FS2bQC4=
github.com/tdrn-org/go-tr064 v0.2.2/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
210 changes: 210 additions & 0 deletions plugins/inputs/fritzbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# 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://en.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 (number 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 URLs of the devices to query. For each device the corresponding URL
## including the login credentials must be set. E.g.
## urls = [
## "http://boxuser:[email protected]:49000/",
## "http://:[email protected]:49000/",
## ]
urls = [
]

## The information to collect (see README for further details).
# collect = [
# "device",
# "wan",
# "ppp",
# "dsl",
# "wlan",
# ]

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

## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
```

### Collect options

The following collect options are available:

`device` metric: fritzbox_device - Collect device infos like model name,
SW version, uptime for the configured devices.

`wan` metric: fritzbox_wan - Collect generic WAN connection status like
bit rates, transferred bytes.

`ppp` metric: fritzbox_ppp - Collect PPP connection parameters like bit
rates, uptime.

`dsl` metric: fritzbox_dsl - Collect DSL line status and statistics.

`wlan` metric: fritzbox_wlan - Collect status and number of associated
devices for all WLANs.

`hosts` metric: fritzbox_hosts - Collect detailed information of the mesh
network including connected nodes, there role in the network as well as
their connection bandwidth.

**Note**: Collecting this metric is time consuming and it generates
very detailed data. If you activate this option, consider increasing
the plugin's query interval to avoid interval overruns and to minimize
the amount of collected data. You can adapt the interval per collect
otpion as follows:

```toml
[[inputs.fritzbox]]
collect = [ "device", "wan", "ppp", "dsl", "wlan" ]
...

[[inputs.fritzbox]]
interval = "5m"
collect = [ "hosts" ]
...
```

## Metrics

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

- `fritzbox_device`
- tags
- `source` - The name of the device (this metric has been queried from)
- `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
- `source` - The name of the device (this metric has been queried from)
- `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
- `source` - The name of the device (this metric has been queried from)
- `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
- `source` - The name of the device (this metric has been queried from)
- `service` - The service id used to query this metric
- `status` - The status of the DLS line (Up or Down)
- 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
- `source` - The name of the device (this metric has been queried from)
- `service` - The service id used to query this metric
- `wlan` - The WLAN SSID (name)
- `channel` - The channel used by this WLAN
- `band` - The band (in MHz) used by this WLAN
- `status` - The status of the WLAN line (Up or Down)
- fields
- `total_associations` (uint) - The number of devices connected to this WLAN.
- `fritzbox_hosts`
- tags
- `source` - The name of the device (this metric has been queried from)
- `service` - The service id used to query this metric
- `node` - The name of the node connected to the mesh network
- `node_role` - The node's role ("master" = mesh master, "slave" = mesh slave, "client") in the network
- `node_ap` - The name of the access point this node is connected to
- `node_ap_role` - The access point's role ("master" = mesh master, "slave" = mesh slave, never "client") in the network
- `link_type` - The link type ("WLAN" or "LAN") of the peer connection
- `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,service=DeviceInfo1,source=fritz.box uptime=2058438i,model_name="Mock 1234",serial_number="123456789",hardware_version="Mock 1234",software_version="1.02.03" 1737003520174438000

fritzbox_wan,service=WANCommonInterfaceConfig1,source=fritz.box layer1_upstream_max_bit_rate=48816000i,layer1_downstream_max_bit_rate=253247000i,upstream_current_max_speed=511831i,downstream_current_max_speed=1304268i,total_bytes_sent=129497283207i,total_bytes_received=554484531337i 1737003587690504000

fritzbox_ppp,service=WANPPPConnection1,source=fritz.box uptime=369434i,upstream_max_bit_rate=44213433i,downstream_max_bit_rate=68038668i 1737003622308149000

fritzbox_dsl,service=WANDSLInterfaceConfig1,source=fritz.box,status=Up downstream_curr_rate=249065i,downstream_max_rate=249065i,downstream_power=513i,init_timeouts=0i,atuc_crc_errors=13i,errored_secs=25i,atuc_hec_errors=0i,upstream_noise_margin=80i,downstream_noise_margin=60i,downstream_attenuation=140i,receive_blocks=490282831i,transmit_blocks=254577751i,init_errors=0i,crc_errors=53i,fec_errors=0i,hec_errors=0i,upstream_max_rate=48873i,upstream_attenuation=80i,upstream_power=498i,cell_delin=0i,link_retrain=2i,loss_of_framing=0i,upstream_curr_rate=46719i,severly_errored_secs=0i,atuc_fec_errors=0i 1737003645769642000

fritzbox_wlan,band=2400,channel=13,service=WLANConfiguration1,source=fritz.box,ssid=MOCK1234,status=Up total_associations=11i 1737003673561198000

fritzbox_hosts,node=device#17,node_ap=device#1,node_ap_role=master,node_role=slave,link_name=AP:2G:0,link_type=WLAN,service=Hosts1,source=fritz.box cur_data_rate_tx=216000i,cur_data_rate_rx=216000i,max_data_rate_tx=216000i,max_data_rate_rx=216000i 1737003707257394000
fritzbox_hosts,node=device#24,node_ap=device#17,node_ap_role=slave,node_role=client,link_name=LAN:1,link_type=LAN,service=Hosts1,source=fritz.box max_data_rate_tx=1000000i,max_data_rate_rx=1000000i,cur_data_rate_tx=0i,cur_data_rate_rx=0i 1737003707257248000
```

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