diff --git a/EXTERNAL_PLUGINS.md b/EXTERNAL_PLUGINS.md index 5463ef9201c79..778fc0691b724 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 - [huebridge](https://github.com/hdecarne-github/huebridge-telegraf-plugin) - Gather smart home statistics from [Hue Bridge](https://www.philips-hue.com/) devices - [nsdp](https://github.com/hdecarne-github/nsdp-telegraf-plugin) - Gather switch network statistics via [Netgear Switch Discovery Protocol](https://en.wikipedia.org/wiki/Netgear_Switch_Discovery_Protocol) diff --git a/docs/LICENSE_OF_DEPENDENCIES.md b/docs/LICENSE_OF_DEPENDENCIES.md index b8994365b6154..88befb1c8760f 100644 --- a/docs/LICENSE_OF_DEPENDENCIES.md +++ b/docs/LICENSE_OF_DEPENDENCIES.md @@ -362,6 +362,7 @@ following works: - github.com/stoewer/go-strcase [MIT License](https://github.com/stoewer/go-strcase/blob/master/LICENSE) - github.com/stretchr/objx [MIT License](https://github.com/stretchr/objx/blob/master/LICENSE) - github.com/stretchr/testify [MIT License](https://github.com/stretchr/testify/blob/master/LICENSE) +- github.com/tdrn-org/go-tr064 [Apache License 2.0](https://github.com/tdrn-org/go-tr064/blob/main/LICENSE) - github.com/testcontainers/testcontainers-go [MIT License](https://github.com/testcontainers/testcontainers-go/blob/main/LICENSE) - github.com/thomasklein94/packer-plugin-libvirt [Mozilla Public License 2.0](https://github.com/thomasklein94/packer-plugin-libvirt/blob/main/LICENSE) - github.com/tidwall/gjson [MIT License](https://github.com/tidwall/gjson/blob/master/LICENSE) diff --git a/go.mod b/go.mod index 27e54af0c7586..2e98ffa05fcfb 100644 --- a/go.mod +++ b/go.mod @@ -471,6 +471,7 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect github.com/stretchr/objx v0.5.2 // indirect + github.com/tdrn-org/go-tr064 v0.2.2 github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/tinylru v1.2.1 // indirect diff --git a/go.sum b/go.sum index ba6c4e2b06eeb..2c51e8d14bacd 100644 --- a/go.sum +++ b/go.sum @@ -2321,6 +2321,8 @@ github.com/t3rm1n4l/go-mega v0.0.0-20240219080617-d494b6a8ace7 h1:Jtcrb09q0AVWe3 github.com/t3rm1n4l/go-mega v0.0.0-20240219080617-d494b6a8ace7/go.mod h1:suDIky6yrK07NnaBadCB4sS0CqFOvUK91lH7CR+JlDA= github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 h1:Oj2e7Sae4XrOsk3ij21QjjEgAcVSeo9nkp0dI//cD2o= github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw= +github.com/tdrn-org/go-tr064 v0.2.2 h1:rDybEK1m2xfV5QPWHtnIJOt+xG4GFSkQSwA6FS2bQC4= +github.com/tdrn-org/go-tr064 v0.2.2/go.mod h1:P2WWUiBcXDGOo+sqJ4hWn4YXYH9kWaYjZo74EdFDSS0= github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0= github.com/testcontainers/testcontainers-go v0.34.0 h1:5fbgF0vIN5u+nD3IWabQwRybuB4GY8G2HHgCkbMzMHo= github.com/testcontainers/testcontainers-go v0.34.0/go.mod h1:6P/kMkQe8yqPHfPWNulFGdFHTD8HB2vLq/231xY2iPQ= diff --git a/plugins/inputs/all/fritzbox.go b/plugins/inputs/all/fritzbox.go new file mode 100644 index 0000000000000..56a4af0209c2c --- /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 0000000000000..aaa081284a161 --- /dev/null +++ b/plugins/inputs/fritzbox/README.md @@ -0,0 +1,210 @@ +# Fritzbox Input Plugin + +This input plugin gathers status from [AVM][1] devices (routers, repeaters, +...). It uses the device's [TR-064][2] interfaces to retrieve the status. + +[1]: https://en.avm.de/ +[2]: https://avm.de/service/schnittstellen/ + +Retrieved status are: + +- Device info (model, HW/SW version, uptime, ...) +- WAN info (bit rates, transferred bytes, ...) +- PPP info (bit rates, connection uptime, ...) +- DSL info (bit rates, DSL statistics, ...) +- WLAN info (number of clients per network, ...) +- Hosts info (mesh nodes, bit rates, ...) + +## Global configuration options + +In addition to the plugin-specific configuration settings, plugins support +additional global and plugin configuration settings. These settings are used to +modify metrics, tags, and field or create aliases and configure ordering, etc. +See the [CONFIGURATION.md][CONFIGURATION.md] for more details. + +[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins + +## Configuration + +```toml @sample.conf +# Gather fritzbox status +[[inputs.fritzbox]] + ## The URLs of the devices to query. For each device the corresponding URL + ## including the login credentials must be set. E.g. + ## urls = [ + ## "http://boxuser:boxpassword@fritz.box:49000/", + ## "http://:repeaterpassword@fritz.repeater:49000/", + ## ] + urls = [ + ] + + ## The information to collect (see README for further details). + collect = [ + "device", + "wan", + "ppp", + "dsl", + "wlan", + ] + + ## The http timeout to use. + # timeout = "10s" + + ## Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false +``` + +### Collect options + +The following collect options are available: + +`device` metric: fritzbox_device - Collect device infos like model name, +SW version, uptime for the configured devices. + +`wan` metric: fritzbox_wan - Collect generic WAN connection status like +bit rates, transferred bytes. + +`ppp` metric: fritzbox_ppp - Collect PPP connection parameters like bit +rates, uptime. + +`dsl` metric: fritzbox_dsl - Collect DSL line status and statistics. + +`wlan` metric: fritzbox_wlan - Collect status and number of associated +devices for all WLANs. + +`hosts` metric: fritzbox_hosts - Collect detailed information of the mesh +network including connected nodes, there role in the network as well as +their connection bandwidth. + +**Note**: Collecting this metric is time consuming and it generates +very detailed data. If you activate this option, consider increasing +the plugin's query interval to avoid interval overruns and to minimize +the amount of collected data. You can adapt the interval per collect +otpion as follows: + +```toml +[[inputs.fritzbox]] + collect = [ "device", "wan", "ppp", "dsl", "wlan" ] + ... + +[[inputs.fritzbox]] + interval = "5m" + collect = [ "hosts" ] + ... +``` + +## Metrics + +By default field names are directly derived from the corresponding [interface +specification][1]. + +- `fritzbox_device` + - tags + - `source` - The name of the device (this metric has been queried from) + - `service` - The service id used to query this metric + - fields + - `uptime` (uint) - Device's uptime in seconds. + - `model_name` (string) - Device's model name. + - `serial_number` (string) - Device's serial number. + - `hardware_version` (string) - Device's hardware version. + - `software_version` (string) - Device's software version. +- `fritzbox_wan` + - tags + - `source` - The name of the device (this metric has been queried from) + - `service` - The service id used to query this metric + - fields + - `layer1_upstream_max_bit_rate` (uint) - The WAN interface's maximum upstream bit rate (bits/sec) + - `layer1_downstream_max_bit_rate` (uint) - The WAN interface's maximum downstream bit rate (bits/sec) + - `upstream_current_max_speed` (uint) - The WAN interface's current maximum upstream transfer rate (bytes/sec) + - `downstream_current_max_speed` (uint) - The WAN interface's current maximum downstream data rate (bytes/sec) + - `total_bytes_sent` (uint) - The total number of bytes sent via the WAN interface (bytes) + - `total_bytes_received` (uint) - The total number of bytes received via the WAN interface (bytes) +- `fritzbox_ppp` + - tags + - `source` - The name of the device (this metric has been queried from) + - `service` - The service id used to query this metric + - fields + - `uptime` (uint) - The current uptime of the PPP connection in seconds + - `upstream_max_bit_rate` (uint) - The current maximum upstream bit rate negotiated for the PPP connection (bits/sec) + - `downstream_max_bit_rate` (uint) - The current maximum downstream bit rate negotiated for the PPP connection (bits/sec) +- `fritzbox_dsl` + - tags + - `source` - The name of the device (this metric has been queried from) + - `service` - The service id used to query this metric + - `status` - The status of the DLS line (Up or Down) + - fields + - `upstream_curr_rate` (uint) - Current DSL upstream rate (kilobits/sec) + - `downstream_curr_rate` (uint) - Current DSL downstream rate (kilobits/sec) + - `upstream_max_rate` (uint) - Maximum DSL upstream rate (kilobits/sec) + - `downstream_max_rate` (uint) - Maximum DSL downstream rate (kilobits/sec) + - `upstream_noise_margin` (uint) - Upstream noise margin (db) + - `downstream_noise_margin` (uint) - Downstream noise margin (db) + - `upstream_attenuation` (uint) - Upstream attenuation (db) + - `downstream_attenuation` (uint) - Downstream attenuation (db) + - `upstream_power` (uint) - Upstream power + - `downstream_power` (uint) - Downstream power + - `receive_blocks` (uint) - Received blocks + - `transmit_blocks` (uint) - Transmitted blocks + - `cell_delin` (uint) - Cell delineation count + - `link_retrain` (uint) - Link retrains + - `init_errors` (uint) - Initialization errors + - `init_timeouts` (uint) - Initialization timeouts + - `loss_of_framing` (uint) - Loss of frame errors + - `errored_secs` (uint) - Continuous seconds with errors + - `severly_errored_secs` (uint) - Continuous seconds with severe errors + - `fec_errors` (uint) - Local (Modem) FEC (Forward Error Correction) errors + - `atuc_fec_errors` (uint) - Remote (DSLAM) FEC (Forward Error Correction) errors + - `hec_errors` (uint) - Local (Modem) HEC (Header Error Control) errors + - `atuc_hec_errors` (uint) - Remote (DSLAM) HEC (Header Error Control) errors + - `crc_errors` (uint) - Local (Modem) CRC (Cyclic Redundancy Check) error + - `atuc_crc_errors` (uint) - Remote (DSLAM) CRC (Cyclic Redundancy Check) errors +- `fritzbox_wlan` + - tags + - `source` - The name of the device (this metric has been queried from) + - `service` - The service id used to query this metric + - `wlan` - The WLAN SSID (name) + - `channel` - The channel used by this WLAN + - `band` - The band (in MHz) used by this WLAN + - `status` - The status of the WLAN line (Up or Down) + - fields + - `total_associations` (uint) - The number of devices connected to this WLAN. +- `fritzbox_hosts` + - tags + - `source` - The name of the device (this metric has been queried from) + - `service` - The service id used to query this metric + - `node` - The name of the node connected to the mesh network + - `node_role` - The node's role ("master" = mesh master, "slave" = mesh slave, "client") in the network + - `node_ap` - The name of the access point this node is connected to + - `node_ap_role` - The access point's role ("master" = mesh master, "slave" = mesh slave, never "client") in the network + - `link_type` - The link type ("WLAN" or "LAN") of the peer connection + - `link_name` - The link name of the connection + - fields + - `max_data_rate_tx` (uint) - The connection's maximum transmit rate (kilobits/sec) + - `max_data_rate_rx` (uint) - The connection's maximum receive rate (kilobits/sec) + - `cur_data_rate_tx` (uint) - The connection's maximum transmit rate (kilobits/sec) + - `cur_data_rate_rx` (uint) - The connection's current receive rate (kilobits/sec) + +## Example Output + + + +```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 0000000000000..9bf6a43de4a2e --- /dev/null +++ b/plugins/inputs/fritzbox/fritzbox.go @@ -0,0 +1,402 @@ +//go:generate ../../../tools/readme_config_includer/generator +package fritzbox + +import ( + _ "embed" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strconv" + "time" + + "github.com/google/uuid" + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/config" + "github.com/influxdata/telegraf/internal/choice" + "github.com/influxdata/telegraf/logger" + "github.com/influxdata/telegraf/plugins/common/tls" + "github.com/influxdata/telegraf/plugins/inputs" + "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" +) + +//go:embed sample.conf +var sampleConfig string + +const pluginName = "fritzbox" + +const defaultTimeout = config.Duration(10 * time.Second) + +type Fritzbox struct { + URLs []string `toml:"urls"` + Collect []string `toml:"collect"` + Timeout config.Duration `toml:"timeout"` + tls.ClientConfig + Log telegraf.Logger `toml:"-"` + deviceClients []*tr064.Client + serviceHandlers map[string]serviceHandlerFunc +} + +func defaultFritzbox() *Fritzbox { + return &Fritzbox{ + URLs: make([]string, 0), + Collect: []string{"device", "wan", "ppp", "dsl", "wlan"}, + Timeout: defaultTimeout, + deviceClients: make([]*tr064.Client, 0), + serviceHandlers: make(map[string]serviceHandlerFunc), + } +} + +func (*Fritzbox) SampleConfig() string { + return sampleConfig +} + +func (plugin *Fritzbox) Init() error { + if plugin.Log == nil { + plugin.Log = logger.New("inputs", pluginName, "") + } + err := plugin.initDeviceClients() + if err != nil { + return err + } + plugin.initServiceHandlers() + return nil +} + +func (plugin *Fritzbox) initDeviceClients() error { + for _, rawUrl := range plugin.URLs { + parsedUrl, err := url.Parse(rawUrl) + if err != nil { + return err + } + client := tr064.NewClient(parsedUrl) + client.Debug = plugin.Log.Level().Includes(telegraf.Debug) + client.Timeout = time.Duration(plugin.Timeout) + tlsConfig, err := plugin.TLSConfig() + if err != nil { + return err + } + client.TlsConfig = tlsConfig + plugin.deviceClients = append(plugin.deviceClients, client) + } + return nil +} + +func (plugin *Fritzbox) initServiceHandlers() { + if choice.Contains("device", plugin.Collect) { + plugin.serviceHandlers[deviceinfo.ServiceShortType] = plugin.gatherDeviceInfo + } + if choice.Contains("wan", plugin.Collect) { + plugin.serviceHandlers[wancommonifconfig.ServiceShortType] = plugin.gatherWanInfo + } + if choice.Contains("ppp", plugin.Collect) { + plugin.serviceHandlers[wanpppconn.ServiceShortType] = plugin.gatherPppInfo + } + if choice.Contains("dsl", plugin.Collect) { + plugin.serviceHandlers[wandslifconfig.ServiceShortType] = plugin.gatherDslInfo + } + if choice.Contains("wlan", plugin.Collect) { + plugin.serviceHandlers[wlanconfig.ServiceShortType] = plugin.gatherWlanInfo + } + if choice.Contains("hosts", plugin.Collect) { + plugin.serviceHandlers[hosts.ServiceShortType] = plugin.gatherHostsInfo + } +} + +func (plugin *Fritzbox) Gather(acc telegraf.Accumulator) error { + for _, deviceClient := range plugin.deviceClients { + plugin.gatherDevice(acc, deviceClient) + } + return nil +} + +func (plugin *Fritzbox) gatherDevice(acc telegraf.Accumulator, deviceClient *tr064.Client) { + plugin.Log.Debugf("Querying %s", deviceClient.DeviceUrl.Redacted()) + services, err := deviceClient.Services(tr064.DefaultServiceSpec) + if err != nil { + acc.AddError(err) + return + } + for _, service := range services { + serviceHandler := plugin.serviceHandlers[service.ShortType()] + if serviceHandler == nil { + continue + } + err := serviceHandler(acc, deviceClient, service) + if err != nil { + acc.AddError(err) + return + } + } +} + +type serviceHandlerFunc func(telegraf.Accumulator, *tr064.Client, tr064.ServiceDescriptor) error + +func (plugin *Fritzbox) gatherDeviceInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := deviceinfo.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &deviceinfo.GetInfoResponse{} + err := serviceClient.GetInfo(info) + if err != nil { + return err + } + tags := make(map[string]string) + tags["source"] = serviceClient.TR064Client.DeviceUrl.Hostname() + tags["service"] = serviceClient.Service.ShortId() + fields := make(map[string]interface{}) + fields["uptime"] = info.NewUpTime + fields["model_name"] = info.NewModelName + fields["serial_number"] = info.NewSerialNumber + fields["hardware_version"] = info.NewHardwareVersion + fields["software_version"] = info.NewSoftwareVersion + acc.AddFields("fritzbox_device", fields, tags) + return nil +} + +func (plugin *Fritzbox) gatherWanInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wancommonifconfig.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + commonLinkProperties := &wancommonifconfig.GetCommonLinkPropertiesResponse{} + err := serviceClient.GetCommonLinkProperties(commonLinkProperties) + if err != nil { + return err + } + // Use public IGD service instead of the WANCommonInfo one for total bytes stats, because IGD supports uint64 counters + igdServices, err := deviceClient.ServicesByType(tr064.IgdServiceSpec, "WANCommonInterfaceConfig") + if err != nil { + return err + } + if len(igdServices) == 0 { + return fmt.Errorf("IGD service not available") + } + igdServiceClient := &igdicfg.ServiceClient{ + TR064Client: deviceClient, + Service: igdServices[0], + } + addonInfos := &igdicfg.GetAddonInfosResponse{} + err = igdServiceClient.GetAddonInfos(addonInfos) + if err != nil { + return err + } + totalBytesSent, err := strconv.ParseUint(addonInfos.NewX_AVM_DE_TotalBytesSent64, 10, 64) + if err != nil { + return err + } + totalBytesReceived, err := strconv.ParseUint(addonInfos.NewX_AVM_DE_TotalBytesReceived64, 10, 64) + if err != nil { + return err + } + tags := make(map[string]string) + tags["source"] = serviceClient.TR064Client.DeviceUrl.Hostname() + tags["service"] = serviceClient.Service.ShortId() + fields := make(map[string]interface{}) + fields["layer1_upstream_max_bit_rate"] = commonLinkProperties.NewLayer1UpstreamMaxBitRate + fields["layer1_downstream_max_bit_rate"] = commonLinkProperties.NewLayer1DownstreamMaxBitRate + fields["upstream_current_max_speed"] = commonLinkProperties.NewX_AVM_DE_UpstreamCurrentMaxSpeed + fields["downstream_current_max_speed"] = commonLinkProperties.NewX_AVM_DE_DownstreamCurrentMaxSpeed + fields["total_bytes_sent"] = totalBytesSent + fields["total_bytes_received"] = totalBytesReceived + acc.AddFields("fritzbox_wan", fields, tags) + return nil +} + +func (plugin *Fritzbox) gatherPppInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wanpppconn.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &wanpppconn.GetInfoResponse{} + err := serviceClient.GetInfo(info) + if err != nil { + return err + } + tags := make(map[string]string) + tags["source"] = serviceClient.TR064Client.DeviceUrl.Hostname() + tags["service"] = serviceClient.Service.ShortId() + fields := make(map[string]interface{}) + fields["uptime"] = info.NewUptime + fields["upstream_max_bit_rate"] = info.NewUpstreamMaxBitRate + fields["downstream_max_bit_rate"] = info.NewDownstreamMaxBitRate + acc.AddFields("fritzbox_ppp", fields, tags) + return nil +} + +func (plugin *Fritzbox) gatherDslInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wandslifconfig.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &wandslifconfig.GetInfoResponse{} + err := serviceClient.GetInfo(info) + if err != nil { + return err + } + statisticsTotal := &wandslifconfig.GetStatisticsTotalResponse{} + if info.NewStatus == "Up" { + err = serviceClient.GetStatisticsTotal(statisticsTotal) + if err != nil { + return err + } + } + tags := make(map[string]string) + tags["source"] = serviceClient.TR064Client.DeviceUrl.Hostname() + tags["service"] = serviceClient.Service.ShortId() + tags["status"] = info.NewStatus + fields := make(map[string]interface{}) + fields["upstream_curr_rate"] = info.NewUpstreamCurrRate + fields["downstream_curr_rate"] = info.NewDownstreamCurrRate + fields["upstream_max_rate"] = info.NewUpstreamMaxRate + fields["downstream_max_rate"] = info.NewDownstreamMaxRate + fields["upstream_noise_margin"] = info.NewUpstreamNoiseMargin + fields["downstream_noise_margin"] = info.NewDownstreamNoiseMargin + fields["upstream_attenuation"] = info.NewUpstreamAttenuation + fields["downstream_attenuation"] = info.NewDownstreamAttenuation + fields["upstream_power"] = info.NewUpstreamPower + fields["downstream_power"] = info.NewDownstreamPower + fields["receive_blocks"] = statisticsTotal.NewReceiveBlocks + fields["transmit_blocks"] = statisticsTotal.NewTransmitBlocks + fields["cell_delin"] = statisticsTotal.NewCellDelin + fields["link_retrain"] = statisticsTotal.NewLinkRetrain + fields["init_errors"] = statisticsTotal.NewInitErrors + fields["init_timeouts"] = statisticsTotal.NewInitTimeouts + fields["loss_of_framing"] = statisticsTotal.NewLossOfFraming + fields["errored_secs"] = statisticsTotal.NewErroredSecs + fields["severly_errored_secs"] = statisticsTotal.NewSeverelyErroredSecs + fields["fec_errors"] = statisticsTotal.NewFECErrors + fields["atuc_fec_errors"] = statisticsTotal.NewATUCFECErrors + fields["hec_errors"] = statisticsTotal.NewHECErrors + fields["atuc_hec_errors"] = statisticsTotal.NewATUCHECErrors + fields["crc_errors"] = statisticsTotal.NewCRCErrors + fields["atuc_crc_errors"] = statisticsTotal.NewATUCCRCErrors + acc.AddFields("fritzbox_dsl", fields, tags) + return nil +} + +func (plugin *Fritzbox) gatherWlanInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := wlanconfig.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + info := &wlanconfig.GetInfoResponse{} + err := serviceClient.GetInfo(info) + if err != nil { + return err + } + totalAssociations := &wlanconfig.GetTotalAssociationsResponse{} + if info.NewStatus == "Up" { + err = serviceClient.GetTotalAssociations(totalAssociations) + if err != nil { + return err + } + } + tags := make(map[string]string) + tags["source"] = serviceClient.TR064Client.DeviceUrl.Hostname() + tags["service"] = serviceClient.Service.ShortId() + tags["status"] = info.NewStatus + tags["ssid"] = info.NewSSID + tags["channel"] = strconv.Itoa(int(info.NewChannel)) + tags["band"] = plugin.wlanBandFromInfo(info) + fields := make(map[string]interface{}) + fields["total_associations"] = totalAssociations.NewTotalAssociations + acc.AddGauge("fritzbox_wlan", fields, tags) + return nil +} + +func (plugin *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 (plugin *Fritzbox) gatherHostsInfo(acc telegraf.Accumulator, deviceClient *tr064.Client, service tr064.ServiceDescriptor) error { + serviceClient := hosts.ServiceClient{ + TR064Client: deviceClient, + Service: service, + } + connections, err := plugin.fetchHostsConnections(&serviceClient) + if err != nil { + return err + } + for _, connection := range connections { + _, err = uuid.Parse(connection.RightDeviceName) + if err == nil { + continue + } + tags := make(map[string]string) + tags["source"] = serviceClient.TR064Client.DeviceUrl.Hostname() + tags["service"] = serviceClient.Service.ShortId() + tags["node"] = connection.RightDeviceName + tags["node_role"] = plugin.hostRole(connection.RightMeshRole) + tags["node_ap"] = connection.LeftDeviceName + tags["node_ap_role"] = plugin.hostRole(connection.LeftMeshRole) + tags["link_type"] = connection.InterfaceType + tags["link_name"] = connection.InterfaceName + fields := make(map[string]interface{}) + fields["max_data_rate_tx"] = connection.MaxDataRateTx + fields["max_data_rate_rx"] = connection.MaxDataRateRx + fields["cur_data_rate_tx"] = connection.CurDataRateTx + fields["cur_data_rate_rx"] = connection.CurDataRateRx + acc.AddGauge("fritzbox_hosts", fields, tags) + } + return nil +} + +func (plugin *Fritzbox) hostRole(role string) string { + if role == "unknown" { + return "client" + } + return role +} + +func (plugin *Fritzbox) fetchHostsConnections(serviceClient *hosts.ServiceClient) ([]*mesh.Connection, error) { + meshListPath := &hosts.X_AVM_DE_GetMeshListPathResponse{} + err := serviceClient.X_AVM_DE_GetMeshListPath(meshListPath) + if err != nil { + return nil, err + } + meshListResponse, err := serviceClient.TR064Client.Get(meshListPath.NewX_AVM_DE_MeshListPath) + if err != nil { + return nil, 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 (status: %s)", meshListPath.NewX_AVM_DE_MeshListPath, meshListResponse.Status) + } + defer meshListResponse.Body.Close() + meshListBytes, err := io.ReadAll(meshListResponse.Body) + if err != nil { + return nil, err + } + meshList := &mesh.List{} + err = json.Unmarshal(meshListBytes, meshList) + if err != nil { + return nil, err + } + return meshList.Connections(), nil +} + +func init() { + inputs.Add(pluginName, func() telegraf.Input { + return defaultFritzbox() + }) +} diff --git a/plugins/inputs/fritzbox/fritzbox_test.go b/plugins/inputs/fritzbox/fritzbox_test.go new file mode 100644 index 0000000000000..87c8b97d99848 --- /dev/null +++ b/plugins/inputs/fritzbox/fritzbox_test.go @@ -0,0 +1,178 @@ +package fritzbox + +import ( + "os" + "testing" + "time" + + "github.com/BurntSushi/toml" + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/config" + "github.com/influxdata/telegraf/logger" + "github.com/influxdata/telegraf/plugins/parsers/influx" + "github.com/influxdata/telegraf/testutil" + "github.com/stretchr/testify/require" + "github.com/tdrn-org/go-tr064/mock" +) + +func TestInitDefaults(t *testing.T) { + plugin := defaultFritzbox() + err := plugin.Init() + require.NoError(t, err) + require.Len(t, plugin.URLs, 0) + require.Equal(t, []string{"device", "wan", "ppp", "dsl", "wlan"}, plugin.Collect) + require.Equal(t, defaultTimeout, plugin.Timeout) + require.Empty(t, plugin.TLSCA) + require.Empty(t, plugin.TLSCert) + require.Empty(t, plugin.TLSKey) + require.Empty(t, plugin.TLSKeyPwd) + require.False(t, plugin.InsecureSkipVerify) + require.NotNil(t, plugin.Log) +} + +func TestConfig(t *testing.T) { + conf, err := os.ReadFile("testdata/conf/fritzbox.conf") + require.NoError(t, err) + var plugin = defaultFritzbox() + err = toml.Unmarshal(conf, plugin) + require.NoError(t, err) + err = plugin.Init() + require.NoError(t, err) + require.Len(t, plugin.URLs, 2) + require.Equal(t, []string{"device", "wan", "ppp", "dsl", "wlan", "hosts"}, plugin.Collect) + require.Equal(t, config.Duration(60*time.Second), plugin.Timeout) + require.Equal(t, "secret", plugin.TLSKeyPwd) + require.True(t, plugin.InsecureSkipVerify) +} + +const mockDocsDir = "testdata/mock" + +var testMocks = []*mock.ServiceMock{ + mock.ServiceMockFromFile("/deviceinfo", "testdata/mock/DeviceInfo.xml"), + mock.ServiceMockFromFile("/wancommonifconfig", "testdata/mock/WANCommonInterfaceConfig1.xml"), + mock.ServiceMockFromFile("/WANCommonIFC1", "testdata/mock/WANCommonInterfaceConfig2.xml"), + mock.ServiceMockFromFile("/wanpppconn", "testdata/mock/WANPPPConnection.xml"), + mock.ServiceMockFromFile("/wandslifconfig", "testdata/mock/WANDSLInterfaceConfig.xml"), + mock.ServiceMockFromFile("/wlanconfig", "testdata/mock/WLANConfiguration.xml"), + mock.ServiceMockFromFile("/hosts", "testdata/mock/Hosts.xml"), +} + +func TestGatherDeviceInfo(t *testing.T) { + // Start mock server + tr064Server := mock.Start(mockDocsDir, testMocks...) + defer tr064Server.Shutdown() + // Enable debug logging + logger.SetupLogging(&logger.Config{Debug: true}) + // Actual test + plugin := defaultFritzbox() + plugin.URLs = append(plugin.URLs, tr064Server.Server().String()) + plugin.Collect = []string{"device"} + err := plugin.Init() + require.NoError(t, err) + acc := &testutil.Accumulator{} + err = acc.GatherError(plugin.Gather) + require.NoError(t, err) + testMetric(t, acc, "testdata/metrics/fritzbox_device.txt", telegraf.Untyped) +} + +func TestGatherWanInfo(t *testing.T) { + // Start mock server + tr064Server := mock.Start(mockDocsDir, testMocks...) + defer tr064Server.Shutdown() + // Enable debug logging + logger.SetupLogging(&logger.Config{Debug: true}) + // Actual test + plugin := defaultFritzbox() + plugin.URLs = append(plugin.URLs, tr064Server.Server().String()) + plugin.Collect = []string{"wan"} + err := plugin.Init() + require.NoError(t, err) + acc := &testutil.Accumulator{} + err = acc.GatherError(plugin.Gather) + require.NoError(t, err) + testMetric(t, acc, "testdata/metrics/fritzbox_wan.txt", telegraf.Untyped) +} + +func TestGatherPppInfo(t *testing.T) { + // Start mock server + tr064Server := mock.Start(mockDocsDir, testMocks...) + defer tr064Server.Shutdown() + // Enable debug logging + logger.SetupLogging(&logger.Config{Debug: true}) + // Actual test + plugin := defaultFritzbox() + plugin.URLs = append(plugin.URLs, tr064Server.Server().String()) + plugin.Collect = []string{"ppp"} + err := plugin.Init() + require.NoError(t, err) + acc := &testutil.Accumulator{} + err = acc.GatherError(plugin.Gather) + require.NoError(t, err) + testMetric(t, acc, "testdata/metrics/fritzbox_ppp.txt", telegraf.Untyped) +} + +func TestGatherDslInfo(t *testing.T) { + // Start mock server + tr064Server := mock.Start(mockDocsDir, testMocks...) + defer tr064Server.Shutdown() + // Enable debug logging + logger.SetupLogging(&logger.Config{Debug: true}) + // Actual test + plugin := defaultFritzbox() + plugin.URLs = append(plugin.URLs, tr064Server.Server().String()) + plugin.Collect = []string{"dsl"} + err := plugin.Init() + require.NoError(t, err) + acc := &testutil.Accumulator{} + err = acc.GatherError(plugin.Gather) + require.NoError(t, err) + testMetric(t, acc, "testdata/metrics/fritzbox_dsl.txt", telegraf.Untyped) +} + +func TestGatherWlanInfo(t *testing.T) { + // Start mock server + tr064Server := mock.Start(mockDocsDir, testMocks...) + defer tr064Server.Shutdown() + // Enable debug logging + logger.SetupLogging(&logger.Config{Debug: true}) + // Actual test + plugin := defaultFritzbox() + plugin.URLs = append(plugin.URLs, tr064Server.Server().String()) + plugin.Collect = []string{"wlan"} + err := plugin.Init() + require.NoError(t, err) + acc := &testutil.Accumulator{} + err = acc.GatherError(plugin.Gather) + require.NoError(t, err) + testMetric(t, acc, "testdata/metrics/fritzbox_wlan.txt", telegraf.Gauge) +} + +func TestGatherHostsInfo(t *testing.T) { + // Start mock server + tr064Server := mock.Start(mockDocsDir, testMocks...) + defer tr064Server.Shutdown() + // Enable debug logging + logger.SetupLogging(&logger.Config{Debug: true}) + // Actual test + plugin := defaultFritzbox() + plugin.URLs = append(plugin.URLs, tr064Server.Server().String()) + plugin.Collect = []string{"hosts"} + err := plugin.Init() + require.NoError(t, err) + acc := &testutil.Accumulator{} + err = acc.GatherError(plugin.Gather) + require.NoError(t, err) + testMetric(t, acc, "testdata/metrics/fritzbox_hosts.txt", telegraf.Gauge) +} + +func testMetric(t *testing.T, acc *testutil.Accumulator, file string, vt telegraf.ValueType) { + parser := &influx.Parser{} + err := parser.Init() + require.NoError(t, err) + expectedMetrics, err := testutil.ParseMetricsFromFile(file, parser) + for index := range expectedMetrics { + expectedMetrics[index].SetType(vt) + } + require.NoError(t, err) + testutil.RequireMetricsEqual(t, expectedMetrics, acc.GetTelegrafMetrics(), testutil.IgnoreTime()) +} diff --git a/plugins/inputs/fritzbox/sample.conf b/plugins/inputs/fritzbox/sample.conf new file mode 100644 index 0000000000000..11f3168b2f506 --- /dev/null +++ b/plugins/inputs/fritzbox/sample.conf @@ -0,0 +1,30 @@ +# Gather fritzbox status +[[inputs.fritzbox]] + ## The URLs of the devices to query. For each device the corresponding URL + ## including the login credentials must be set. E.g. + ## urls = [ + ## "http://boxuser:boxpassword@fritz.box:49000/", + ## "http://:repeaterpassword@fritz.repeater:49000/", + ## ] + urls = [ + ] + + ## The information to collect (see README for further details). + collect = [ + "device", + "wan", + "ppp", + "dsl", + "wlan", + ] + + ## The http timeout to use. + # timeout = "10s" + + ## Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + # tls_key_pwd = "secret" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false diff --git a/plugins/inputs/fritzbox/testdata/conf/fritzbox.conf b/plugins/inputs/fritzbox/testdata/conf/fritzbox.conf new file mode 100644 index 0000000000000..d627e221c097a --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/conf/fritzbox.conf @@ -0,0 +1,31 @@ + ## The URLs of the devices to query. For each device the corresponding URL + ## including the login credentials must be set. E.g. + ## urls = [ + ## "http://boxuser:boxpassword@fritz.box:49000/", + ## "http://:repeaterpassword@fritz.repeater:49000/", + ## ] + 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/metrics/fritzbox_device.txt b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_device.txt new file mode 100644 index 0000000000000..7c723f0e96f72 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_device.txt @@ -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/metrics/fritzbox_dsl.txt b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_dsl.txt new file mode 100644 index 0000000000000..891f1bdcd82b8 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_dsl.txt @@ -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/metrics/fritzbox_hosts.txt b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_hosts.txt new file mode 100644 index 0000000000000..7a5bc13dc73c0 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_hosts.txt @@ -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/metrics/fritzbox_ppp.txt b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_ppp.txt new file mode 100644 index 0000000000000..20730e543e4d0 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_ppp.txt @@ -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/metrics/fritzbox_wan.txt b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_wan.txt new file mode 100644 index 0000000000000..c5c13231f6109 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_wan.txt @@ -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/metrics/fritzbox_wlan.txt b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_wlan.txt new file mode 100644 index 0000000000000..6b7bed1c96448 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/metrics/fritzbox_wlan.txt @@ -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/mock/DeviceInfo.xml b/plugins/inputs/fritzbox/testdata/mock/DeviceInfo.xml new file mode 100644 index 0000000000000..3d3ad9dc74e02 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/DeviceInfo.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/mock/Hosts.xml b/plugins/inputs/fritzbox/testdata/mock/Hosts.xml new file mode 100644 index 0000000000000..cde36d58d3c4f --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/Hosts.xml @@ -0,0 +1,8 @@ + + + + +/meshlist.json?sid=123456789abcdef + + + diff --git a/plugins/inputs/fritzbox/testdata/mock/WANCommonInterfaceConfig1.xml b/plugins/inputs/fritzbox/testdata/mock/WANCommonInterfaceConfig1.xml new file mode 100644 index 0000000000000..3504187308da5 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/WANCommonInterfaceConfig1.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/mock/WANCommonInterfaceConfig2.xml b/plugins/inputs/fritzbox/testdata/mock/WANCommonInterfaceConfig2.xml new file mode 100644 index 0000000000000..43538f62670bb --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/WANCommonInterfaceConfig2.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/mock/WANDSLInterfaceConfig.xml b/plugins/inputs/fritzbox/testdata/mock/WANDSLInterfaceConfig.xml new file mode 100644 index 0000000000000..34ca377ceaf8c --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/WANDSLInterfaceConfig.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/mock/WANPPPConnection.xml b/plugins/inputs/fritzbox/testdata/mock/WANPPPConnection.xml new file mode 100644 index 0000000000000..3f8d8b2412d4a --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/WANPPPConnection.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/mock/WLANConfiguration.xml b/plugins/inputs/fritzbox/testdata/mock/WLANConfiguration.xml new file mode 100644 index 0000000000000..332356618cb50 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/WLANConfiguration.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/mock/dummySCPD.xml b/plugins/inputs/fritzbox/testdata/mock/dummySCPD.xml new file mode 100644 index 0000000000000..5f4787762f0a3 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/dummySCPD.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/inputs/fritzbox/testdata/mock/igddesc.xml b/plugins/inputs/fritzbox/testdata/mock/igddesc.xml new file mode 100644 index 0000000000000..813ad273ac8b8 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/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/mock/meshlist.json b/plugins/inputs/fritzbox/testdata/mock/meshlist.json new file mode 100644 index 0000000000000..87c29ccd29ad7 --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/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/mock/tr64desc.xml b/plugins/inputs/fritzbox/testdata/mock/tr64desc.xml new file mode 100644 index 0000000000000..f1ad3c7ea275d --- /dev/null +++ b/plugins/inputs/fritzbox/testdata/mock/tr64desc.xml @@ -0,0 +1,43 @@ + + + + + urn:dslforum-org:service:DeviceInfo:1 + urn:DeviceInfo-com:serviceId:DeviceInfo1 + /deviceinfo + /dummySCPD.xml + + + urn:dslforum-org:service:WLANConfiguration:1 + urn:WLANConfiguration-com:serviceId:WLANConfiguration1 + /wlanconfig + /dummySCPD.xml + + + urn:dslforum-org:service:WANCommonInterfaceConfig:1 + urn:WANCIfConfig-com:serviceId:WANCommonInterfaceConfig1 + /wancommonifconfig + /dummySCPD.xml + + + urn:dslforum-org:service:WANPPPConnection:1 + urn:WANPPPConnection-com:serviceId:WANPPPConnection1 + /wanpppconn + /dummySCPD.xml + + + urn:dslforum-org:service:WANDSLInterfaceConfig:1 + urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1 + /wandslifconfig + /dummySCPD.xml + + + urn:dslforum-org:service:Hosts:1 + urn:LanDeviceHosts-com:serviceId:Hosts1 + /hosts + /dummySCPD.xml + + + + + \ No newline at end of file