mxschmitt / fritzbox_exporter

Prometheus Exporter for FRITZ!Box (TR64 and UPnP)
https://mxschmitt.github.io/fritzbox_exporter
Apache License 2.0
58 stars 17 forks source link

Upload/Download Counters reset every 4GB #19

Closed detlevo closed 3 years ago

detlevo commented 4 years ago

The total upload and download counters are reset to 0 whenever they reach 4GB. What can be done about this?

tillepille commented 3 years ago

This is a problem of the fritzbox API. The counter resets, the closest I got was 4289894889 bytes. Which is conspiciously close to an uint32. But what I can see at my 6490 is a parameter called NewX_AVM_DE_TotalBytesReceived64 which seems to be a more reasonable value since boot.

@mxschmitt I do not get how the parsing of the SOAP response exactly works, For me the corresponding field for gateway_wan_bytes_received is named NewTotalBytesReceived but I don't see this keyword anywhere in the code. Maybe you can help out?

nachfuellbar commented 3 years ago

@tillepille https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/IGD1.pdf

He uses the Action GetAddonInfos which is described in the pdf https://github.com/mxschmitt/fritzbox_exporter/blob/b8526853a6f2a7cbb6f520d2a8d40e83b1a3fd90/cmd/exporter/exporter.go#L79-L80 I think you are probably right with your assumption about using NewX_AVM_DE_TotalBytesReceived64 - the corrospondending variable would be X_AVM_DE_TotalBytesReceived64

The same goes for https://github.com/mxschmitt/fritzbox_exporter/blob/b8526853a6f2a7cbb6f520d2a8d40e83b1a3fd90/cmd/exporter/exporter.go#L91-L92 which should probably be X_AVM_DE_TotalBytesSent64

mxschmitt commented 3 years ago

fixed in #22

nachfuellbar commented 3 years ago

I tried your updated image and it's not working for me - metrics say 0 for the received and sent values

gateway_wan_bytes_receive_rate{gateway="fritz.box"} 118485
gateway_wan_bytes_received{gateway="fritz.box"} 0
gateway_wan_bytes_send_rate{gateway="fritz.box"} 13387
gateway_wan_bytes_sent{gateway="fritz.box"} 0
gateway_wan_connection_status{gateway="fritz.box"} 1
gateway_wan_connection_uptime_seconds{gateway="fritz.box"} 52596
gateway_wan_layer1_downstream_max_bitrate{gateway="fritz.box"} 2.85305e+08
gateway_wan_layer1_link_status{gateway="fritz.box"} 1
gateway_wan_layer1_upstream_max_bitrate{gateway="fritz.box"} 4.441e+07
gateway_wan_packets_received{gateway="fritz.box"} 1.209051e+06
gateway_wan_packets_sent{gateway="fritz.box"} 5.960714e+06

Is this only happening for me? I thought of some possibilities why this would happen: 1) documentation is obsolete (says it's for fritz os 6.93 but i'm using the most recent version) 2) we need to change something else too 3) some unique error on my side

Buuuuut IDK After querying the upnp interface i got following output which seems like my PR should have been correct

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetAddonInfosResponse xmlns:u="urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1">
<NewByteSendRate>9893</NewByteSendRate>
<NewByteReceiveRate>19429</NewByteReceiveRate>
<NewPacketSendRate>0</NewPacketSendRate>
<NewPacketReceiveRate>0</NewPacketReceiveRate>
<NewTotalBytesSent>2416823644</NewTotalBytesSent>
<NewTotalBytesReceived>1461669881</NewTotalBytesReceived>
<NewAutoDisconnectTime>0</NewAutoDisconnectTime>
<NewIdleDisconnectTime>1</NewIdleDisconnectTime>
<NewDNSServer1>217.237.148.102</NewDNSServer1>
<NewDNSServer2>217.237.151.115</NewDNSServer2>
<NewVoipDNSServer1>217.237.148.102</NewVoipDNSServer1>
<NewVoipDNSServer2>217.237.151.115</NewVoipDNSServer2>
<NewUpnpControlEnabled>0</NewUpnpControlEnabled>
<NewRoutedBridgedModeBoth>1</NewRoutedBridgedModeBoth>
<NewX_AVM_DE_TotalBytesSent64>2416823644</NewX_AVM_DE_TotalBytesSent64>
<NewX_AVM_DE_TotalBytesReceived64>18641539065</NewX_AVM_DE_TotalBytesReceived64>
<NewX_AVM_DE_WANAccessType>DSL</NewX_AVM_DE_WANAccessType>
</u:GetAddonInfosResponse>
</s:Body>
</s:Envelope>
nachfuellbar commented 3 years ago

Small update I build the binary on my client and with this binary i get non zero values for X_AVM_DE_TotalBytesSent64 and X_AVM_DE_TotalBytesReceived64

Can somebody verify if the docker container is working for them?

Edit: correct the values to the right ones - accidentially used the prometheus ones ;)

mxschmitt commented 3 years ago

I will revert the last commit. a7c9b2a26c820c77a8a693760b4d4d262b274c16

Should be fixed on DockerHub in a few minutes.

nachfuellbar commented 3 years ago

Sample Output from ./exporter -stdout for me

  GetAddonInfos
    ByteSendRate: 4904
    ByteReceiveRate: 2758
    PacketSendRate: 0
    PacketReceiveRate: 0
    TotalBytesSent: 3265010469
    TotalBytesReceived: 338633081
    AutoDisconnectTime: 0
    IdleDisconnectTime: 0
    DNSServer1: 217.237.148.102
    DNSServer2: 217.237.151.115
    VoipDNSServer1: 217.237.148.102
    VoipDNSServer2: 217.237.151.115
    UpnpControlEnabled: false
    RoutedBridgedModeBoth: 1
    X_AVM_DE_TotalBytesSent64: 3265010469
    X_AVM_DE_TotalBytesReceived64: 17518502265
    X_AVM_DE_WANAccessType: DSL
nachfuellbar commented 3 years ago

New pull request available AVM formats both as a string which was the source of the problem

PR https://github.com/mxschmitt/fritzbox_exporter/pull/24