Search code examples
performanceloggingwgetpython-3.10

Get Mbps from wget -o logged output


I'm using wget inside Python to test internet speed. My goal is to track the latency throughout the download, so I need to know the Mbps at least every second during the download.

If I manually run script and then wget I get the desired output ...

--2022-06-20 04:14:13--  https://speed.hetzner.de/100MB.bin
Resolving speed.hetzner.de (speed.hetzner.de)... 88.198.248.254
Connecting to speed.hetzner.de (speed.hetzner.de)|88.198.248.254|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: ‘100MB.bin.9’

100MB.bin.9                         0%[                                                              ]       0  --.-KB/s               
100MB.bin.9                         0%[                                                              ] 119.69K   516KB/s               
100MB.bin.9                         0%[                                                              ] 231.69K   488KB/s               
100MB.bin.9                         0%[                                                              ] 343.69K   494KB/s               
100MB.bin.9                         0%[                                                              ] 423.69K   447KB/s               
100MB.bin.9                         0%[                                                              ] 519.69K   431KB/s         

But if I run wget <address> -o wget.log I get the follwowing...

Resolving speed.hetzner.de (speed.hetzner.de)... 88.198.248.254
Connecting to speed.hetzner.de (speed.hetzner.de)|88.198.248.254|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: ‘100MB.bin.7’

     0K .......... .......... .......... .......... ..........  0% 1.22M 82s
    50K .......... .......... .......... .......... ..........  0% 1.68M 71s
   100K .......... .......... .......... .......... ..........  0% 1.70M 67s
   150K .......... .......... .......... .......... ..........  0% 8.41M 53s
   200K .......... .......... .......... .......... ..........  0% 3.89M 47s
(snip)
102250K .......... .......... .......... .......... .......... 99% 3.45M 0s
102300K .......... .......... .......... .......... .......... 99% 2.86M 0s
102350K .......... .......... .......... .......... ..........100% 3.22M 0s
102400K                                                       100% 0.00 =30s

2022-06-20 03:44:11 (3.37 MB/s) - ‘100MB.bin.7’ saved [104857600/104857600]

What exactly does each column mean? For example in the lines...

50K .......... .......... .......... .......... ..........  0% 1.68M 71s
100K .......... .......... .......... .......... ..........  0% 1.70M 67s

Does the 1.68M mean that the first 50 Kilo(bytes?) of data was downloaded at 1.68Mega(bits?) per second, and the 1.70M means the next 50K was at 1.70Mbps?


Solution

  • GNU wget has 2 distinct ways of representing progress: thermometer and dot, 1st is used when output is TTY (as is your first example), writing to file is non-TTY, so you need to instruct GNU wget to use thermometer implicitly if you want first style written to file, that is

    wget --progress=bar:force <address> -o wget.log
    

    for more detailed description see --progress in wget man page