kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
304 stars 59 forks source link

GetTotalBytesReceived is resetted after ~4.23GB #61

Closed SeaLife closed 3 years ago

SeaLife commented 3 years ago

Hello!

im using https://github.com/pdreker/fritzbox_exporter to export fritz!box data to my prometheus instance. For some reason, the data returned by GetTotalBytesReceived in NewTotalBytesReceived is resetted after ~4.23GB. Can i somehow prevent this?

The code the exporter uses (conn is a instance of fc.FritzConnection):

        fritzbox_wan_result = self.conn.call_action('WANCommonInterfaceConfig:1', 'GetTotalBytesReceived')
        wan_bytes_rx = fritzbox_wan_result['NewTotalBytesReceived']
Bildschirmfoto 2020-07-21 um 20 33 14

Regards SeaLife

seven0fx commented 3 years ago

try:

fritzbox_wan_result = self.conn.call_action('WANCommonIFC1', 'GetAddonInfos')

wan_bytes_rx = fritzbox_wan_result['NewX_AVM_DE_TotalBytesReceived64']

and see this https://github.com/kbr/fritzconnection/issues/20

SeaLife commented 3 years ago

Hey! Thanks, the counter is above 4.23GB, but for some reason, it differs from the metric displayed in the Fritz!Box UI.

(Grafana shows ~15 GB) image

(Today at ~20GB) image

//EDIT:

I resetted the "Online Zähler" in the UI of the Box and the Metric returned by the API call remains at the value given before... Im confused now :D

kbr commented 3 years ago

It's not documented, but it seems that 'NewX_AVM_DE_TotalBytesReceived64' returns the number of bytes since the system start (I don't know whether it is reset by a restart). The UI displays the bytes for time ranges - these are different numbers.

SeaLife commented 3 years ago

Okay, so, after modifying the code to use the other values, its kinda working. I can assure, that the value resets after the "Zwangstrennung" (force disconnect from the ISP).

At the weekend, i'll probably open a PR to "fix" the metrics in the exporter, hopefully, the dude is still maintaining the repository. :D

This is probably closed. :)

Thanks. :)

kbr commented 3 years ago

As it seems to be resolved and there are no more comments, I like to close the issue.