Giter Club home page Giter Club logo

fritz_exporter's People

Contributors

bjoern-r avatar dependabot[bot] avatar dotlambda avatar ein-stein-chen avatar francyesco avatar niklasbuechner avatar nistee avatar pdreker avatar r0ckarong avatar rwxd avatar stoically avatar transacid avatar treibholz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fritz_exporter's Issues

Docker image can't be build out of the box

Hello,
I am not a Python developer and without any further knowledge it is not possible to build with the given Docker image, as there are essential files missing. E.g. *.whl, requirements.txt and potentially more.

I am aware of the existing, but 2 year old, Docker image on DockerHub, anyways I would appreciate to utilize the latest version of this tool.

-C

AttributeError: 'NoneType' object has no attribute 'strip'

Hi, when i run the docker container, i get the following error.

Any ideas?

FritzBox: 7560
FritzOS: 7.30

023-12-08 06:26:25,012 INFO fritzexporter.fritzdevice | Connection to 192.168.178.1 successful, reading capabilities
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/local/lib/python3.12/site-packages/fritzexporter/main.py", line 128, in
main()
File "/usr/local/lib/python3.12/site-packages/fritzexporter/main.py", line 92, in main
fritz_device = FritzDevice(
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/fritzexporter/fritzdevice.py", line 39, in init
self.capabilities = FritzCapabilities(self, host_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/fritzexporter/fritzcapabilities.py", line 97, in init
self.check_present(device)
File "/usr/local/lib/python3.12/site-packages/fritzexporter/fritzcapabilities.py", line 122, in check_present
self.capabilities[c].checkCapability(device)
File "/usr/local/lib/python3.12/site-packages/fritzexporter/fritzcapabilities.py", line 56, in checkCapability
device.fc.call_action(svc, action)
File "/usr/local/lib/python3.12/site-packages/fritzconnection/core/fritzconnection.py", line 456, in call_action
return self.soaper.execute(service, action_name, arguments)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/fritzconnection/core/soaper.py", line 286, in execute
return handle_response(response)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/fritzconnection/core/soaper.py", line 268, in handle_response
raise_fritzconnection_error(response)
File "/usr/local/lib/python3.12/site-packages/fritzconnection/core/soaper.py", line 183, in raise_fritzconnection_error
text = node.text.strip()
^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'

Thanks!

Any way to monitor remote fritz!boxes via MyFritz?

I am trying to keep tabs on the internet connections to three remote sites, and have set up their fritz!boxes to be reachable remotely via MyFritz (https://www.myfritz.net/devices/); it looks like the webface that is exposed via this doesn't export the igddesc.xml file, though:

$ curl 'https://me:[email protected]:44369/igddesc.xml'
*   Trying 2a01:aea0:df4:1::5c29:44369...
* Connected to a-very-long-random-string.myfritz.net (2a01:aea0:df4:1::5c29) port 44369 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: CN=a-very-long-random-string.myfritz.net
*  start date: Jun 18 12:03:05 2022 GMT
*  expire date: Sep 16 12:03:04 2022 GMT
*  subjectAltName: host "a-very-long-random-string.myfritz.net" matched cert's "a-very-long-random-string.myfritz.net"
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify ok.
* Server auth using Basic with user 'me'
> GET /igddesc.xml HTTP/1.1
> Host: a-very-long-random-string.myfritz.net:44369
> Authorization: Basic ========
> User-Agent: curl/7.83.1
> Accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Connection: close
< Content-Length: 1705
< Content-Type: text/html; charset=utf-8
<
...

Is there any hope that the exporter could work with a remote fritz!box? I would hate to have to drop little computers that run the exporter in the local network (especially in the current supply chain situation)...

AttributeError

python3 -m fritzbox_exporter                                                                              master :: 40d :: ⬡
curl localhost:8765
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: 500</p>
        <p>Message: error generating metric output.</p>
        <p>Error code explanation: 500 - Server got itself in trouble.</p>
    </body>
</html>

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53654)
Traceback (most recent call last):
  File "/usr/lib/python3.5/socketserver.py", line 625, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
    self.handle()
  File "/usr/lib/python3.5/http/server.py", line 422, in handle
    self.handle_one_request()
  File "/usr/lib/python3.5/http/server.py", line 410, in handle_one_request
    method()
  File "/usr/local/lib/python3.5/dist-packages/prometheus_client/exposition.py", line 152, in do_GET
    output = encoder(registry)
  File "/usr/local/lib/python3.5/dist-packages/prometheus_client/exposition.py", line 121, in generate_latest
    output.append(sample_line(s))
  File "/usr/local/lib/python3.5/dist-packages/prometheus_client/exposition.py", line 79, in sample_line
    for k, v in sorted(line.labels.items())]))
  File "/usr/local/lib/python3.5/dist-packages/prometheus_client/exposition.py", line 79, in <listcomp>
    for k, v in sorted(line.labels.items())]))
AttributeError: ("'NoneType' object has no attribute 'replace'", Metric(fritzbox_update_available, FritzBox update available, gauge, , [Sample(name='fritzbox_update_available', labels={'Serial': 'XXXXXXXXXXXX', 'NewSoftwareVersion': None}, value=0, timestamp=None, exemplar=None)]))

Capability merging may be redundant

An empty FritzCollector will start out with a maximal set of capabilities (all capas known to the exporter). When adding a device to the collector it merges the devices capabilities with its own, which effectively creates a union of the two sets of capabilities.

As the collector always starts out with a full set this will always be the full set.

Either rework the merging process, so it actually represents a set of all currently available capas, or get rid of this mechanis altogether.

NOTE: this has no functional implications as available capabilities are checked for each device before actually trying to fetch them.

FRITZ!Box 7530 UnauthorizedERR_NONEWebserver

Hi,

Currently, having an issue with the script, and the error is not really helping:

First a quick description of the environment & libs:

root@prometheus:/opt/fritzbox_exporter# pip3 install prometheus-client
Requirement already satisfied: prometheus-client in /usr/local/lib/python3.8/dist-packages (0.9.0)
root@prometheus:/opt/fritzbox_exporter# pip3 install fritzconnection
Requirement already satisfied: fritzconnection in /usr/local/lib/python3.8/dist-packages (1.4.0)
Requirement already satisfied: requests>=2.22.0 in /usr/lib/python3/dist-packages (from fritzconnection) (2.22.0)
root@prometheus:/opt/fritzbox_exporter# python --version
Python 3.8.5
root@prometheus:/opt/fritzbox_exporter# env | grep FRITZ | grep -v PASS
FRITZ_HOST=192.168.178.1
FRITZ_USER=monitoring

I can log-in with the monitoring user from "home network".

When I execute the script:

root@prometheus:/opt/fritzbox_exporter# python fritzbox_exporter.py 
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/soaper.py", line 123, in raise_fritzconnection_error
    root = etree.fromstring(response.content)
  File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1320, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: mismatched tag: line 1, column 156

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fritzbox_exporter.py", line 123, in <module>
    REGISTRY.register(FritzBoxCollector(os.getenv('FRITZ_HOST', 'fritz.box'), os.getenv('FRITZ_USER'), os.getenv('FRITZ_PASS')))
  File "/usr/local/lib/python3.8/dist-packages/prometheus_client/registry.py", line 26, in register
    names = self._get_names(collector)
  File "/usr/local/lib/python3.8/dist-packages/prometheus_client/registry.py", line 66, in _get_names
    for metric in desc_func():
  File "fritzbox_exporter.py", line 31, in collect
    info_result = self.conn.call_action('DeviceInfo:1', 'GetInfo')
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/fritzconnection.py", line 227, in call_action
    return self.soaper.execute(service, action_name, arguments)
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/soaper.py", line 238, in execute
    return handle_response(response)
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/soaper.py", line 222, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/soaper.py", line 133, in raise_fritzconnection_error
    raise FritzConnectionException(msg)
fritzconnection.core.exceptions.FritzConnectionException: Unable to perform operation. 401 Unauthorized (ERR_NONE)401 UnauthorizedERR_NONEWebserver Sat, 30 Jan 2021 16:35:30 GMT

Just checking the lib from the REPL:

root@prometheus:/opt/fritzbox_exporter# python
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from fritzconnection import FritzConnection
>>> 
>>> fc = FritzConnection(address='192.168.178.1')
>>> fc.reconnect()  # get a new external ip from the provider
>>> print(fc)  # print router model informations
FRITZ!Box 7530 at http://192.168.178.1
FRITZ!OS: 7.13
>>> quit()
root@prometheus:/opt/fritzbox_exporter# 

Guest_Packets_Count not working

I'm using the provisioned Grafana Dashboard and played around with 2 Devices in my Guest wifi.

The image shows a speedtest on a wifi device in my guest network. The packets count doesn't show anything.

Packets for all others Wifis and LAN do work though.

Bildschirmfoto 2021-03-16 um 22 00 52

Prometheus Output:


fritz_wifi_guest_packets_count_total{direction="rx", enabled="1", instance="fritz:9787", job="fritz", serial="removed", ssid="FRITZ! Hotspot", standard="n"}
fritz_uptime_seconds_total{modelname="FRITZ!Box 7590",serial="removed",softwareversion="154.07.21"} 2.716208e+06


docker-compose service

  fritz:
    privileged: true
    image: pdreker/fritz_exporter
    expose:
      - 9787
    ports:
      - 9787:9787
    environment:
      - "FRITZ_EXPORTER_CONFIG=192.168.178.1,username,password"
    restart: always
    networks:
      - back-tier

Fritz!Box 6591 Cable UPnPError 401 invalid action

Hi,

Currently, having an issue with the script, and the error is not really helping:
I have a FritzBox 6591 Cable with FRITZ!OS 07.13

First a quick description of the libs:

root@bababooey:/opt/fritzbox_exporter# pip3 install prometheus-client
Requirement already satisfied: prometheus-client in /usr/local/lib/python3.8/dist-packages (0.9.0)
root@bababooey:/opt/fritzbox_exporter# pip3 install fritzconnection
Requirement already satisfied: fritzconnection in /usr/local/lib/python3.8/dist-packages (1.4.1)
Requirement already satisfied: requests>=2.22.0 in /usr/lib/python3/dist-packages (from fritzconnection) (2.22.0)

When I execute the Script:

root@bababooey:/opt/fritzbox_exporter# python3 fritz_exporter.py
Traceback (most recent call last):
  File "fritz_exporter.py", line 59, in <module>
    main()
  File "fritz_exporter.py", line 46, in main
    REGISTRY.register(fritzcollector)
  File "/usr/local/lib/python3.8/dist-packages/prometheus_client/registry.py", line 26, in register
    names = self._get_names(collector)
  File "/usr/local/lib/python3.8/dist-packages/prometheus_client/registry.py", line 66, in _get_names
    for metric in desc_func():
  File "/opt/fritzbox_exporter/fritzexporter/fritzdevice.py", line 74, in collect
    yield from capa.getMetrics(self.devices, name)
  File "/opt/fritzbox_exporter/fritzexporter/fritzcapabilities.py", line 28, in getMetrics
    yield from self._getMetricValues(device)
  File "/opt/fritzbox_exporter/fritzexporter/fritzcapabilities.py", line 202, in _getMetricValues
    fritz_dslinfo_result = device.fc.call_action('WANDSLInterfaceConfig:1', 'GetInfo')
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/fritzconnection.py", line 227, in call_action
    return self.soaper.execute(service, action_name, arguments)
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/soaper.py", line 238, in execute
    return handle_response(response)
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/soaper.py", line 222, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/local/lib/python3.8/dist-packages/fritzconnection/core/soaper.py", line 147, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzActionError: UPnPError:
errorCode: 401
errorDescription: Invalid Action

Byterate

Metrics which are not yet scraped by this exporter (as far as I have seen):

  1. FritzBox DSL 7590 V7.25
  2. Servicename: WANCommonInterfaceConfig1 Action: GetAddonInfos
  3. Sorry, the Helper didn't run properly. Fields are "NewByteReceiveRate" and "NewByteSendRate".
  4. At the moment I am getting this info in an nodered environment (node-red-contrib-fritz) from the Fritzbox and I would like to migrate to Fritzbox_exporter.

v2.1.0 HostInfo Capability enabled

Using the new v2.1.0 docker image I am getting the warning:
WARNING fritzexporter.fritzdevice | HostInfo Capability enabled on device fritz.box. This may consume a lot of resources!.
The request is taking more than 10 seconds. Going back to v2.0.0 is solving that problem.
Any hints, what I am doing wrong?

Weird response from request in Grafana

I'm running fritzexporter in an docker container,
Connected successfully the Prometheus database to the container but Grafana doesn't show anything.
I modified a label in Grafana so it matches a line in the query, but the response is weird (at least for me)

don't know what's wrong

afbeelding

Yet another dashboard for Grafana

I created yet another dashboard additionally display some data from the host info metrics

Grafana Dash #17751
(although it is published. Grafana's website currently shows a 404 when searching and clicking it :-/ )

The JSON can be downloaded also here.
I attached a screenshot. If you find the link worth to be included in the docs, I would create a PR.
If you have suggestion or find errors please let me know.

Fritz!Exporter Dash-2022-12-29

Set default wifi

Hey,
is there any way to set the default wifi?
Mine shows "Guest" but is there any way to first choose 5GHz for example?

Installation Documentation

Hi all,

I am trying to install fritz_exporter using Docker on my Synology NAS in order to read my Fritzbox 7490.

I am struggeling with the setup.

I created a NAS Folder: docker/fritzexporter and copied fritz-exporter.yml

content of fritz-exporter.yml

# Config File for Fritz-Exporter
#exporter_port: 9787 # optional
#log_level: DEBUG # optional
devices:
  - name: Fritz!Box 7490 # optional
    hostname: fritz.box
    username: Fritz-Exporter
    password: Fritz-Exporter

But I am not sure how to mount the config file. In the documentation is not mentioned to which mount path the yml should be mounted.

Link: f79cf40

grafik

grafik

grafik

Can you please support me and updated the installation documentation?

Thx

Enhance configurability

Make the exporter more configurable:

  1. make it possible to enable/disable some data blocks (e.g. if your LAN metrics work, but always are 0 you could disable them
  2. enable configuration via config file (YAML) - as configuration gets more complex env vars get "exponentially more difficult to handle". Find a good compromise on this.

Is there a way to get window/door sensor readings?

I've successfully added the exporter to my Synology NAS and now am monitoring the state of my heating and PV system. Thanks for this awesome tool!

One thing I'm missing at the moment and can't figure out how to do is to get the states of my window sensors that govern the heating in various rooms. The devices are listed in the prometheus data but there doesn't seem to be data on their state other than "present".

fritz_ha_device_present{ain="11934 0323032", device_id="UNKNOWN", device_name="Fenster Toilette", friendly_name="Fritz!Box", instance="fritz-exporter:9787", job="fritz-exporter", manufacturer="HAN-FUN", serial="989BCB5F8FE4"} | 2
fritz_ha_device_present{ain="11934 0323032-1", device_id="UNKNOWN", device_name="Fenster Toilette", friendly_name="Fritz!Box", instance="fritz-exporter:9787", job="fritz-exporter", manufacturer="HAN-FUN", serial="989BCB5F8FE4"} | 2
fritz_ha_device_present{ain="11934 0324621", device_id="UNKNOWN", device_name="Fenster Badezimmer", friendly_name="Fritz!Box", instance="fritz-exporter:9787", job="fritz-exporter", manufacturer="HAN-FUN", serial="989BCB5F8FE4"} | 2
fritz_ha_device_present{ain="11934 0324621-1", device_id="UNKNOWN", device_name="Fenster Badezimmer", friendly_name="Fritz!Box", instance="fritz-exporter:9787", job="fritz-exporter", manufacturer="HAN-FUN", serial="989BCB5F8FE4"} | 2
fritz_ha_device_present{ain="11934 0335913", device_id="UNKNOWN", device_name="Terrassentür Küche", friendly_name="Fritz!Box", instance="fritz-exporter:9787", job="fritz-exporter", manufacturer="HAN-FUN", serial="989BCB5F8FE4"} | 2
fritz_ha_device_present{ain="11934 0335913-1", device_id="UNKNOWN", device_name="Terrassentür Küche", friendly_name="Fritz!Box", instance="fritz-exporter:9787", job="fritz-exporter", manufacturer="HAN-FUN", serial="989BCB5F8FE4"}

I would love to get the state "Open / Closed" readings from these sensors to overlay on my Grafana temperature panels.
Can you give me an idea what I need to look out for in the API specs then I could try and write some code to do this.

No Cable Data

hi,

just started with prometheus and found this exporter :) 👍
but unfortunately there is no data about the cable connection of my 6591. would it be possible to get this info?

kr
david

Additional Fritz!Box Fiber metrics

I'm using a Fritz!Box 5530 Fiber to directly connect to a local fiber network.

The exporter works fine for basic metrics (wifi, wan, lan, ...) but does not contain any fiber specific information.
What's required to add those metrics? I'm willing to provide example data or gather the relevant queries.

a lot duplicate metrics when FRITZ_HOST_INFO is enabled

When enabling FRITZ_HOST_INFO the HTTP body gets large but also contains a lot of duplicate metrics.
This leads to an increase of factor 10 to 100 in http body size, normal exporter output is approx. 10k to 20k.

# ls -lh exporter-dump-7*
-rw-r--r--    1 root     root      111.8K Dec 29 03:27 exporter-dump-7370
-rw-r--r--    1 root     root      229.4K Dec 29 03:29 exporter-dump-7470
-rw-r--r--    1 root     root        1.0M Dec 29 03:27 exporter-dump-7570

I read the warning in about increased load when enabling FRITZ_HOST_INFO in https://github.com/pdreker/fritz_exporter/blob/develop/docs/configuration.rst
The increased load comes from more API calls to the fritzbox for host informations.

This has been observed with exporter version 2.1.6 deployed via docker on the following boxes:

  • FRITZ!Box 7590 07.50
  • FRITZ!Box 7430 07.29
  • FRITZ!Box 7490 07.29

See example from direct curl dump
(A bit anonymized: I applied sed -re 's/((serial|hostname|ip_address|mac_address)=)"[^"]+(....)"/\1"...\3"/g' to the output)

# curl $EXPORTER_URL | grep -v "^#" | sort | uniq -c | sort -n
...
     26 fritz_host_speed{hostname="...-k8s",interface="",ip_address="....105",mac_address="...D:0F",model="",port="0",serial="...C3A4"} 0.0
     27 fritz_host_active{hostname="...iene",interface="",ip_address="...3.18",mac_address="...F:A8",model="udhcp 1.30.1",port="0",serial="...C3A4"} 0.0
     27 fritz_host_speed{hostname="...iene",interface="",ip_address="...3.18",mac_address="...F:A8",model="udhcp 1.30.1",port="0",serial="...C3A4"} 0.0
     28 fritz_host_active{hostname="...7490",interface="",ip_address="...23.1",mac_address="...3:A4",model="",port="0",serial="...C3A4"} 1.0
     28 fritz_host_speed{hostname="...7490",interface="",ip_address="...23.1",mac_address="...3:A4",model="",port="0",serial="...C3A4"} 0.0
     29 fritz_host_active{hostname="...mmer",interface="",ip_address="....104",mac_address="...D:39",model="dhcpcd-6.8.2:Linux-3.8.13+:armv7l:Marvell",port="0",serial="...C3A4"} 0.0
     29 fritz_host_speed{hostname="...mmer",interface="",ip_address="....104",mac_address="...D:39",model="dhcpcd-6.8.2:Linux-3.8.13+:armv7l:Marvell",port="0",serial="...C3A4"} 0.0
     30 fritz_host_active{hostname="...eche",interface="",ip_address="....112",mac_address="...C:06",model="",port="0",serial="...C3A4"} 0.0
     30 fritz_host_speed{hostname="...eche",interface="",ip_address="....112",mac_address="...C:06",model="",port="0",serial="...C3A4"} 0.0
     31 fritz_host_active{hostname="...in10",interface="",ip_address="....111",mac_address="...5:93",model="",port="0",serial="...C3A4"} 0.0
     31 fritz_host_speed{hostname="...in10",interface="",ip_address="....111",mac_address="...5:93",model="",port="0",serial="...C3A4"} 0.0
     32 fritz_host_active{hostname="...t-03",interface="",ip_address="...3.83",mac_address="...D:40",model="",port="0",serial="...C3A4"} 0.0
     32 fritz_host_speed{hostname="...t-03",interface="",ip_address="...3.83",mac_address="...D:40",model="",port="0",serial="...C3A4"} 0.0
     33 fritz_host_active{hostname="...t-02",interface="",ip_address="...3.82",mac_address="...5:CB",model="",port="0",serial="...C3A4"} 0.0
     33 fritz_host_speed{hostname="...t-02",interface="",ip_address="...3.82",mac_address="...5:CB",model="",port="0",serial="...C3A4"} 0.0
     34 fritz_host_active{hostname="...t-01",interface="",ip_address="...3.81",mac_address="...F:D6",model="",port="0",serial="...C3A4"} 0.0
     34 fritz_host_speed{hostname="...t-01",interface="",ip_address="...3.81",mac_address="...F:D6",model="",port="0",serial="...C3A4"} 0.0
     35 fritz_host_active{hostname="...dolt",interface="",ip_address="...3.29",mac_address="...2:13",model="",port="0",serial="...C3A4"} 0.0
     35 fritz_host_speed{hostname="...dolt",interface="",ip_address="...3.29",mac_address="...2:13",model="",port="0",serial="...C3A4"} 0.0
     36 fritz_host_active{hostname="...j0ju",interface="",ip_address="....115",mac_address="...A:DC",model="",port="0",serial="...C3A4"} 0.0
     36 fritz_host_speed{hostname="...j0ju",interface="",ip_address="....115",mac_address="...A:DC",model="",port="0",serial="...C3A4"} 0.0
...

Make WiFi networks more discoverable/configurable

It may make sense to automatically detect how many WiFi networks are present in the output of the Box (at the moment the exporter simply expects 3 WLANConfigurationX blocks and checks, if they are viable.

Also the association is hardcoded for WLANConfiguration Blocks: 1->2.4GHz, 2->5GHz and 3->GuestWiFi. In #39 there is output for a guest wifi reported in the 5GHz block (disabled).

As an idea: make it configurable to map e.g. (SSID/WLANConfiguration Block Number/Serial)->WiFi-Type to be able to clean up the output to actually match reality. Keep the default as it is currently, as this seems to be the prevalent case, but enable other boxes with "weird output" to actually correctly label result metrics.

Docker-Container throws "Fatal Python error" on HypriotOS/armv7

Disclaimer: This is kind of a self-post to help others with the same issue in the future.

I'm running Prometheus, Grafana and a bunch of exporters on a Raspberry Pi 4 in Docker containers. I'm using Hypriot OS for that. When calling docker run -d -e FRITZ_EXPORTER_CONFIG="192.168.178.1,username,password" -p 9787:9787 --name fritz_exporter pdreker/fritz_exporter it fails with during startup with the following message: Fatal Python error: init_interp_main: can't initialize time.

I was able to work around that by starting in priviliged mode with docker run ... --privileged ..., but this is not working for docker build ... for example.

Exporter not starting on a FritzBox 4040 because of UPNPError 820

Disclaimer: Posting this as kind of a self-post to help anyone with a similar problem in the future.

When running the exporter and connecting to my FritzBox 4040 it immediately hangs up with a UPNPError with errorcode 820. This is simply the code for internal error. The stacktrace suggests that the exception occurs during FritzCapability::checkCapability.

Invalid Args Error with uncommented HostInfo

Hello there,

I'm trying to get the exporter running with detailed HostInfo but am getting the following error:

fritz-exporter    | 2022-03-17 19:49:39,415    DEBUG fritzexporter.fritzcapability | Capability HostInfo set to {self.present} on device {device.host}
fritz-exporter    | Traceback (most recent call last):
fritz-exporter    |   File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
fritz-exporter    |     return _run_code(code, main_globals, None,
fritz-exporter    |   File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
fritz-exporter    |     exec(code, run_globals)
fritz-exporter    |   File "/app/fritzexporter/__main__.py", line 74, in <module>
fritz-exporter    |     main()
fritz-exporter    |   File "/app/fritzexporter/__main__.py", line 58, in main
fritz-exporter    |     FritzDevice(dev['hostname'], dev['username'], dev['password'], dev['name']))
fritz-exporter    |   File "/app/fritzexporter/fritzdevice.py", line 35, in __init__
fritz-exporter    |     self.capabilities = FritzCapabilities(self)
fritz-exporter    |   File "/app/fritzexporter/fritzcapabilities.py", line 75, in __init__
fritz-exporter    |     self.checkPresent(device)
fritz-exporter    |   File "/app/fritzexporter/fritzcapabilities.py", line 99, in checkPresent
fritz-exporter    |     self.capabilities[c].checkCapability(device)
fritz-exporter    |   File "/app/fritzexporter/fritzcapabilities.py", line 46, in checkCapability
fritz-exporter    |     device.fc.call_action(svc, action)
fritz-exporter    |   File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/fritzconnection.py", line 227, in call_action
fritz-exporter    |     return self.soaper.execute(service, action_name, arguments)
fritz-exporter    |   File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 238, in execute
fritz-exporter    |     return handle_response(response)
fritz-exporter    |   File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 222, in handle_response
fritz-exporter    |     raise_fritzconnection_error(response)
fritz-exporter    |   File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 147, in raise_fritzconnection_error
fritz-exporter    |     raise exception(message)
fritz-exporter    | fritzconnection.core.exceptions.FritzArgumentError: UPnPError: 
fritz-exporter    | errorCode: 402
fritz-exporter    | errorDescription: Invalid Args
fritz-exporter    | LOG LEVEL READ FROM CONFIG

without the "HostInfo" Class everything is running fine.

any help would be appreciated :)

demo dashboard not working (grafana 8)?

i'm using the exporter in a docker container that seems to work okay, i've added the dashboard but all metrics are empty and also device dropdown (i've manually write the friendly name but nothing changed) is empty
image
something needs to be updated?

Exporter does not handle devices which disappear

If a configured device is unreachable for some reason the error handling is really bad. Basically it just throws an exception and dies.

This needs to be handled gracefully, ideally by just leaving an error message in the logs, report a status metric for all configured devices (so prometheus/alertmanager can notice the problem) and then not delivering the associated metrics, instead of "dropping dead".

No cable data for FritzBox 6660 Cable

Hi,

I'm trying to use this exporter to send my FritzBox 6660 Cable Data to Prometheus.
But unfortunately it looks like no Docsis related data is being transferred. Although I did not find a suitable Grafana dashboard for cable monitoring, I can't see any of the metrics in Prometheus UI.

I used the data donation tool, the ID is the following:
a37fbd2a-18fe-453f-9ce2-4bdc03754685

Maybe I'm doing something wrong?

Rework Credentials config

Current way of configuring credentials is a bit of mess. There are two different ways of doing it, for no real benefit (You could put the whole config string into a kubernetes secret with no ill effect, instead of separating out the password).

At the same time the "multi-device credentials" feels really awkward with the "sequence based" Env Var.

Ideas:

  1. a more elegant way of specifying Device Configs via Env vars.
  2. allow to use a config file (optional) for configuration. Still allow env vars if using the config file (env takes precedence)
  3. Document an example kubernetes setup (YAML files for K8s? Helm Chart?)

2.3.0 packaged, tests fine, doesn't start

I've packaged 2.3.0 for pkgsrc, and it passes the self tests:

tests/test_config.py ..........                                                                                                                 [ 16%]
tests/test_datadonation.py ...............                                                                                                      [ 41%]
tests/test_fritzdevice.py ..........................                                                                                            [ 85%]
tests/test_main.py .........                                                                                                                    [100%]

--------- coverage: platform netbsd10, python 3.11.7-final-0 ---------
Coverage XML written to file coverage.xml


================================================================= 60 passed in 0.55s ==================================================================

However, when I try starting fritzexporter, I just get an error:

# fritzexporter-3.11 
Traceback (most recent call last):
  File "/usr/pkg/bin/fritzexporter-3.11", line 8, in <module>
    sys.exit(__main__())
             ^^^^^^^^^^
TypeError: 'module' object is not callable
# cat /usr/pkg/bin/fritzexporter-3.11               
#!/usr/pkg/bin/python3.11
# -*- coding: utf-8 -*-
import re
import sys
from fritzexporter import __main__
if __name__ == "__main__":
    sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
    sys.exit(__main__())

I don't know what this means, do you know?

I also tried the other way that is mentioned on readthedocs:

python -m fritz_export_helper <FRITZ-IP> <USERNAME> <PASSWORD> <ServiceName> <ActionName> # Will output the data returned from the device in a readable format

but this gives

# python -m fritz_export_helper
/usr/pkg/bin/python3.11: No module named fritz_export_helper

and indeed, fritzexporter only installs a 'fritzexporter' module.

Possible implementation of Smart Home metrics?

Hi there,

is there any possibility which I'm not aware of, to get Smart Home metrics from FritzBox connected AVM / Dect devices?
There should be a TR64 interface for that.

Kind regards
Philip

Crash at start: 606 - Action Not Authorized

I am using the latest published docker version and a 6660 (cable).
From the logs, it seems that the connection is properly established but it breaks right after.

LOG LEVEL READ FROM CONFIG
2021-09-02 20:11:10,168     INFO fritzexporter | registering 192.168.178.1 to collector
2021-09-02 20:11:10,984     INFO fritzexporter.fritzdevice | Connection to 192.168.178.1 successful, reading capabilities
2021-09-02 20:11:10,984    DEBUG fritzexporter.fritzcapability | Capability DeviceInfo set to {self.present} on device {device.host}
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/fritzexporter/__main__.py", line 74, in <module>
    main()
  File "/app/fritzexporter/__main__.py", line 58, in main
    FritzDevice(dev['hostname'], dev['username'], dev['password'], dev['name']))
  File "/app/fritzexporter/fritzdevice.py", line 35, in __init__
    self.capabilities = FritzCapabilities(self)
  File "/app/fritzexporter/fritzcapabilities.py", line 75, in __init__
    self.checkPresent(device)
  File "/app/fritzexporter/fritzcapabilities.py", line 99, in checkPresent
    self.capabilities[c].checkCapability(device)
  File "/app/fritzexporter/fritzcapabilities.py", line 46, in checkCapability
    device.fc.call_action(svc, action)
  File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/fritzconnection.py", line 227, in call_action
    return self.soaper.execute(service, action_name, arguments)
  File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 238, in execute
    return handle_response(response)
  File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 222, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/local/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 147, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzSecurityError: UPnPError: 
errorCode: 606
errorDescription: Action Not Authorized

Extend Grafana dashboard to display "Daily Traffic"

Hi pdreker,

thank you for sharing your solution to gather informations from my FritzBox 7590 👍

In the past i've used another Grafana dashboard with a influx db in the backend. There i have also the Daily Traffic and total Download/Upload.

Is it possible to extend the dashboard to see this informations?

image

Best regards,
Buddinski88

Make devices have labels with a friendly name

Currently all devices are only recognizable vial their serial number, which is unique but not very easy to remember.

Make it possible to specify a name for each device, which will be put into a label called "friendly_name".

Counter for fritz_wan_data_bytes_total sometimes going backwards (not due to counter reset)

Hi,

this is probably not an issue with this exporter, but I'm hoping that someone here might have an idea on this. I have now experienced this with two different FBs (6591 Cable and 7530 AX) and not only with the fritz_exporter, but also with other means of collecting the metrics from the FB.

What I'm seeing are sometimes (1-2 times a day) slight decreases in the counter. I'm fully aware of the counter reset when the FB restarts or the counter overflows, but this is something different.

Here is an example with actual data that I'm seeing for tx:

3717324887 1691733188.52
3717616438 1691733248.52
3717611343 1691733308.52 <---
3717798920 1691733368.52
3718060786 1691733428.52

The values before and after clearly show that this is just a small hiccup. The connection (at least on tx side) would not even be able to produce 3.7 GB in one minute.

I don't really mind a small inaccuracy of a few kbs, but with that behavior I don't see a good way of distinguishing this from a real counter reset. increase() certainly produces confusing spikes with this.

Is this a known issue with FBs and are there ways to mitigate this? Does it help to increase the scrape_time?

Any feedback is very much appreciated!

Thanks,
Joerg

Fritzbox 7270 UPnPError: 402 Invalid Args

Hey there,

when using a FRITZ!Box Fon WLAN 7270 v3 i get the following error:

Exception has occurred: FritzArgumentError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
UPnPError: 
errorCode: 402
errorDescription: Invalid Args
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/soaper.py", line 191, in raise_fritzconnection_error
    raise exception(message)
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/soaper.py", line 268, in handle_response
    raise_fritzconnection_error(response)
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/soaper.py", line 286, in execute
    return handle_response(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/fritzconnection.py", line 441, in call_action
    return self.soaper.execute(service, action_name, arguments)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/volza/Projects/fritz_exporter/fritzexporter/fritzcapabilities.py", line 56, in checkCapability
    device.fc.call_action(svc, action)
  File "/home/volza/Projects/fritz_exporter/fritzexporter/fritzcapabilities.py", line 112, in check_present
    self.capabilities[c].checkCapability(device)
  File "/home/volza/Projects/fritz_exporter/fritzexporter/fritzcapabilities.py", line 87, in __init__
    self.check_present(device)
  File "/home/volza/Projects/fritz_exporter/fritzexporter/fritzdevice.py", line 39, in __init__
    self.capabilities = FritzCapabilities(self, host_info)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/volza/Projects/fritz_exporter/fritzexporter/__main__.py", line 92, in main
    fritz_device = FritzDevice(
                   ^^^^^^^^^^^^
  File "/home/volza/Projects/fritz_exporter/fritzexporter/__main__.py", line 128, in <module>
    main()
  File "/usr/lib/python3.11/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.11/runpy.py", line 198, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fritzconnection.core.exceptions.FritzArgumentError: UPnPError: 
errorCode: 402
errorDescription: Invalid Args

it happens right after

DEBUG fritzexporter.fritzcapability | Capability WanPPPConnectionStatus set to True on device fb-7270-01..local

so i could narrow down that commenting out the WanPPPConnectionStatus class "fixes" the breaking of the exporter at least.

The output of
fritzconnection -i fb-7270-01..local -s

fritzconnection v1.12.2
FRITZ!Box Fon WLAN 7270 v3 at http://fb-7270-01..local
FRITZ!OS: None

Servicenames:
                    any1
                    WANCommonIFC1
                    WANDSLLinkC1
                    WANIPConn1
                    DeviceInfo1
                    DeviceConfig1
                    Layer3Forwarding1
                    LANConfigSecurity1
                    ManagementServer1
                    Time1
                    UserInterface1
                    X_VoIP1
                    X_AVM-DE_Storage1
                    X_AVM-DE_OnTel1
                    X_AVM-DE_WebDAVClient1
                    X_AVM-DE_UPnP1
                    X_AVM-DE_RemoteAccess1
                    X_AVM-DE_MyFritz1
                    X_AVM-DE_TAM1
                    WLANConfiguration1
                    WLANConfiguration2
                    Hosts1
                    LANEthernetInterfaceConfig1
                    LANHostConfigManagement1
                    WANCommonInterfaceConfig1
                    WANDSLInterfaceConfig1
                    WANDSLLinkConfig1
                    WANEthernetLinkConfig1
                    WANPPPConnection1
                    WANIPConnection1

The output of fritzconnection -i fb-7270-01..local -S WANPPPConnection1

fritzconnection v1.12.2
FRITZ!Box Fon WLAN 7270 v3 at http://fb-7270-01..local
FRITZ!OS: None


Servicename:        WANPPPConnection1
Actionnames:
                    GetInfo
                    GetConnectionTypeInfo
                    SetConnectionType
                    GetStatusInfo
                    GetUserName
                    SetUserName
                    SetPassword
                    GetNATRSIPStatus
                    SetConnectionTrigger
                    ForceTermination
                    RequestConnection
                    GetGenericPortMappingEntry
                    GetSpecificPortMappingEntry
                    AddPortMapping
                    DeletePortMapping
                    GetExternalIPAddress
                    X_GetDNSServers
                    X_SetDNSServers
                    GetLinkLayerMaxBitRates
                    GetPortMappingNumberOfEntries
                    SetRouteProtocolRx
                    SetIdleDisconnectTime
                    X_AVM-DE_GetAutoDisconnectTimeSpan
                    X_AVM-DE_SetAutoDisconnectTimeSpan

The output of fritzconnection -i fb-7270-01..local -A WANPPPConnection1 GetStatusInfo

fritzconnection v1.12.2
FRITZ!Box Fon WLAN 7270 v3 at http://fb-7270-01..local
FRITZ!OS: None


Service:            WANPPPConnection1
Action:             GetStatusInfo
Parameters:

    Name                                  direction     data type

    NewConnectionStatus                      out ->     string
    NewLastConnectionError                   out ->     string
    NewUptime                                out ->     ui4

Running your helper script:

python3 -m fritz_export_helper fb-7270-01..local user password WANPPPConnection1 GetInfo   

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/volza/Projects/fritz_exporter/fritz_export_helper.py", line 26, in <module>
    result = fc.call_action(args.service, args.action)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/fritzconnection.py", line 441, in call_action
    return self.soaper.execute(service, action_name, arguments)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/soaper.py", line 286, in execute
    return handle_response(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/soaper.py", line 268, in handle_response
    raise_fritzconnection_error(response)
  File "/home/volza/Projects/fritz_exporter/.venv/lib/python3.11/site-packages/fritzconnection/core/soaper.py", line 191, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzArgumentError: UPnPError: 
errorCode: 402
errorDescription: Invalid Args

Sadly i did not really understand how to test further from here to maybe help including support for the broken WanPPPConnectionStatus or add X_VoIP1 for example.

Maybe you can use this info to build in some adjustments :)
Let me know if i can provide you somehow with additional Information.

monitor dyndns

Hello,
sometime my FritzBox looses the dyndns connection. I'm totally lost, because I cannot reach the box via VPN to do anything.
Is there a metric to monitor the dyndns ?

regard Christoph

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.