From 1406f41ce848e2e72a04d088972966b577cd9e80 Mon Sep 17 00:00:00 2001 From: Holger Date: Tue, 18 Mar 2025 09:24:51 +0100 Subject: [PATCH] feat(inputs.fritzbox): Add plugin (#16390) --- EXTERNAL_PLUGINS.md | 1 - docs/LICENSE_OF_DEPENDENCIES.md | 1 + go.mod | 1 + go.sum | 2 + plugins/inputs/all/fritzbox.go | 5 + plugins/inputs/fritzbox/README.md | 184 +++ plugins/inputs/fritzbox/fritzbox.go | 413 ++++++ plugins/inputs/fritzbox/fritzbox_test.go | 148 +++ plugins/inputs/fritzbox/sample.conf | 24 + .../testdata/conf/invalid_collect.conf | 18 + .../fritzbox/testdata/conf/invalid_urls.conf | 24 + .../inputs/fritzbox/testdata/conf/valid.conf | 28 + .../testdata/testcases/device/expected.out | 1 + .../device/mock/deviceinfo/response.xml | 19 + .../testcases/device/mock/dummySCPD.xml | 4 + .../testcases/device/mock/tr64desc.xml | 13 + .../testdata/testcases/device/telegraf.conf | 6 + .../testdata/testcases/dsl/expected.out | 1 + .../testdata/testcases/dsl/mock/dummySCPD.xml | 4 + .../testdata/testcases/dsl/mock/tr64desc.xml | 13 + .../dsl/mock/wandslifconfig/response.xml | 39 + .../testdata/testcases/dsl/telegraf.conf | 6 + .../testdata/testcases/hosts/expected.out | 21 + .../testcases/hosts/mock/dummySCPD.xml | 4 + .../testcases/hosts/mock/hosts/response.xml | 8 + .../testcases/hosts/mock/meshlist.json | 1177 +++++++++++++++++ .../testcases/hosts/mock/tr64desc.xml | 13 + .../testdata/testcases/hosts/telegraf.conf | 6 + .../testdata/testcases/ppp/expected.out | 1 + .../testdata/testcases/ppp/mock/dummySCPD.xml | 4 + .../testdata/testcases/ppp/mock/tr64desc.xml | 13 + .../ppp/mock/wanpppconn/response.xml | 38 + .../testdata/testcases/ppp/telegraf.conf | 6 + .../testdata/testcases/wan/expected.out | 1 + .../wan/mock/WANCommonIFC1/response.xml | 24 + .../testdata/testcases/wan/mock/dummySCPD.xml | 4 + .../testdata/testcases/wan/mock/igddesc.xml | 13 + .../testdata/testcases/wan/mock/tr64desc.xml | 13 + .../wan/mock/wancommonifconfig/response.xml | 15 + .../testdata/testcases/wan/telegraf.conf | 6 + .../testdata/testcases/wlan/expected.out | 1 + .../testcases/wlan/mock/dummySCPD.xml | 4 + .../testdata/testcases/wlan/mock/tr64desc.xml | 13 + .../wlan/mock/wlanconfig/response.xml | 30 + .../testdata/testcases/wlan/telegraf.conf | 6 + 45 files changed, 2375 insertions(+), 1 deletion(-) create mode 100644 plugins/inputs/all/fritzbox.go create mode 100644 plugins/inputs/fritzbox/README.md create mode 100644 plugins/inputs/fritzbox/fritzbox.go create mode 100644 plugins/inputs/fritzbox/fritzbox_test.go create mode 100644 plugins/inputs/fritzbox/sample.conf create mode 100644 plugins/inputs/fritzbox/testdata/conf/invalid_collect.conf create mode 100644 plugins/inputs/fritzbox/testdata/conf/invalid_urls.conf create mode 100644 plugins/inputs/fritzbox/testdata/conf/valid.conf create mode 100644 plugins/inputs/fritzbox/testdata/testcases/device/expected.out create mode 100644 plugins/inputs/fritzbox/testdata/testcases/device/mock/deviceinfo/response.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/device/mock/dummySCPD.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/device/mock/tr64desc.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/device/telegraf.conf create mode 100644 plugins/inputs/fritzbox/testdata/testcases/dsl/expected.out create mode 100644 plugins/inputs/fritzbox/testdata/testcases/dsl/mock/dummySCPD.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/dsl/mock/tr64desc.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/dsl/mock/wandslifconfig/response.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/dsl/telegraf.conf create mode 100644 plugins/inputs/fritzbox/testdata/testcases/hosts/expected.out create mode 100644 plugins/inputs/fritzbox/testdata/testcases/hosts/mock/dummySCPD.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/hosts/mock/hosts/response.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/hosts/mock/meshlist.json create mode 100644 plugins/inputs/fritzbox/testdata/testcases/hosts/mock/tr64desc.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/hosts/telegraf.conf create mode 100644 plugins/inputs/fritzbox/testdata/testcases/ppp/expected.out create mode 100644 plugins/inputs/fritzbox/testdata/testcases/ppp/mock/dummySCPD.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/ppp/mock/tr64desc.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/ppp/mock/wanpppconn/response.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/ppp/telegraf.conf create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wan/expected.out create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wan/mock/WANCommonIFC1/response.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wan/mock/dummySCPD.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wan/mock/igddesc.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wan/mock/tr64desc.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wan/mock/wancommonifconfig/response.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wan/telegraf.conf create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wlan/expected.out create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wlan/mock/dummySCPD.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wlan/mock/tr64desc.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wlan/mock/wlanconfig/response.xml create mode 100644 plugins/inputs/fritzbox/testdata/testcases/wlan/telegraf.conf diff --git a/EXTERNAL_PLUGINS.md b/EXTERNAL_PLUGINS.md index 1ffb80598..8aad5961b 100644 --- a/EXTERNAL_PLUGINS.md +++ b/EXTERNAL_PLUGINS.md @@ -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 - [hwinfo](https://github.com/zachstence/hwinfo-telegraf-plugin) - Gather Windows system hardware information from [HWiNFO](https://www.hwinfo.com/) - [libvirt](https://gitlab.com/warrenio/tools/telegraf-input-libvirt) - Gather libvirt domain stats, based on a historical Telegraf implementation [libvirt](https://libvirt.org/) diff --git a/docs/LICENSE_OF_DEPENDENCIES.md b/docs/LICENSE_OF_DEPENDENCIES.md index 40de5e462..d9bcc58a6 100644 --- a/docs/LICENSE_OF_DEPENDENCIES.md +++ b/docs/LICENSE_OF_DEPENDENCIES.md @@ -373,6 +373,7 @@ following works: - github.com/stretchr/testify [MIT License](https://github.com/stretchr/testify/blob/master/LICENSE) - github.com/tdrn-org/go-hue [MIT License](https://github.com/tdrn-org/go-log/blob/main/LICENSE) - github.com/tdrn-org/go-nsdp [MIT License](https://github.com/tdrn-org/go-nsdp/blob/main/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) diff --git a/go.mod b/go.mod index 8c74401f3..445ed8c99 100644 --- a/go.mod +++ b/go.mod @@ -482,6 +482,7 @@ require ( github.com/stoewer/go-strcase v1.3.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/tdrn-org/go-nsdp v0.5.0 + 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 diff --git a/go.sum b/go.sum index f5798b865..7c970c2ff 100644 --- a/go.sum +++ b/go.sum @@ -2296,6 +2296,8 @@ github.com/tdrn-org/go-hue v0.3.0 h1:ywIlfTx9lcDp+n9XyGNY/9mUihW82lsWUanTzvdfeMc github.com/tdrn-org/go-hue v0.3.0/go.mod h1:KUnPy2lGoP43ygNoCg6jVEhf8h5fpRn0Esjxq9syCnU= github.com/tdrn-org/go-nsdp v0.5.0 h1:bOs8qABaP/BSQlWeziZx9gjGkC2ld9UQek9p5w6PvdY= github.com/tdrn-org/go-nsdp v0.5.0/go.mod h1:zp7CxiCPcyXHo+s6tn+wrNBr1qQe1G/hOh/FybM5xiM= +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.35.0 h1:uADsZpTKFAtp8SLK+hMwSaa+X+JiERHtd4sQAFmXeMo= github.com/testcontainers/testcontainers-go v0.35.0/go.mod h1:oEVBj5zrfJTrgjwONs1SsRbnBtH9OKl+IGl3UMcr2B4= diff --git a/plugins/inputs/all/fritzbox.go b/plugins/inputs/all/fritzbox.go new file mode 100644 index 000000000..56a4af020 --- /dev/null +++ b/plugins/inputs/all/fritzbox.go @@ -0,0 +1,5 @@ +//go:build !custom || inputs || inputs.fritzbox + +package all + +import _ "github.com/influxdata/telegraf/plugins/inputs/fritzbox" // register plugin diff --git a/plugins/inputs/fritzbox/README.md b/plugins/inputs/fritzbox/README.md new file mode 100644 index 000000000..708d43ea0 --- /dev/null +++ b/plugins/inputs/fritzbox/README.md @@ -0,0 +1,184 @@ +# Fritzbox Input Plugin + +This plugin gathers status information from [AVM][avm] 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/ + +## Global configuration options + +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]] + ## URLs of the devices to query including login credentials + urls = [ "http://user:password@fritz.box:49000/" ] + + ## 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` : Collect device information like model name, SW version, uptime etc +for the configured devices. Will create `fritzbox_device` metrics. + +`wan` : Collect generic WAN connection status like bit rates, transferred +bytes for the configured devices. Will create `fritzbox_wan`metrics. + +`ppp` : Collect PPP connection parameters like bit rates, uptime for the +configured devices. Will create `fritzbox_ppp` metrics. + +`dsl` : Collect DSL line status and statistics for the configured devices. +Will create `fritzbox_dsl` metrics. + +`wlan` : Collect status and number of associated devices for all WLANs. +Will create `fritzbox_wlan` metrics. + +`hosts` : Collect detailed information of the mesh network including +connected nodes, there role in the network as well as their connection +bandwidth. Will create `fritzbox_hosts` metrics. + +> [!NOTE] Collecting `hosts` metrics is time consuming and 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. + +## Metrics + +By default field names are directly derived from the corresponding [interface +specification][tr064]. + +- `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 + +```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 +``` diff --git a/plugins/inputs/fritzbox/fritzbox.go b/plugins/inputs/fritzbox/fritzbox.go new file mode 100644 index 000000000..4fbfe4597 --- /dev/null +++ b/plugins/inputs/fritzbox/fritzbox.go @@ -0,0 +1,413 @@ +//go:generate ../../../tools/readme_config_includer/generator +package fritzbox + +import ( + _ "embed" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "strconv" + "sync" + "time" + + "github.com/google/uuid" + "github.com/tdrn-org/go-tr064" + "github.com/tdrn-org/go-tr064/mesh" + "github.com/tdrn-org/go-tr064/services/igddesc/igdicfg" + "github.com/tdrn-org/go-tr064/services/tr64desc/deviceinfo" + "github.com/tdrn-org/go-tr064/services/tr64desc/hosts" + "github.com/tdrn-org/go-tr064/services/tr64desc/wancommonifconfig" + "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/influxdata/telegraf" + "github.com/influxdata/telegraf/config" + "github.com/influxdata/telegraf/plugins/common/tls" + "github.com/influxdata/telegraf/plugins/inputs" +) + +//go:embed sample.conf +var sampleConfig string + +type serviceHandlerFunc func(telegraf.Accumulator, *tr064.Client, tr064.ServiceDescriptor) error + +type Fritzbox struct { + URLs []string `toml:"urls"` + Collect []string `toml:"collect"` + Timeout config.Duration `toml:"timeout"` + Log telegraf.Logger `toml:"-"` + tls.ClientConfig + + deviceClients []*tr064.Client + serviceHandlers map[string]serviceHandlerFunc +} + +func (*Fritzbox) SampleConfig() string { + return sampleConfig +} + +func (f *Fritzbox) Init() error { + // No need to run without any devices configured + if len(f.URLs) == 0 { + return errors.New("no device URLs configured") + } + + // Use default collect options if nothing is configured + if len(f.Collect) == 0 { + f.Collect = []string{"device", "wan", "ppp", "dsl", "wlan"} + } + + // Setup TLS + tlsConfig, err := f.TLSConfig() + if err != nil { + return fmt.Errorf("initializing TLS configuration failed: %w", err) + } + + // Initialize the device clients + debug := f.Log.Level().Includes(telegraf.Trace) + f.deviceClients = make([]*tr064.Client, 0, len(f.URLs)) + for _, rawUrl := range f.URLs { + parsedUrl, err := url.Parse(rawUrl) + if err != nil { + return fmt.Errorf("parsing device URL %q failed: %w", rawUrl, err) + } + client := tr064.NewClient(parsedUrl) + client.Debug = debug + client.Timeout = time.Duration(f.Timeout) + client.TlsConfig = tlsConfig + f.deviceClients = append(f.deviceClients, client) + } + + // Initialize the service handlers + f.serviceHandlers = make(map[string]serviceHandlerFunc, len(f.Collect)) + for _, c := range f.Collect { + switch c { + case "device": + f.serviceHandlers[deviceinfo.ServiceShortType] = f.gatherDeviceInfo + case "wan": + f.serviceHandlers[wancommonifconfig.ServiceShortType] = f.gatherWanInfo + case "ppp": + f.serviceHandlers[wanpppconn.ServiceShortType] = f.gatherPppInfo + case "dsl": + f.serviceHandlers[wandslifconfig.ServiceShortType] = f.gatherDslInfo + case "wlan": + f.serviceHandlers[wlanconfig.ServiceShortType] = f.gatherWlanInfo + case "hosts": + f.serviceHandlers[hosts.ServiceShortType] = f.gatherHostsInfo + default: + return fmt.Errorf("invalid service %q in collect parameter", c) + } + } + + return nil +} + +func (f *Fritzbox) Gather(acc telegraf.Accumulator) error { + var wg sync.WaitGroup + for _, deviceClient := range f.deviceClients { + wg.Add(1) + // Pass deviceClient as parameter to avoid any race conditions + go func(client *tr064.Client) { + defer wg.Done() + f.gatherDevice(acc, client) + }(deviceClient) + } + wg.Wait() + return nil +} + +func (f *Fritzbox) gatherDevice(acc telegraf.Accumulator, deviceClient *tr064.Client) { + services, err := deviceClient.Services(tr064.DefaultServiceSpec) + if err != nil { + acc.AddError(err) + return + } + for _, service := range services { + serviceHandler, exists := f.serviceHandlers[service.ShortType()] + // If no serviceHandler has been setup during Init(), we ignore this service. + if !exists { + continue + } + acc.AddError(serviceHandler(acc, deviceClient, service)) + } +} + +func (f *Fritzbox) gatherDeviceInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := deviceinfo.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &deviceinfo.GetInfoResponse{} + if err := serviceClient.GetInfo(info); err != nil { + return fmt.Errorf("failed to query device info: %w", err) + } + tags := map[string]string{ + "source": serviceClient.TR064Client.DeviceUrl.Hostname(), + "service": serviceClient.Service.ShortId(), + } + fields := map[string]interface{}{ + "uptime": info.NewUpTime, + "model_name": info.NewModelName, + "serial_number": info.NewSerialNumber, + "hardware_version": info.NewHardwareVersion, + "software_version": info.NewSoftwareVersion, + } + acc.AddFields("fritzbox_device", fields, tags) + return nil +} + +func (f *Fritzbox) gatherWanInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wancommonifconfig.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + commonLinkProperties := &wancommonifconfig.GetCommonLinkPropertiesResponse{} + if err := serviceClient.GetCommonLinkProperties(commonLinkProperties); err != nil { + return fmt.Errorf("failed to query link properties: %w", err) + } + // Prefer igdicfg service over wancommonifconfig service for total bytes stats, because igdicfg supports uint64 counters + igdServices, err := deviceClient.ServicesByType(tr064.IgdServiceSpec, igdicfg.ServiceShortType) + if err != nil { + return fmt.Errorf("failed to lookup IGD service: %w", err) + } + var totalBytesSent uint64 = 0 + var totalBytesReceived uint64 = 0 + if len(igdServices) > 0 { + igdServiceClient := &igdicfg.ServiceClient{ + TR064Client: deviceClient, + Service: igdServices[0], + } + addonInfos := &igdicfg.GetAddonInfosResponse{} + if err = igdServiceClient.GetAddonInfos(addonInfos); err != nil { + return fmt.Errorf("failed to query addon info: %w", err) + } + totalBytesSent, err = strconv.ParseUint(addonInfos.NewX_AVM_DE_TotalBytesSent64, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse total bytes sent: %w", err) + } + totalBytesReceived, err = strconv.ParseUint(addonInfos.NewX_AVM_DE_TotalBytesReceived64, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse total bytes received: %w", err) + } + } else { + // Fall back to wancommonifconfig service in case igdicfg is not available (only uint32 based) + totalBytesSentResponse := &wancommonifconfig.GetTotalBytesSentResponse{} + if err = serviceClient.GetTotalBytesSent(totalBytesSentResponse); err != nil { + return fmt.Errorf("failed to query bytes sent: %w", err) + } + totalBytesSent = uint64(totalBytesSentResponse.NewTotalBytesSent) + totalBytesReceivedResponse := &wancommonifconfig.GetTotalBytesReceivedResponse{} + if err = serviceClient.GetTotalBytesReceived(totalBytesReceivedResponse); err != nil { + return fmt.Errorf("failed to query bytes received: %w", err) + } + totalBytesReceived = uint64(totalBytesReceivedResponse.NewTotalBytesReceived) + } + tags := map[string]string{ + "source": serviceClient.TR064Client.DeviceUrl.Hostname(), + "service": serviceClient.Service.ShortId(), + } + fields := map[string]interface{}{ + "layer1_upstream_max_bit_rate": commonLinkProperties.NewLayer1UpstreamMaxBitRate, + "layer1_downstream_max_bit_rate": commonLinkProperties.NewLayer1DownstreamMaxBitRate, + "upstream_current_max_speed": commonLinkProperties.NewX_AVM_DE_UpstreamCurrentMaxSpeed, + "downstream_current_max_speed": commonLinkProperties.NewX_AVM_DE_DownstreamCurrentMaxSpeed, + "total_bytes_sent": totalBytesSent, + "total_bytes_received": totalBytesReceived, + } + acc.AddFields("fritzbox_wan", fields, tags) + return nil +} + +func (f *Fritzbox) gatherPppInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wanpppconn.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &wanpppconn.GetInfoResponse{} + if err := serviceClient.GetInfo(info); err != nil { + return fmt.Errorf("failed to query PPP info: %w", err) + } + tags := map[string]string{ + "source": serviceClient.TR064Client.DeviceUrl.Hostname(), + "service": serviceClient.Service.ShortId(), + } + fields := map[string]interface{}{ + "uptime": info.NewUptime, + "upstream_max_bit_rate": info.NewUpstreamMaxBitRate, + "downstream_max_bit_rate": info.NewDownstreamMaxBitRate, + } + acc.AddFields("fritzbox_ppp", fields, tags) + return nil +} + +func (f *Fritzbox) gatherDslInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wandslifconfig.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &wandslifconfig.GetInfoResponse{} + if err := serviceClient.GetInfo(info); err != nil { + return fmt.Errorf("failed to query DSL info: %w", err) + } + statisticsTotal := &wandslifconfig.GetStatisticsTotalResponse{} + if info.NewStatus == "Up" { + if err := serviceClient.GetStatisticsTotal(statisticsTotal); err != nil { + return fmt.Errorf("failed to query DSL statistics: %w", err) + } + } + tags := map[string]string{ + "source": serviceClient.TR064Client.DeviceUrl.Hostname(), + "service": serviceClient.Service.ShortId(), + "status": info.NewStatus, + } + fields := map[string]interface{}{ + "upstream_curr_rate": info.NewUpstreamCurrRate, + "downstream_curr_rate": info.NewDownstreamCurrRate, + "upstream_max_rate": info.NewUpstreamMaxRate, + "downstream_max_rate": info.NewDownstreamMaxRate, + "upstream_noise_margin": info.NewUpstreamNoiseMargin, + "downstream_noise_margin": info.NewDownstreamNoiseMargin, + "upstream_attenuation": info.NewUpstreamAttenuation, + "downstream_attenuation": info.NewDownstreamAttenuation, + "upstream_power": info.NewUpstreamPower, + "downstream_power": info.NewDownstreamPower, + "receive_blocks": statisticsTotal.NewReceiveBlocks, + "transmit_blocks": statisticsTotal.NewTransmitBlocks, + "cell_delin": statisticsTotal.NewCellDelin, + "link_retrain": statisticsTotal.NewLinkRetrain, + "init_errors": statisticsTotal.NewInitErrors, + "init_timeouts": statisticsTotal.NewInitTimeouts, + "loss_of_framing": statisticsTotal.NewLossOfFraming, + "errored_secs": statisticsTotal.NewErroredSecs, + "severly_errored_secs": statisticsTotal.NewSeverelyErroredSecs, + "fec_errors": statisticsTotal.NewFECErrors, + "atuc_fec_errors": statisticsTotal.NewATUCFECErrors, + "hec_errors": statisticsTotal.NewHECErrors, + "atuc_hec_errors": statisticsTotal.NewATUCHECErrors, + "crc_errors": statisticsTotal.NewCRCErrors, + "atuc_crc_errors": statisticsTotal.NewATUCCRCErrors, + } + acc.AddFields("fritzbox_dsl", fields, tags) + return nil +} + +func (f *Fritzbox) gatherWlanInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wlanconfig.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &wlanconfig.GetInfoResponse{} + if err := serviceClient.GetInfo(info); err != nil { + return fmt.Errorf("failed to query WLAN info: %w", err) + } + totalAssociations := &wlanconfig.GetTotalAssociationsResponse{} + if info.NewStatus == "Up" { + if err := serviceClient.GetTotalAssociations(totalAssociations); err != nil { + return fmt.Errorf("failed to query WLAN associations: %w", err) + } + } + tags := map[string]string{ + "source": serviceClient.TR064Client.DeviceUrl.Hostname(), + "service": serviceClient.Service.ShortId(), + "status": info.NewStatus, + "ssid": info.NewSSID, + "channel": strconv.Itoa(int(info.NewChannel)), + "band": f.wlanBandFromInfo(info), + } + fields := map[string]interface{}{ + "total_associations": totalAssociations.NewTotalAssociations, + } + acc.AddGauge("fritzbox_wlan", fields, tags) + return nil +} + +func (f *Fritzbox) wlanBandFromInfo(info *wlanconfig.GetInfoResponse) string { + band := info.NewX_AVM_DE_FrequencyBand + if band != "" { + return band + } + if 1 <= info.NewChannel && info.NewChannel <= 14 { + return "2400" + } + return "5000" +} + +func (f *Fritzbox) gatherHostsInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := hosts.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + connections, err := f.fetchHostsConnections(&serviceClient) + if err != nil { + return fmt.Errorf("failed to fetch hosts connections: %w", err) + } + for _, connection := range connections { + // Ignore ephemeral UUID style device names + _, err = uuid.Parse(connection.RightDeviceName) + if err == nil { + continue + } + tags := map[string]string{ + "source": serviceClient.TR064Client.DeviceUrl.Hostname(), + "service": serviceClient.Service.ShortId(), + "node": connection.RightDeviceName, + "node_role": f.hostRole(connection.RightMeshRole), + "node_ap": connection.LeftDeviceName, + "node_ap_role": f.hostRole(connection.LeftMeshRole), + "link_type": connection.InterfaceType, + "link_name": connection.InterfaceName, + } + fields := map[string]interface{}{ + "max_data_rate_tx": connection.MaxDataRateTx, + "max_data_rate_rx": connection.MaxDataRateRx, + "cur_data_rate_tx": connection.CurDataRateTx, + "cur_data_rate_rx": connection.CurDataRateRx, + } + acc.AddGauge("fritzbox_hosts", fields, tags) + } + return nil +} + +func (f *Fritzbox) hostRole(role string) string { + if role == "unknown" { + return "client" + } + return role +} + +func (f *Fritzbox) fetchHostsConnections(serviceClient *hosts.ServiceClient) ([]*mesh.Connection, error) { + meshListPath := &hosts.X_AVM_DE_GetMeshListPathResponse{} + if err := serviceClient.X_AVM_DE_GetMeshListPath(meshListPath); err != nil { + return nil, fmt.Errorf("failed to query mesh list path: %w", err) + } + meshListResponse, err := serviceClient.TR064Client.Get(meshListPath.NewX_AVM_DE_MeshListPath) + if err != nil { + return nil, fmt.Errorf("failed to access mesh list %q: %w", meshListPath.NewX_AVM_DE_MeshListPath, err) + } + if meshListResponse.StatusCode == http.StatusNotFound { + return make([]*mesh.Connection, 0), nil + } + if meshListResponse.StatusCode != http.StatusOK { + return nil, fmt.Errorf("failed to fetch mesh list %q: %s", meshListPath.NewX_AVM_DE_MeshListPath, meshListResponse.Status) + } + defer meshListResponse.Body.Close() + meshListBytes, err := io.ReadAll(meshListResponse.Body) + if err != nil { + return nil, fmt.Errorf("failed to read mesh list: %w", err) + } + meshList := &mesh.List{} + if json.Unmarshal(meshListBytes, meshList); err != nil { + return nil, fmt.Errorf("failed to parse mesh list: %w", err) + } + return meshList.Connections(), nil +} + +func init() { + inputs.Add("fritzbox", func() telegraf.Input { + return &Fritzbox{Timeout: config.Duration(10 * time.Second)} + }) +} diff --git a/plugins/inputs/fritzbox/fritzbox_test.go b/plugins/inputs/fritzbox/fritzbox_test.go new file mode 100644 index 000000000..50788cf81 --- /dev/null +++ b/plugins/inputs/fritzbox/fritzbox_test.go @@ -0,0 +1,148 @@ +package fritzbox + +import ( + "os" + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/require" + "github.com/tdrn-org/go-tr064/mock" + + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/config" + "github.com/influxdata/telegraf/plugins/inputs" + "github.com/influxdata/telegraf/plugins/parsers/influx" + "github.com/influxdata/telegraf/testutil" +) + +func TestValidDefaultConfig(t *testing.T) { + // Verify plugin can be loaded from config + conf := config.NewConfig() + require.NoError(t, conf.LoadConfig("sample.conf")) + require.Len(t, conf.Inputs, 1) + f, ok := conf.Inputs[0].Input.(*Fritzbox) + require.True(t, ok) + + // Verify successful Init + require.NoError(t, f.Init()) + + // Verify everything is setup according to plugin defaults + require.ElementsMatch(t, []string{"http://user:password@fritz.box:49000/"}, f.URLs) + require.Equal(t, []string{"device", "wan", "ppp", "dsl", "wlan"}, f.Collect) + require.Equal(t, config.Duration(10*time.Second), f.Timeout) + require.Empty(t, f.TLSKeyPwd) + require.False(t, f.InsecureSkipVerify) +} + +func TestValidCustomConfig(t *testing.T) { + // Verify plugin can be loaded from config + conf := config.NewConfig() + require.NoError(t, conf.LoadConfig("testdata/conf/valid.conf")) + require.Len(t, conf.Inputs, 1) + f, ok := conf.Inputs[0].Input.(*Fritzbox) + require.True(t, ok) + + // Verify successful Init + require.NoError(t, f.Init()) + + // Verify everything is setup according to the config file + require.ElementsMatch(t, []string{"http://boxuser:boxpassword@fritz.box:49000/", "http://:repeaterpassword@fritz.repeater:49000/"}, f.URLs) + require.Equal(t, []string{"device", "wan", "ppp", "dsl", "wlan", "hosts"}, f.Collect) + require.Equal(t, config.Duration(60*time.Second), f.Timeout) + require.Equal(t, "secret", f.TLSKeyPwd) + require.True(t, f.InsecureSkipVerify) +} + +func TestInvalidURLsConfig(t *testing.T) { + // Verify plugin can be loaded from config + conf := config.NewConfig() + require.NoError(t, conf.LoadConfig("testdata/conf/invalid_urls.conf")) + require.Len(t, conf.Inputs, 1) + f, ok := conf.Inputs[0].Input.(*Fritzbox) + require.True(t, ok) + + // Verify Init failure + require.EqualError(t, f.Init(), `parsing device URL "::" failed: parse "::": missing protocol scheme`) +} + +func TestInvalidCollectConfig(t *testing.T) { + // Verify plugin can be loaded from config + conf := config.NewConfig() + require.NoError(t, conf.LoadConfig("testdata/conf/invalid_collect.conf")) + require.Len(t, conf.Inputs, 1) + f, ok := conf.Inputs[0].Input.(*Fritzbox) + require.True(t, ok) + + // Verify Init failure + require.EqualError(t, f.Init(), `invalid service "undefined" in collect parameter`) +} + +func TestCases(t *testing.T) { + // Get all testcase directories + testcases, err := os.ReadDir("testdata/testcases") + require.NoError(t, err) + + // Register the plugin + inputs.Add("fritzbox", func() telegraf.Input { + return &Fritzbox{Timeout: config.Duration(10 * time.Second)} + }) + + for _, testcase := range testcases { + // Only handle folders + if !testcase.IsDir() { + continue + } + + t.Run(testcase.Name(), func(t *testing.T) { + testcaseDir := filepath.Join("testdata/testcases", testcase.Name()) + configFile := filepath.Join(testcaseDir, "telegraf.conf") + mockDir := filepath.Join(testcaseDir, "mock") + expectedMetricsFile := filepath.Join(testcaseDir, "expected.out") + + // Setup the services to mock (one per sub-folder of mockDir) + services, err := os.ReadDir(mockDir) + require.NoError(t, err) + serviceMocks := make([]*mock.ServiceMock, 0, len(services)) + for _, service := range services { + // Ignore the mock files + if !testcase.IsDir() { + continue + } + serviceMock := mock.ServiceMockFromFile("/"+service.Name(), filepath.Join(mockDir, service.Name(), "response.xml")) + serviceMocks = append(serviceMocks, serviceMock) + } + + // Start testcase mock server + tr064Server := mock.Start(mockDir, serviceMocks...) + defer tr064Server.Shutdown() + + // Load plugin from config + conf := config.NewConfig() + require.NoError(t, conf.LoadConfig(configFile)) + require.Len(t, conf.Inputs, 1) + f, ok := conf.Inputs[0].Input.(*Fritzbox) + require.True(t, ok) + + // Target plugin at mock server + f.URLs = []string{tr064Server.Server().String()} + f.Log = &testutil.Logger{Name: "fritzbox"} + + // Verify successful Init + require.NoError(t, f.Init()) + + // Verify successfull Gather + acc := &testutil.Accumulator{} + require.NoError(t, acc.GatherError(f.Gather)) + + // Load expexected metrics + parser := &influx.Parser{} + require.NoError(t, parser.Init()) + expectedMetrics, err := testutil.ParseMetricsFromFile(expectedMetricsFile, parser) + require.NoError(t, err) + + // Verify metrics are as expected + testutil.RequireMetricsEqual(t, expectedMetrics, acc.GetTelegrafMetrics(), testutil.IgnoreTime(), testutil.IgnoreType(), testutil.SortMetrics()) + }) + } +} diff --git a/plugins/inputs/fritzbox/sample.conf b/plugins/inputs/fritzbox/sample.conf new file mode 100644 index 000000000..2477fe6d5 --- /dev/null +++ b/plugins/inputs/fritzbox/sample.conf @@ -0,0 +1,24 @@ +# Gather fritzbox status +[[inputs.fritzbox]] + ## URLs of the devices to query including login credentials + urls = [ "http://user:password@fritz.box:49000/" ] + + ## 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" + # tls_key_pwd = "secret" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false diff --git a/plugins/inputs/fritzbox/testdata/conf/invalid_collect.conf b/plugins/inputs/fritzbox/testdata/conf/invalid_collect.conf new file mode 100644 index 000000000..751872053 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/conf/invalid_collect.conf @@ -0,0 +1,18 @@ +# Gather fritzbox status +[[inputs.fritzbox]] + ## URLs of the devices to query including login credentials + urls = [ "http://user:password@fritz.box:49000/" ] + + ## The information to collect (see README for further details). + collect = [ "undefined" ] + + ## 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" + # tls_key_pwd = "secret" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false diff --git a/plugins/inputs/fritzbox/testdata/conf/invalid_urls.conf b/plugins/inputs/fritzbox/testdata/conf/invalid_urls.conf new file mode 100644 index 000000000..b176b3f76 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/conf/invalid_urls.conf @@ -0,0 +1,24 @@ +# Gather fritzbox status +[[inputs.fritzbox]] + ## URLs of the devices to query including login credentials + urls = [ "http://user:password@fritz.box:49000/", "::" ] + + ## 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" + # tls_key_pwd = "secret" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false diff --git a/plugins/inputs/fritzbox/testdata/conf/valid.conf b/plugins/inputs/fritzbox/testdata/conf/valid.conf new file mode 100644 index 000000000..8aabfe441 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/conf/valid.conf @@ -0,0 +1,28 @@ +# Gather fritzbox status +[[inputs.fritzbox]] + ## URLs of the devices to query including login credentials + urls = [ + "http://boxuser:boxpassword@fritz.box:49000/", + "http://:repeaterpassword@fritz.repeater:49000/", + ] + + ## The information to collect (see README for further details). + collect = [ + "device", + "wan", + "ppp", + "dsl", + "wlan", + "hosts", + ] + + ## The http timeout to use. + timeout = "1m" + + ## Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + tls_key_pwd = "secret" + ## Use TLS but skip chain & host verification + insecure_skip_verify = true diff --git a/plugins/inputs/fritzbox/testdata/testcases/device/expected.out b/plugins/inputs/fritzbox/testdata/testcases/device/expected.out new file mode 100644 index 000000000..7c723f0e9 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/device/expected.out @@ -0,0 +1 @@ +fritzbox_device,service=DeviceInfo1,source=127.0.0.1 hardware_version="Mock 1234",model_name="Mock 1234",serial_number="123456789",software_version="1.02.03",uptime=2058438u 1737088489284767000 diff --git a/plugins/inputs/fritzbox/testdata/testcases/device/mock/deviceinfo/response.xml b/plugins/inputs/fritzbox/testdata/testcases/device/mock/deviceinfo/response.xml new file mode 100644 index 000000000..3d3ad9dc7 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/device/mock/deviceinfo/response.xml @@ -0,0 +1,19 @@ + + + + +AVM +00000E +Mock 1234 +Mock 1234 Release 1.02.03 +MOCK1234 +123456789 +1.02.03 +Mock 1234 +1.0 +000.000.000.000 +2058438 + + + + diff --git a/plugins/inputs/fritzbox/testdata/testcases/device/mock/dummySCPD.xml b/plugins/inputs/fritzbox/testdata/testcases/device/mock/dummySCPD.xml new file mode 100644 index 000000000..5f4787762 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/device/mock/dummySCPD.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/device/mock/tr64desc.xml b/plugins/inputs/fritzbox/testdata/testcases/device/mock/tr64desc.xml new file mode 100644 index 000000000..9d393dc1a --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/device/mock/tr64desc.xml @@ -0,0 +1,13 @@ + + + + + urn:dslforum-org:service:DeviceInfo:1 + urn:DeviceInfo-com:serviceId:DeviceInfo1 + /deviceinfo + /dummySCPD.xml + + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/device/telegraf.conf b/plugins/inputs/fritzbox/testdata/testcases/device/telegraf.conf new file mode 100644 index 000000000..ad715faf4 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/device/telegraf.conf @@ -0,0 +1,6 @@ +[[inputs.fritzbox]] + ## URLs are set dynamically by test + # urls = [ ] + collect = [ "device" ] + # everything else stays at defaults + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/dsl/expected.out b/plugins/inputs/fritzbox/testdata/testcases/dsl/expected.out new file mode 100644 index 000000000..891f1bdcd --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/dsl/expected.out @@ -0,0 +1 @@ +fritzbox_dsl,service=WANDSLInterfaceConfig1,source=127.0.0.1,status=Up atuc_crc_errors=13u,atuc_fec_errors=0u,atuc_hec_errors=0u,cell_delin=0u,crc_errors=53u,downstream_attenuation=140u,downstream_curr_rate=249065u,downstream_max_rate=249065u,downstream_noise_margin=60u,downstream_power=513u,errored_secs=25u,fec_errors=0u,hec_errors=0u,init_errors=0u,init_timeouts=0u,link_retrain=2u,loss_of_framing=0u,receive_blocks=490282831u,severly_errored_secs=0u,transmit_blocks=254577751u,upstream_attenuation=80u,upstream_curr_rate=46719i,upstream_max_rate=48873u,upstream_noise_margin=80u,upstream_power=498u 1737088741855188000 diff --git a/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/dummySCPD.xml b/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/dummySCPD.xml new file mode 100644 index 000000000..5f4787762 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/dummySCPD.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/tr64desc.xml b/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/tr64desc.xml new file mode 100644 index 000000000..5830a9adc --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/tr64desc.xml @@ -0,0 +1,13 @@ + + + + + urn:dslforum-org:service:WANDSLInterfaceConfig:1 + urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1 + /wandslifconfig + /dummySCPD.xml + + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/wandslifconfig/response.xml b/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/wandslifconfig/response.xml new file mode 100644 index 000000000..34ca377ce --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/dsl/mock/wandslifconfig/response.xml @@ -0,0 +1,39 @@ + + + + +1 +Up +Fast +46719 +249065 +48873 +249065 +80 +60 +80 +140 +41564d00 +0400 +498 +513 + + +490282831 +254577751 +0 +2 +0 +0 +0 +25 +0 +0 +0 +0 +0 +53 +13 + + + diff --git a/plugins/inputs/fritzbox/testdata/testcases/dsl/telegraf.conf b/plugins/inputs/fritzbox/testdata/testcases/dsl/telegraf.conf new file mode 100644 index 000000000..f1587b043 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/dsl/telegraf.conf @@ -0,0 +1,6 @@ +[[inputs.fritzbox]] + ## URLs are set dynamically by test + # urls = [ ] + collect = [ "dsl" ] + # everything else stays at defaults + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/hosts/expected.out b/plugins/inputs/fritzbox/testdata/testcases/hosts/expected.out new file mode 100644 index 000000000..7a5bc13dc --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/hosts/expected.out @@ -0,0 +1,21 @@ +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=127.0.0.1 cur_data_rate_rx=216000i,cur_data_rate_tx=216000i,max_data_rate_rx=216000i,max_data_rate_tx=216000i 1737063884317915000 +fritzbox_hosts,node=device#17,node_ap=device#1,node_ap_role=master,node_role=slave,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=1300000i,cur_data_rate_tx=975000i,max_data_rate_rx=1300000i,max_data_rate_tx=1300000i 1737063884317962000 +fritzbox_hosts,node=device#4,node_ap=device#1,node_ap_role=master,node_role=client,link_name=LAN:1,link_type=LAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=1000000i,cur_data_rate_tx=1000000i,max_data_rate_rx=1000000i,max_data_rate_tx=1000000i 1737063884317976000 +fritzbox_hosts,node=device#26,node_ap=device#1,node_ap_role=master,node_role=client,link_name=LAN:2,link_type=LAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=1000000i,cur_data_rate_tx=1000000i,max_data_rate_rx=1000000i,max_data_rate_tx=1000000i 1737063884317992000 +fritzbox_hosts,node=device#2,node_ap=device#1,node_ap_role=master,node_role=client,link_name=LAN:3,link_type=LAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=100000i,cur_data_rate_tx=100000i,max_data_rate_rx=100000i,max_data_rate_tx=100000i 1737063884318005000 +fritzbox_hosts,node=device#3,node_ap=device#1,node_ap_role=master,node_role=client,link_name=LAN:4,link_type=LAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=100000i,cur_data_rate_tx=100000i,max_data_rate_rx=100000i,max_data_rate_tx=100000i 1737063884318018000 +fritzbox_hosts,node=device#14,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:2G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=65000i,cur_data_rate_tx=72000i,max_data_rate_rx=72200i,max_data_rate_tx=72200i 1737063884318031000 +fritzbox_hosts,node=device#5,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:2G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=72000i,cur_data_rate_tx=72000i,max_data_rate_rx=72200i,max_data_rate_tx=72200i 1737063884318043000 +fritzbox_hosts,node=device#11,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=390000i,cur_data_rate_tx=433000i,max_data_rate_rx=433300i,max_data_rate_tx=433300i 1737063884318065000 +fritzbox_hosts,node=device#11,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=585000i,cur_data_rate_tx=866000i,max_data_rate_rx=866700i,max_data_rate_tx=866700i 1737063884318082000 +fritzbox_hosts,node=device#16,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=866000i,cur_data_rate_tx=866000i,max_data_rate_rx=866700i,max_data_rate_tx=866700i 1737063884318118000 +fritzbox_hosts,node=device#18,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=526000i,cur_data_rate_tx=780000i,max_data_rate_rx=866700i,max_data_rate_tx=866700i 1737063884318140000 +fritzbox_hosts,node=device#19,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=650000i,cur_data_rate_tx=1170000i,max_data_rate_rx=1733300i,max_data_rate_tx=1733300i 1737063884318153000 +fritzbox_hosts,node=device#7,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=780000i,cur_data_rate_tx=866000i,max_data_rate_rx=866700i,max_data_rate_tx=866700i 1737063884318166000 +fritzbox_hosts,node=device#8,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=390000i,cur_data_rate_tx=433000i,max_data_rate_rx=433300i,max_data_rate_tx=433300i 1737063884318179000 +fritzbox_hosts,node=device#9,node_ap=device#1,node_ap_role=master,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=390000i,cur_data_rate_tx=433000i,max_data_rate_rx=433300i,max_data_rate_tx=433300i 1737063884318192000 +fritzbox_hosts,node=device#13,node_ap=device#17,node_ap_role=slave,node_role=client,link_name=LAN:1,link_type=LAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=0i,cur_data_rate_tx=0i,max_data_rate_rx=1000000i,max_data_rate_tx=1000000i 1737063884318215000 +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=127.0.0.1 cur_data_rate_rx=0i,cur_data_rate_tx=0i,max_data_rate_rx=1000000i,max_data_rate_tx=1000000i 1737063884318233000 +fritzbox_hosts,node=device#6,node_ap=device#17,node_ap_role=slave,node_role=client,link_name=AP:2G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=72200i,cur_data_rate_tx=72000i,max_data_rate_rx=72000i,max_data_rate_tx=72000i 1737063884318251000 +fritzbox_hosts,node=device#10,node_ap=device#17,node_ap_role=slave,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=866700i,cur_data_rate_tx=866000i,max_data_rate_rx=866000i,max_data_rate_tx=866000i 1737063884318263000 +fritzbox_hosts,node=device#22,node_ap=device#17,node_ap_role=slave,node_role=client,link_name=AP:5G:0,link_type=WLAN,service=Hosts1,source=127.0.0.1 cur_data_rate_rx=866700i,cur_data_rate_tx=866000i,max_data_rate_rx=866000i,max_data_rate_tx=866000i 1737063884318275000 diff --git a/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/dummySCPD.xml b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/dummySCPD.xml new file mode 100644 index 000000000..5f4787762 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/dummySCPD.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/hosts/response.xml b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/hosts/response.xml new file mode 100644 index 000000000..cde36d58d --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/hosts/response.xml @@ -0,0 +1,8 @@ + + + + +/meshlist.json?sid=123456789abcdef + + + diff --git a/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/meshlist.json b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/meshlist.json new file mode 100644 index 000000000..87c29ccd2 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/meshlist.json @@ -0,0 +1,1177 @@ +{ + "schema_version": "7.8", + "nodes": [ + { + "uid": "n-1", + "device_name": "device#1", + "is_meshed": true, + "mesh_role": "master", + "node_interfaces": [ + { + "uid": "ni-6", + "name": "LANBridge", + "type": "LAN", + "node_links": [] + }, + { + "uid": "ni-17", + "name": "LAN:2", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-286", + "node_interface_1_uid": "ni-17", + "node_interface_2_uid": "ni-287", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 1000000, + "cur_data_rate_tx": 1000000 + } + ] + }, + { + "uid": "ni-43", + "name": "LAN:1", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-54", + "node_interface_1_uid": "ni-43", + "node_interface_2_uid": "ni-55", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 1000000, + "cur_data_rate_tx": 1000000 + } + ] + }, + { + "uid": "ni-47", + "name": "LAN:3", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-50", + "node_interface_1_uid": "ni-47", + "node_interface_2_uid": "ni-51", + "max_data_rate_rx": 100000, + "max_data_rate_tx": 100000, + "cur_data_rate_rx": 100000, + "cur_data_rate_tx": 100000 + } + ] + }, + { + "uid": "ni-48", + "name": "LAN:4", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-52", + "node_interface_1_uid": "ni-48", + "node_interface_2_uid": "ni-53", + "max_data_rate_rx": 100000, + "max_data_rate_tx": 100000, + "cur_data_rate_rx": 100000, + "cur_data_rate_tx": 100000 + } + ] + }, + { + "uid": "ni-49", + "name": "WAN:1", + "type": "LAN", + "node_links": [] + }, + { + "uid": "ni-59", + "name": "AP:2G:0", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-81", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-82", + "max_data_rate_rx": 72200, + "max_data_rate_tx": 72200, + "cur_data_rate_rx": 72000, + "cur_data_rate_tx": 72000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-110", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-252", + "max_data_rate_rx": 216000, + "max_data_rate_tx": 216000, + "cur_data_rate_rx": 216000, + "cur_data_rate_tx": 216000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-205", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-206", + "max_data_rate_rx": 72200, + "max_data_rate_tx": 72200, + "cur_data_rate_rx": 65000, + "cur_data_rate_tx": 72000 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + }, + { + "uid": "ni-60", + "name": "AP:5G:0", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-217", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-218", + "max_data_rate_rx": 1733300, + "max_data_rate_tx": 1733300, + "cur_data_rate_rx": 650000, + "cur_data_rate_tx": 1170000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-106", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-107", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 780000, + "cur_data_rate_tx": 866000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-110", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-251", + "max_data_rate_rx": 1300000, + "max_data_rate_tx": 1300000, + "cur_data_rate_rx": 1300000, + "cur_data_rate_tx": 975000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-199", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-200", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 526000, + "cur_data_rate_tx": 780000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-100", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-101", + "max_data_rate_rx": 433300, + "max_data_rate_tx": 433300, + "cur_data_rate_rx": 390000, + "cur_data_rate_tx": 433000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 585000, + "cur_data_rate_tx": 866000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-210", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-211", + "max_data_rate_rx": 433300, + "max_data_rate_tx": 433300, + "cur_data_rate_rx": 390000, + "cur_data_rate_tx": 433000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-148", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-149", + "max_data_rate_rx": 433300, + "max_data_rate_tx": 433300, + "cur_data_rate_rx": 390000, + "cur_data_rate_tx": 433000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 866000, + "cur_data_rate_tx": 866000 + } + ] + } + ] + }, + { + "uid": "n-50", + "device_name": "device#2", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-51", + "name": "", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-50", + "node_interface_1_uid": "ni-47", + "node_interface_2_uid": "ni-51", + "max_data_rate_rx": 100000, + "max_data_rate_tx": 100000, + "cur_data_rate_rx": 100000, + "cur_data_rate_tx": 100000 + } + ] + } + ] + }, + { + "uid": "n-52", + "device_name": "device#3", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-53", + "name": "", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-52", + "node_interface_1_uid": "ni-48", + "node_interface_2_uid": "ni-53", + "max_data_rate_rx": 100000, + "max_data_rate_tx": 100000, + "cur_data_rate_rx": 100000, + "cur_data_rate_tx": 100000 + } + ] + } + ] + }, + { + "uid": "n-54", + "device_name": "device#4", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-55", + "name": "", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-54", + "node_interface_1_uid": "ni-43", + "node_interface_2_uid": "ni-55", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 1000000, + "cur_data_rate_tx": 1000000 + } + ] + } + ] + }, + { + "uid": "n-81", + "device_name": "device#5", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-82", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-81", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-82", + "max_data_rate_rx": 72200, + "max_data_rate_tx": 72200, + "cur_data_rate_rx": 72000, + "cur_data_rate_tx": 72000 + } + ] + } + ] + }, + { + "uid": "n-92", + "device_name": "device#6", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-93", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-92", + "node_interface_1_uid": "ni-254", + "node_interface_2_uid": "ni-93", + "max_data_rate_rx": 72000, + "max_data_rate_tx": 72000, + "cur_data_rate_rx": 72200, + "cur_data_rate_tx": 72000 + } + ] + } + ] + }, + { + "uid": "n-106", + "device_name": "device#7", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-107", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-106", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-107", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 780000, + "cur_data_rate_tx": 866000 + } + ] + } + ] + }, + { + "uid": "n-148", + "device_name": "device#8", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-149", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-148", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-149", + "max_data_rate_rx": 433300, + "max_data_rate_tx": 433300, + "cur_data_rate_rx": 390000, + "cur_data_rate_tx": 433000 + } + ] + } + ] + }, + { + "uid": "n-210", + "device_name": "device#9", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-211", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-210", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-211", + "max_data_rate_rx": 433300, + "max_data_rate_tx": 433300, + "cur_data_rate_rx": 390000, + "cur_data_rate_tx": 433000 + } + ] + } + ] + }, + { + "uid": "n-44", + "device_name": "device#10", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-45", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-44", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-45", + "max_data_rate_rx": 866000, + "max_data_rate_tx": 866000, + "cur_data_rate_rx": 866700, + "cur_data_rate_tx": 866000 + } + ] + } + ] + }, + { + "uid": "n-100", + "device_name": "device#11", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-101", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-100", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-101", + "max_data_rate_rx": 433300, + "max_data_rate_tx": 433300, + "cur_data_rate_rx": 390000, + "cur_data_rate_tx": 433000 + } + ] + } + ] + }, + { + "uid": "n-122", + "device_name": "device#12", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-123", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-203", + "device_name": "device#13", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-204", + "name": "", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-203", + "node_interface_1_uid": "ni-89", + "node_interface_2_uid": "ni-204", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + } + ] + }, + { + "uid": "n-205", + "device_name": "device#14", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-206", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-205", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-206", + "max_data_rate_rx": 72200, + "max_data_rate_tx": 72200, + "cur_data_rate_rx": 65000, + "cur_data_rate_tx": 72000 + } + ] + } + ] + }, + { + "uid": "n-62", + "device_name": "device#15", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-67", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-178", + "device_name": "device#11", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-179", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 585000, + "cur_data_rate_tx": 866000 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-254", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + } + ] + }, + { + "uid": "n-102", + "device_name": "device#16", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-103", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-110", + "device_name": "device#17", + "is_meshed": true, + "mesh_role": "slave", + "node_interfaces": [ + { + "uid": "ni-89", + "name": "LAN:1", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-121", + "node_interface_1_uid": "ni-89", + "node_interface_2_uid": "ni-138", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-203", + "node_interface_1_uid": "ni-89", + "node_interface_2_uid": "ni-204", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + }, + { + "uid": "ni-250", + "name": "LANBridge", + "type": "LAN", + "node_links": [] + }, + { + "uid": "ni-251", + "name": "UPLINK:5G:0", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-110", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-251", + "max_data_rate_rx": 1300000, + "max_data_rate_tx": 1300000, + "cur_data_rate_rx": 1300000, + "cur_data_rate_tx": 975000 + } + ] + }, + { + "uid": "ni-252", + "name": "UPLINK:2G:0", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-110", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-252", + "max_data_rate_rx": 216000, + "max_data_rate_tx": 216000, + "cur_data_rate_rx": 216000, + "cur_data_rate_tx": 216000 + } + ] + }, + { + "uid": "ni-253", + "name": "AP:5G:0", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-196", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-207", + "max_data_rate_rx": 866000, + "max_data_rate_tx": 866000, + "cur_data_rate_rx": 866700, + "cur_data_rate_tx": 866000 + }, + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-44", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-45", + "max_data_rate_rx": 866000, + "max_data_rate_tx": 866000, + "cur_data_rate_rx": 866700, + "cur_data_rate_tx": 866000 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + }, + { + "uid": "ni-254", + "name": "AP:2G:0", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-92", + "node_interface_1_uid": "ni-254", + "node_interface_2_uid": "ni-93", + "max_data_rate_rx": 72000, + "max_data_rate_tx": 72000, + "cur_data_rate_rx": 72200, + "cur_data_rate_tx": 72000 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-254", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-178", + "node_interface_1_uid": "ni-254", + "node_interface_2_uid": "ni-179", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + } + ] + }, + { + "uid": "n-199", + "device_name": "device#18", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-200", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-199", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-200", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 526000, + "cur_data_rate_tx": 780000 + } + ] + } + ] + }, + { + "uid": "n-217", + "device_name": "device#19", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-218", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-217", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-218", + "max_data_rate_rx": 1733300, + "max_data_rate_tx": 1733300, + "cur_data_rate_rx": 650000, + "cur_data_rate_tx": 1170000 + } + ] + } + ] + }, + { + "uid": "n-197", + "device_name": "device#20", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-202", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-180", + "device_name": "device#21", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-182", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-196", + "device_name": "device#22", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-207", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-196", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-207", + "max_data_rate_rx": 866000, + "max_data_rate_tx": 866000, + "cur_data_rate_rx": 866700, + "cur_data_rate_tx": 866000 + } + ] + } + ] + }, + { + "uid": "n-284", + "device_name": "device#21", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-285", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-166", + "device_name": "device#21", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-186", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-225", + "device_name": "device#21", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-227", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-244", + "device_name": "device#19", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-245", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-238", + "device_name": "device#21", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-239", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-233", + "device_name": "device#23", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-234", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-121", + "device_name": "device#24", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-138", + "name": "", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-121", + "node_interface_1_uid": "ni-89", + "node_interface_2_uid": "ni-138", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + } + ] + }, + { + "uid": "n-247", + "device_name": "device#16", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-248", + "name": "", + "type": "WLAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-60", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 866700, + "max_data_rate_tx": 866700, + "cur_data_rate_rx": 866000, + "cur_data_rate_tx": 866000 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-253", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-110", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-254", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + }, + { + "state": "DISCONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-247", + "node_interface_1_uid": "ni-59", + "node_interface_2_uid": "ni-248", + "max_data_rate_rx": 0, + "max_data_rate_tx": 0, + "cur_data_rate_rx": 0, + "cur_data_rate_tx": 0 + } + ] + } + ] + }, + { + "uid": "n-191", + "device_name": "device#25", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-193", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-209", + "device_name": "device#21", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-212", + "name": "", + "type": "WLAN", + "node_links": [] + } + ] + }, + { + "uid": "n-286", + "device_name": "device#26", + "is_meshed": false, + "mesh_role": "unknown", + "node_interfaces": [ + { + "uid": "ni-287", + "name": "", + "type": "LAN", + "node_links": [ + { + "state": "CONNECTED", + "node_1_uid": "n-1", + "node_2_uid": "n-286", + "node_interface_1_uid": "ni-17", + "node_interface_2_uid": "ni-287", + "max_data_rate_rx": 1000000, + "max_data_rate_tx": 1000000, + "cur_data_rate_rx": 1000000, + "cur_data_rate_tx": 1000000 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/tr64desc.xml b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/tr64desc.xml new file mode 100644 index 000000000..04a9a136b --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/hosts/mock/tr64desc.xml @@ -0,0 +1,13 @@ + + + + + urn:dslforum-org:service:Hosts:1 + urn:LanDeviceHosts-com:serviceId:Hosts1 + /hosts + /dummySCPD.xml + + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/hosts/telegraf.conf b/plugins/inputs/fritzbox/testdata/testcases/hosts/telegraf.conf new file mode 100644 index 000000000..c92bd5be9 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/hosts/telegraf.conf @@ -0,0 +1,6 @@ +[[inputs.fritzbox]] + ## URLs are set dynamically by test + # urls = [ ] + collect = [ "hosts" ] + # everything else stays at defaults + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/ppp/expected.out b/plugins/inputs/fritzbox/testdata/testcases/ppp/expected.out new file mode 100644 index 000000000..20730e543 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/ppp/expected.out @@ -0,0 +1 @@ +fritzbox_ppp,service=WANPPPConnection1,source=127.0.0.1 downstream_max_bit_rate=68038668u,upstream_max_bit_rate=44213433u,uptime=369434u 1737088658570388000 diff --git a/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/dummySCPD.xml b/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/dummySCPD.xml new file mode 100644 index 000000000..5f4787762 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/dummySCPD.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/tr64desc.xml b/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/tr64desc.xml new file mode 100644 index 000000000..000d92fd7 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/tr64desc.xml @@ -0,0 +1,13 @@ + + + + + urn:dslforum-org:service:WANPPPConnection:1 + urn:WANPPPConnection-com:serviceId:WANPPPConnection1 + /wanpppconn + /dummySCPD.xml + + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/wanpppconn/response.xml b/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/wanpppconn/response.xml new file mode 100644 index 000000000..3f8d8b241 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/ppp/mock/wanpppconn/response.xml @@ -0,0 +1,38 @@ + + + + +1 +Connected +IP_Routed, IP_Bridged +IP_Routed +internet +369434 +44213433 +68038668 +ERROR_NONE +0 +0 +5511248654630001@setup.t-online.de +1 +217.238.141.33 +2003:180:2:7000::53, 2003:180:2:9000::53,217.237.151.115,217.237.148.102 +dc:39:6f:3a:bc:40 +AlwaysOn + +128 +3 +0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._@()#/%[]{}*+§$&=?!:;, +64 +3 +0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._@()#/%[]{}*+§$&=?!:;, +PPPoE +Off + + +MUNJ20 +1 +1 + + + diff --git a/plugins/inputs/fritzbox/testdata/testcases/ppp/telegraf.conf b/plugins/inputs/fritzbox/testdata/testcases/ppp/telegraf.conf new file mode 100644 index 000000000..4613bd26c --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/ppp/telegraf.conf @@ -0,0 +1,6 @@ +[[inputs.fritzbox]] + ## URLs are set dynamically by test + # urls = [ ] + collect = [ "ppp" ] + # everything else stays at defaults + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/wan/expected.out b/plugins/inputs/fritzbox/testdata/testcases/wan/expected.out new file mode 100644 index 000000000..c5c13231f --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wan/expected.out @@ -0,0 +1 @@ +fritzbox_wan,service=WANCommonInterfaceConfig1,source=127.0.0.1 downstream_current_max_speed=1304268u,layer1_downstream_max_bit_rate=253247000u,layer1_upstream_max_bit_rate=48816000u,total_bytes_received=554484531337u,total_bytes_sent=129497283207u,upstream_current_max_speed=511831u 1737088572669757000 diff --git a/plugins/inputs/fritzbox/testdata/testcases/wan/mock/WANCommonIFC1/response.xml b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/WANCommonIFC1/response.xml new file mode 100644 index 000000000..43538f626 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/WANCommonIFC1/response.xml @@ -0,0 +1,24 @@ + + + + +178 +10893 +0 +0 +648264327 +433750153 +0 +1 +0.0.0.0 +0.0.0.0 +0.0.0.0 +0.0.0.0 +0 +1 +129497283207 +554484531337 +DSL + + + diff --git a/plugins/inputs/fritzbox/testdata/testcases/wan/mock/dummySCPD.xml b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/dummySCPD.xml new file mode 100644 index 000000000..5f4787762 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/dummySCPD.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/wan/mock/igddesc.xml b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/igddesc.xml new file mode 100644 index 000000000..813ad273a --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/igddesc.xml @@ -0,0 +1,13 @@ + + + + + urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 + urn:upnp-org:serviceId:WANCommonIFC1 + /WANCommonIFC1 + /dummySCPD.xml + + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/wan/mock/tr64desc.xml b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/tr64desc.xml new file mode 100644 index 000000000..054b63878 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/tr64desc.xml @@ -0,0 +1,13 @@ + + + + + urn:dslforum-org:service:WANCommonInterfaceConfig:1 + urn:WANCIfConfig-com:serviceId:WANCommonInterfaceConfig1 + /wancommonifconfig + /dummySCPD.xml + + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/wan/mock/wancommonifconfig/response.xml b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/wancommonifconfig/response.xml new file mode 100644 index 000000000..350418730 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wan/mock/wancommonifconfig/response.xml @@ -0,0 +1,15 @@ + + + + +DSL +48816000 +253247000 +Up +281672,1069998,122887,154143,335464,376641,201036,1046752,1304268,117397,42277,54058,41911,193162,372545,232857,661911,884903,35486,43050 +100417,76139,389328,217575,68110,49200,248209,122899,83175,466221,511831,491191,372128,192963,269890,222214,41261,56576,328630,388027 +1304268 +511831 + + + diff --git a/plugins/inputs/fritzbox/testdata/testcases/wan/telegraf.conf b/plugins/inputs/fritzbox/testdata/testcases/wan/telegraf.conf new file mode 100644 index 000000000..317d372f1 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wan/telegraf.conf @@ -0,0 +1,6 @@ +[[inputs.fritzbox]] + ## URLs are set dynamically by test + # urls = [ ] + collect = [ "wan" ] + # everything else stays at defaults + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/wlan/expected.out b/plugins/inputs/fritzbox/testdata/testcases/wlan/expected.out new file mode 100644 index 000000000..6b7bed1c9 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wlan/expected.out @@ -0,0 +1 @@ +fritzbox_wlan,band=2400,channel=13,service=WLANConfiguration1,source=127.0.0.1,ssid=MOCK1234,status=Up total_associations=11u 1737063660847310000 diff --git a/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/dummySCPD.xml b/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/dummySCPD.xml new file mode 100644 index 000000000..5f4787762 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/dummySCPD.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/tr64desc.xml b/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/tr64desc.xml new file mode 100644 index 000000000..e1d35c526 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/tr64desc.xml @@ -0,0 +1,13 @@ + + + + + urn:dslforum-org:service:WLANConfiguration:1 + urn:WLANConfiguration-com:serviceId:WLANConfiguration1 + /wlanconfig + /dummySCPD.xml + + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/wlanconfig/response.xml b/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/wlanconfig/response.xml new file mode 100644 index 000000000..332356618 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wlan/mock/wlanconfig/response.xml @@ -0,0 +1,30 @@ + + + + +1 +Up +Auto +13 +MOCK1234 +11i +None,11i,WPAand11i,11iandWPA3 +0 +n +00:00:00:00:00:00 +None +None +32 +1 +0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +64 +64 +0123456789ABCDEFabcdef +2400 +1 + + +11 + + + diff --git a/plugins/inputs/fritzbox/testdata/testcases/wlan/telegraf.conf b/plugins/inputs/fritzbox/testdata/testcases/wlan/telegraf.conf new file mode 100644 index 000000000..608b3f7d3 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/testcases/wlan/telegraf.conf @@ -0,0 +1,6 @@ +[[inputs.fritzbox]] + ## URLs are set dynamically by test + # urls = [ ] + collect = [ "wlan" ] + # everything else stays at defaults + \ No newline at end of file