Skip to content
55 changes: 49 additions & 6 deletions plugins/inputs/fritzbox/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Fritzbox Input Plugin

This plugin gathers status information from [AVM][avm] devices (routers,
This plugin gathers status information from [FRITZ!][fritz] devices (routers,
repeaters, etc) using the device's [TR-064][tr064] interface.

⭐ Telegraf v1.35.0
🏷️ network, iot
💻 all

[avm]: https://en.avm.de/
[tr064]: https://avm.de/service/schnittstellen/
[fritz]: https://fritz.com/
[tr064]: https://fritz.com/en/pages/interfaces

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

Expand All @@ -32,6 +32,7 @@ plugin ordering. See [CONFIGURATION.md][CONFIGURATION.md] for more details.
# "wan",
# "ppp",
# "dsl",
# "fiber",
# "wlan",
# ]

Expand Down Expand Up @@ -63,6 +64,9 @@ configured devices. Will create `fritzbox_ppp` metrics.
`dsl` : Collect DSL line status and statistics for the configured devices.
Will create `fritzbox_dsl` metrics.

`fiber` : Collect Fiber line status and statistics for the configured devices.
Will create `fritzbox_fiber` metrics.

`wlan` : Collect status and number of associated devices for all WLANs.
Will create `fritzbox_wlan` metrics.

Expand All @@ -75,6 +79,11 @@ bandwidth. Will create `fritzbox_hosts` metrics.
> the plugin's query interval to avoid interval overruns and to minimize
> the amount of collected data.

An empty `collect` option defaults to the set
`["device", "wan", "ppp", "dsl", "wlan"]` supported by the initial
release of the plugin. Newly added options like `fiber` must be
enabled explicitly.

## Metrics

By default field names are directly derived from the corresponding [interface
Expand All @@ -85,9 +94,9 @@ specification][tr064].
- `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.
- `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`
Expand Down Expand Up @@ -148,6 +157,38 @@ specification][tr064].
- `atuc_hec_errors` (uint) - Remote DSLAM Header Error Control errors
- `crc_errors` (uint) - Local Modem Cyclic Redundancy Check error
- `atuc_crc_errors` (uint) - Remote DSLAM Cyclic Redundancy Check errors
- `fritzbox_fiber`
- tags
- `source` - The name of the device (this metric has been queried from)
- `service` - The service id used to query this metric
- fields
- `optical_signal_level` (uint) - Optical signal level (mdBm)
- `lower_optical_threshold` (uint) - Lower optical threshold (mdBm)
- `upper_optical_threshold` (uint) - Upper optical threshold (mdBm)
- `transmit_optical_level` (uint) - Transmit optical signal level
(mdBm)
- `lower_transmit_power_threshold` (uint) - Lower transmit power
threshold (mdBm)
- `upper_transmit_power_threshold` (uint) - Upper transmit power
threshold (mdBm)
- `sfp_vendor` (string) - SFP module vendor
- `sfp_part_number` (string) - SFP module part number
- `sfp_serial_number` (string) - SFP module serial number
- `sfp_type` (uint) - SFP module type
- `tx_wave_length` (uint) - TX wave length (nm)
- `fiber_mode` (string) - Current fiber mode
- `bytes_sent` (uint) - Total bytes sent
- `bytes_received` (uint) - Total bytes received
- `packets_sent` (uint) - Total packets sent
- `packets_received` (uint) - Total packets received
- `packet_errors_sent` (uint) - Total send packet errors
- `packet_errors_received` (uint) - Total receive packet errors
- `packets_multicast` (uint) - Total multicast packets
- `connection_rate_down` (uint) - Downstream connection rate (bit/s)
- `connection_rate_up` (uint) - Upstream connection rate (bit/s)
- `best_train_state` (uint) - Best train state
- `resyncs` (uint) - Number of resyncs
- `minutes_in_showtime` (uint) - Minutes in showtime
- `fritzbox_wlan`
- tags
- `source` - The name of the device (this metric has been queried from)
Expand Down Expand Up @@ -187,6 +228,8 @@ fritzbox_ppp,service=WANPPPConnection1,source=fritz.box uptime=369434i,upstream_

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_fiber,service=X_AVM_DE_WANFiber1,source=127.0.0.1 optical_signal_level=0i,lower_optical_threshold=0i,upper_optical_threshold=-5900i,transmit_optical_level=0i,lower_transmit_power_threshold=-500i,upper_transmit_power_threshold=0i,sfp_vendor="XXXX XXx",sfp_part_number="",sfp_serial_number="AB12345678901",sfp_type=0i,tx_wave_length=1310u,fiber_mode="Unknown",bytes_sent=664548698u,bytes_received=0u,packets_sent=1328165u,packets_received=0u,packet_errors_sent=0u,packet_errors_received=0u,packets_multicast=2944821u,connection_rate_down=0u,connection_rate_up=1250000u,best_train_state=0u,resyncs=0u,minutes_in_showtime=0u 1737088741855188000

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
Expand Down
50 changes: 50 additions & 0 deletions plugins/inputs/fritzbox/fritzbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/tdrn-org/go-tr064/services/tr64desc/wandslifconfig"
"github.com/tdrn-org/go-tr064/services/tr64desc/wanpppconn"
"github.com/tdrn-org/go-tr064/services/tr64desc/wlanconfig"
"github.com/tdrn-org/go-tr064/services/tr64desc/x_wanfiber"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
Expand Down Expand Up @@ -94,6 +95,8 @@ func (f *Fritzbox) Init() error {
f.serviceHandlers[wanpppconn.ServiceShortType] = gatherPppInfo
case "dsl":
f.serviceHandlers[wandslifconfig.ServiceShortType] = gatherDslInfo
case "fiber":
f.serviceHandlers[x_wanfiber.ServiceShortType] = gatherFiberInfo
case "wlan":
f.serviceHandlers[wlanconfig.ServiceShortType] = gatherWlanInfo
case "hosts":
Expand Down Expand Up @@ -295,6 +298,53 @@ func gatherDslInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service
return nil
}

func gatherFiberInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error {
serviceClient := x_wanfiber.ServiceClient{
TR064Client: deviceClient,
Service: service,
}
info := &x_wanfiber.GetInfoResponse{}
if err := serviceClient.GetInfo(info); err != nil {
return fmt.Errorf("failed to query Fiber info: %w", err)
}
statistics := &x_wanfiber.GetStatisticsResponse{}
if err := serviceClient.GetStatistics(statistics); err != nil {
return fmt.Errorf("failed to query Fiber statistics: %w", err)
}
tags := map[string]string{
"source": serviceClient.TR064Client.DeviceUrl.Hostname(),
"service": serviceClient.Service.ShortId(),
}
fields := map[string]interface{}{
"optical_signal_level": info.NewOpticalSignalLevel,
"lower_optical_threshold": info.NewLowerOpticalThreshold,
"upper_optical_threshold": info.NewUpperOpticalThreshold,
"transmit_optical_level": info.NewTransmitOpticalLevel,
"lower_transmit_power_threshold": info.NewLowerTransmitPowerThreshold,
"upper_transmit_power_threshold": info.NewUpperTransmitPowerThreshold,
"sfp_vendor": info.NewSFPVendor,
"sfp_part_number": info.NewSFPPartNumber,
"sfp_serial_number": info.NewSFPSerialNumber,
"sfp_type": info.NewSFPType,
"tx_wave_length": info.NewTXWaveLength,
"fiber_mode": info.NewFiberMode,
"bytes_sent": statistics.NewBytesSent,
"bytes_received": statistics.NewBytesReceived,
"packets_sent": statistics.NewPacketsSent,
"packets_received": statistics.NewPacketsReceived,
"packet_errors_sent": statistics.NewPacketErrorsSent,
"packet_errors_received": statistics.NewPacketErrorsReceived,
"packets_multicast": statistics.NewPacketsMulticast,
"connection_rate_down": statistics.NewConnectionRateDown,
"connection_rate_up": statistics.NewConnectionRateUp,
"best_train_state": statistics.NewBestTrainState,
"resyncs": statistics.NewResyncs,
"minutes_in_showtime": statistics.NewMinutesInShowtime,
}
acc.AddFields("fritzbox_fiber", fields, tags)
return nil
}

func gatherWlanInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error {
serviceClient := wlanconfig.ServiceClient{
TR064Client: deviceClient,
Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/fritzbox/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# "wan",
# "ppp",
# "dsl",
# "fiber",
# "wlan",
# ]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fritzbox_fiber,service=X_AVM_DE_WANFiber1,source=127.0.0.1 optical_signal_level=0i,lower_optical_threshold=0i,upper_optical_threshold=-5900i,transmit_optical_level=0i,lower_transmit_power_threshold=-500i,upper_transmit_power_threshold=0i,sfp_vendor="XXXX XXx",sfp_part_number="",sfp_serial_number="AB12345678901",sfp_type=0i,tx_wave_length=1310u,fiber_mode="Unknown",bytes_sent=664548698u,bytes_received=0u,packets_sent=1328165u,packets_received=0u,packet_errors_sent=0u,packet_errors_received=0u,packets_multicast=2944821u,connection_rate_down=0u,connection_rate_up=1250000u,best_train_state=0u,resyncs=0u,minutes_in_showtime=0u 1737088741855188000
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<scpd xmlns="urn:dslforum-org:service-1-0">
<actionList/>
<serviceStateTable/>
</scpd>
13 changes: 13 additions & 0 deletions plugins/inputs/fritzbox/testdata/testcases/fiber/mock/tr64desc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<root xmlns="urn:dslforum-org:device-1-0">
<device>
<serviceList>
<service>
<serviceType>urn:dslforum-org:service:X_AVM-DE_WANFiber:1</serviceType>
<serviceId>urn:X_AVM-DE_WANFiber-com:serviceId:X_AVM-DE_WANFiber1</serviceId>
<controlURL>/x_wanfiber</controlURL>
<SCPDURL>/dummySCPD.xml</SCPDURL>
</service>
</serviceList>
<deviceList/>
</device>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetInfoResponse xmlns:u="urn:dslforum-org:service:X_AVM-DE_WANFiber:1">
<NewOpticalSignalLevel>0</NewOpticalSignalLevel>
<NewLowerOpticalThreshold>0</NewLowerOpticalThreshold>
<NewUpperOpticalThreshold>-5900</NewUpperOpticalThreshold>
<NewTransmitOpticalLevel>0</NewTransmitOpticalLevel>
<NewLowerTransmitPowerThreshold>-500</NewLowerTransmitPowerThreshold>
<NewUpperTransmitPowerThreshold>0</NewUpperTransmitPowerThreshold>
<NewSFPVendor>XXXX XXx</NewSFPVendor>
<NewSFPPartNumber></NewSFPPartNumber>
<NewSFPSerialNumber>AB12345678901</NewSFPSerialNumber>
<NewSFPType>0</NewSFPType>
<NewTXWaveLength>1310</NewTXWaveLength>
<NewFiberMode>Unknown</NewFiberMode>
</u:GetInfoResponse>
<u:GetStatisticsResponse xmlns:u="urn:dslforum-org:service:X_AVM-DE_WANFiber:1">
<NewBytesSent>664548698</NewBytesSent>
<NewBytesReceived>0</NewBytesReceived>
<NewPacketsSent>1328165</NewPacketsSent>
<NewPacketsReceived>0</NewPacketsReceived>
<NewPacketErrorsSent>0</NewPacketErrorsSent>
<NewPacketErrorsReceived>0</NewPacketErrorsReceived>
<NewPacketsMulticast>2944821</NewPacketsMulticast>
<NewConnectionRateDown>0</NewConnectionRateDown>
<NewConnectionRateUp>1250000</NewConnectionRateUp>
<NewBestTrainState>0</NewBestTrainState>
<NewResyncs>0</NewResyncs>
<NewMinutesInShowtime>0</NewMinutesInShowtime>
</u:GetStatisticsResponse>
</s:Body>
</s:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[inputs.fritzbox]]
## URLs are set dynamically by test
# urls = [ ]
collect = [ "fiber" ]
# everything else stays at defaults

Loading