mcktr / check_fritz

Check plugin written in Go to monitor a Fritz!Box
GNU General Public License v2.0
32 stars 10 forks source link

cable speed seems to be incorrectly reported #72

Closed dirkpauli closed 4 years ago

dirkpauli commented 4 years ago

I use an FB 6591 Cable with Fritz!OS 7.12. On the overview page, the cable speed is shown as 57,5 MBit don / 53 MBit up; nevertheless, the plugin reports downstream_max as 62,48 MBit/s and upstream_max as 34,24 MBit

mcktr commented 4 years ago

Hi,

which overview page do you mean? The Internet -> Online Monitor page shows two values (at least for DSL).

Bildschirmfoto von 2019-12-09 20-15-41

The values marked with blue are for the internet connection line, this is the speed which is theoretically possible on this line. The values marked with red is the actual internet connection speed which I booked at my provider. The red values indicates my download/upload speed.

May you can add a screenshot to better indicate what values you mean. If so please blur the sensitive information such as IP address, passwords, etc.

mcktr commented 4 years ago

Please also have a look if the output from the plugin and the max numbers from the graphs under Internet -> Online Monitor correlate. I may have a suspicion. The functions upstream_max and downstream_max uses the Online Monitor values to calculate the max downstream/upstream speed.

Bildschirmfoto von 2019-12-09 20-36-43

uclara commented 4 years ago

Hi, since a few weeks I switched from a FRITZ!Box Cable 6490 to a FRITZ!Box Cable 6591 and Updated my contract from 400/50Mbit/s to 1000/50Mbit/s.

The Downstream is displayed with 5.416 K and the Upstream with 273.

image

Ulli

mcktr commented 4 years ago

@dirkpauli @uclara I will have a look into this! Since I don't have access to a cable connection can I ask you to test possible patches? :-)

uclara commented 4 years ago

Anytime :-)

mcktr commented 4 years ago

@uclara Thanks! :+1: Unfortunately there is currently no way to collect debug information. The implementation for a debug mode depends on #79. As soon as I have the debug mode ready I'll provide a pre-release version for v1.2.0 than we can begin to debug this. The final v1.2.0 will definitely not be released until this bug is fixed.

Maybe you can test the old bash script and verify if the cable speed is also reported wrong. If it works with the bash script this would indicate a bug in the Go implementation otherwise AVM changed something in the Fritz!Box API.

Bash Script: https://github.com/mcktr/check_tr64_fritz

uclara commented 4 years ago

@mcktr sorry for the delay ...

these are my results with my FRITZ!Box 6591 Cable, FRITZ!OS-Version: 07.13

Tested with check_tr64_fritz (Version 2.1)

./check_tr64_fritz -h <IP-Address> -P <Password> -f status:cable
OK - Connected | 'status'=0;;;;
./check_tr64_fritz -h <IP-Address> -P <Password> -f linkuptime:cable
OK - Link Uptime 1703470 seconds (19d 17h 11m 10s) | 'linkuptime'=1703470s;;;;
./check_tr64_fritz -h <IP-Address> -P <Password> -f uptime
OK - Uptime 5066482 seconds (58d 15h 21m 22s) | 'uptime'=5066482s;;;;
./check_tr64_fritz -h <IP-Address> -P <Password> -f downstream
OK - Downstream 4012 Mbit/s | 'downstream_rate'=4012;;;;
./check_tr64_fritz -h <IP-Address> -P <Password> -f upstream
OK - Upstream 61 Mbit/s | 'upstream_rate'=61;;;;
./check_tr64_fritz -h <IP-Address> -P <Password> -f downstreamrate
OK - Current Downstream 0.25 Mbit/s | 'current_downstream'=0.25;;;;
./check_tr64_fritz -h <IP-Address> -P <Password> -f upstreamrate
OK - Current Upstream 0.07 Mbit/s | 'current_upstream'=0.07;;;;
./check_tr64_fritz -h <IP-Address> -P <Password> -f update
OK - No Upgrade available | 'update_pending'=0;;;;

The Down- and Uplink speed reported by FRITZ!OS GUI is the following:

Bildschirmfoto 2020-05-24 um 18 32 52

for comparison the values I got via check_fritz (v1.1.0)

./check_fritz -H <IP-Address> -M Cable -p <Password> -m connection_status
OK - Connection Status: Connected; External IP: 188.193.68.10
./check_fritz -H <IP-Address> -M Cable -p <Password> -m connection_uptime
OK - Connection Uptime: 1706027 seconds (19d 17h 53m 47s) | 'uptime'=1706027.000000s;;;;
./check_fritz -H <IP-Address> -M Cable -p <Password> -m device_uptime
OK - Device Uptime: 5069043 seconds (58d 16h 4m 3s) | 'uptime'=5069043.000000s;;;;
./check_fritz -H <IP-Address> -M Cable -p <Password> -m device_update
OK - No update available
./check_fritz -H <IP-Address> -M Cable -p <Password> -m downstream_max
OK - Max Downstream: 4012.90 Mbit/s | 'downstream_max'=4012.900856;;;;
./check_fritz -H <IP-Address> -M Cable -p <Password> -m downstream_current
OK - Current Downstream: 0.07 Mbit/s | 'downstream_current'=0.067816;;;;
./check_fritz -H <IP-Address> -M Cable -p <Password> -m downstream_usage
OK - 0.00% Downstream utilization (0.07 Mbit/s of 4012.90 Mbits) | 'downstream_usage'=0.001757;;;0.000000;100.000000
./check_fritz -H <IP-Address> -M Cable -p <Password> -m upstream_max
OK - Max Upstream: 61.96 Mbit/s | 'upstream_max'=61.956360;;;;
./check_fritz -H <IP-Address> -M Cable -p <Password> -m upstream_current
OK - Current Upstream: 0.07 Mbit/s | 'upstream_current'=0.074096;;;;
./check_fritz -H <IP-Address> -M Cable -p <Password> -m upstream_usage
OK - 0.18% Upstream utilization (0.11 Mbit/s of 61.96 Mbits) | 'upstream_usage'=0.177067;;;0.000000;100.000000
mcktr commented 4 years ago

@uclara No worries, I am currently also short on time :-)

The results look identical, this is not good. But I am sure we can figure this out.

I just learned that there can be multiple sync groups for one internet connection. For example I have one sync group on my VDSL connection with the ID 0. In the code I just query the sync group with ID 0 and calculate the downstream/upstream. If now for some reason a cable connection has two sync groups and the sync group with ID 0 is used for something different this can lead to wrong downstream/upstream speed calculation as the other sync groups with other IDs are not queried.

I put in a little development sprint to create a version of this check plugin to identify and debug this issue. :-)

The debug version is based on the latest master branch including the changes from the branch debug/downstream-speed-d1, the changes can be found here: https://github.com/mcktr/check_fritz/commit/fcbe63de1df310f6980d804e6aeeb04d77d3d96b

Basically what this does it queries all sync groups and outputs a bunch of debug information. Can you please test this version? You can download a ZIP archive containing the binary from the following URL:

https://github.com/mcktr/check_fritz/actions/runs/115055209

Just select check_fritz.ubuntu-latest_1.14.x for a Linux based system. After downloading unzip the binary and give permissions to run the binary with chmod +x check_fritz. Now you can run the binary with the --debug parameter.

./check_fritz -p [PASSWORD] -m downstream_max --debug

The full debug function with querying all sync groups is only implemented in the downstream_max method.

Please share the full debug output here.

Thanks! :+1:

uclara commented 4 years ago

@mcktr I tested the version mentioned in your post and got the following result:

OK - Max Downstream: 1150.00 Mbit/s | 'downstream_max'=1150.000000;;;;

It matches perfectly what the FRITZ!Box 6591 Cable, FRITZ!OS-Version: 07.13 displays as the max downstream rate.

But unfortunately the --debug option fails:

error: unknown option "debug"

Update (June, 7th): what I also noticed is that the "Max Downstream: 1150.00 Mbit/s" ist displayed correctly, regardless of whether I use the old version

./check_fritz -V
check_fritz v1.1.0

./check_fritz -v
Incorrect Usage. flag provided but not defined: -v

or the new check_fritz, that you sent me for testing

./check_fritz -V
check_fritz version 1.1.0

./check_fritz -v
NAME:

  check_fritz - Check plugin to monitor a Fritz!Box

USAGE:
   check_fritz [options...]

OPTIONS:

  --hostname value, -H value  Specifies the hostname. (default: fritz.box)
  --port value, -P value      Specifies the SSL port. (default: 49443)
  ...

Ulli

uclara commented 4 years ago

I tested the debug option again and today I was able to get the desired output (obviously I did something wrong the last time)

~/local/lib/monitoring-plugins$ ./check_fritz -H <FRITZ!Box IP> -p <Password> -m downstream_max --debug
---
Frist SOAP Response:
---
<HTML><HEAD><TITLE>401 Unauthorized (ERR_NONE)</TITLE></HEAD><BODY><H1>401 Unauthorized</H1><BR>ERR_NONE<HR><B>Webserver</B> Sun, 07 Jun 2020 19:45:46 GMT</BODY></HTML>

---
---
Second SOAP Response:
---
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:X_AVM-DE_GetOnlineMonitorResponse xmlns:u="urn:dslforum-org:service:WANCommonInterfaceConfig:1">
<NewTotalNumberSyncGroups>2</NewTotalNumberSyncGroups>
<NewSyncGroupName>sync_cable</NewSyncGroupName>
<NewSyncGroupMode>CABLE</NewSyncGroupMode>
<Newmax_ds>143750000</Newmax_ds>
<Newmax_us>7088750</Newmax_us>
<Newds_current_bps>211773,34010,29449,16941,26092,41514,42283,53187,22083,51471,29240,63215,37571,38122,21615,51258,5700,26446,8608,526700</Newds_current_bps>
<Newmc_current_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newmc_current_bps>
<Newus_current_bps>20803,19330,11182,8327,5704,23954,19830,26384,13063,14562,14219,14095,12206,18383,8520,11006,5784,8165,10704,25096</Newus_current_bps>
<Newprio_realtime_bps>769,1149,1685,878,798,704,728,610,617,654,464,949,646,971,1113,1096,984,634,921,571</Newprio_realtime_bps>
<Newprio_high_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newprio_high_bps>
<Newprio_default_bps>20034,18181,9497,7449,4906,23250,19102,25774,12446,13908,13755,13146,11560,17412,7407,9910,4800,7531,9783,24525</Newprio_default_bps>
<Newprio_low_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newprio_low_bps>
</u:X_AVM-DE_GetOnlineMonitorResponse>
</s:Body>
</s:Envelope>
---
---
Frist SOAP Response:
---
<HTML><HEAD><TITLE>401 Unauthorized (ERR_NONE)</TITLE></HEAD><BODY><H1>401 Unauthorized</H1><BR>ERR_NONE<HR><B>Webserver</B> Sun, 07 Jun 2020 19:45:46 GMT</BODY></HTML>

---
---
Second SOAP Response:
---
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:X_AVM-DE_GetOnlineMonitorResponse xmlns:u="urn:dslforum-org:service:WANCommonInterfaceConfig:1">
<NewTotalNumberSyncGroups>2</NewTotalNumberSyncGroups>
<NewSyncGroupName>sync_cable</NewSyncGroupName>
<NewSyncGroupMode>CABLE</NewSyncGroupMode>
<Newmax_ds>143750000</Newmax_ds>
<Newmax_us>7088750</Newmax_us>
<Newds_current_bps>211773,34010,29449,16941,26092,41514,42283,53187,22083,51471,29240,63215,37571,38122,21615,51258,5700,26446,8608,526700</Newds_current_bps>
<Newmc_current_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newmc_current_bps>
<Newus_current_bps>20803,19330,11182,8327,5704,23954,19830,26384,13063,14562,14219,14095,12206,18383,8520,11006,5784,8165,10704,25096</Newus_current_bps>
<Newprio_realtime_bps>769,1149,1685,878,798,704,728,610,617,654,464,949,646,971,1113,1096,984,634,921,571</Newprio_realtime_bps>
<Newprio_high_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newprio_high_bps>
<Newprio_default_bps>20034,18181,9497,7449,4906,23250,19102,25774,12446,13908,13755,13146,11560,17412,7407,9910,4800,7531,9783,24525</Newprio_default_bps>
<Newprio_low_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newprio_low_bps>
</u:X_AVM-DE_GetOnlineMonitorResponse>
</s:Body>
</s:Envelope>
---
*** DEBUG downstream 1150.000000, Sync Group Name: 'sync_cable', Counter: 0 ***
---
Frist SOAP Response:
---
<HTML><HEAD><TITLE>401 Unauthorized (ERR_NONE)</TITLE></HEAD><BODY><H1>401 Unauthorized</H1><BR>ERR_NONE<HR><B>Webserver</B> Sun, 07 Jun 2020 19:45:46 GMT</BODY></HTML>

---
---
Second SOAP Response:
---
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:X_AVM-DE_GetOnlineMonitorResponse xmlns:u="urn:dslforum-org:service:WANCommonInterfaceConfig:1">
<NewTotalNumberSyncGroups>2</NewTotalNumberSyncGroups>
<NewSyncGroupName>sync_lan0</NewSyncGroupName>
<NewSyncGroupMode>ATA</NewSyncGroupMode>
<Newmax_ds>128000</Newmax_ds>
<Newmax_us>12499875</Newmax_us>
<Newds_current_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newds_current_bps>
<Newmc_current_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newmc_current_bps>
<Newus_current_bps>19098,19428,14004,6774,9017,18253,21593,28422,12199,13127,16156,12878,11696,18726,8782,10501,7042,8054,10647,25761</Newus_current_bps>
<Newprio_realtime_bps>848,988,1581,1019,922,665,828,604,497,757,391,925,682,830,1121,1288,904,638,898,689</Newprio_realtime_bps>
<Newprio_high_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newprio_high_bps>
<Newprio_default_bps>18250,18440,12423,5755,8095,17588,20765,27818,11702,12370,15765,11953,11014,17896,7661,9213,6138,7416,9749,25072</Newprio_default_bps>
<Newprio_low_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newprio_low_bps>
</u:X_AVM-DE_GetOnlineMonitorResponse>
</s:Body>
</s:Envelope>
---
*** DEBUG downstream 1.024000, Sync Group Name: 'sync_lan0', Counter: 1 ***
OK - Max Downstream: 1150.00 Mbit/s | 'downstream_max'=1150.000000;;;;