Coder Social home page Coder Social logo

speedtest-cli's Introduction

LibreSpeed Logo

LibreSpeed command line tool

Don't have a GUI but want to use LibreSpeed servers to test your Internet speed? ๐Ÿš€

librespeed-cli comes to rescue!

This is a command line interface for LibreSpeed speed test backends, written in Go.

Features

  • Ping
  • Jitter
  • Download
  • Upload
  • IP address
  • ISP Information
  • Result sharing (telemetry) [optional]
  • Test with multiple servers in a single run
  • Use your own server list or telemetry endpoints
  • Tested with PHP and Go backends

asciicast

Requirements for compiling

  • Go 1.14+

Runtime requirements

Use prebuilt binaries

If you don't want to build librespeed-cli yourself, you can find different binaries compiled for various platforms in the releases page.

Building librespeed-cli

  1. First, you'll have to install Go (at least version 1.11). For Windows users, you can download an installer from golang.org. For Linux users, you can use either the archive from golang.org, or install from your distribution's package manager.

    For example, Arch Linux:

    # pacman -S go
    
  2. Then, clone the repository:

    $ git clone -b v1.0.0 https://github.com/librespeed/speedtest-cli
    
  3. After you have Go installed on your system (and added to your $PATH if you're using the archive from golang.org), you can now proceed to build librespeed-cli with the build script:

    $ cd speedtest-cli
    $ ./build.sh
    

    If you want to build for another operating system or system architecture, use the GOOS and GOARCH environment variables. Run go tool dist list to get a list of possible combinations of GOOS and GOARCH.

    Note: Technically, the CLI can be compiled with older Go versions that support Go modules, with GO111MODULE=on set. If you're compiling with an older Go runtime, you might have to change the Go version in go.mod.

    # Let's say we're building for 64-bit Windows on Linux
    $ GOOS=windows GOARCH=amd64 ./build.sh
    
  4. When the build script finishes, if everything went smoothly, you can find the built binary under directory out.

    $ ls out
    librespeed-cli-windows-amd64.exe
    
  5. Now you can use the librespeed-cli and test your Internet speed!

Install from AUR

To install librespeed-cli from AUR, use your favorite AUR helper and install package librespeed-cli-bin

$ yay librespeed-cli-bin

... or, clone it and build it yourself:

$ git clone https://aur.archlinux.org/librespeed-cli-bin.git
$ cd librespeed-cli-bin
$ makepkg -si

Install from Homebrew

See the librespeed-cli Homebrew tap.

Install on Windows

If you have either Scoop or Chocolatey installed you can use one of the following commands:

  • Scoop (ensure you have the extras bucket added):

    > scoop install librespeed-cli
    
  • Chocolatey:

    > choco install librespeed-cli
    

Container Image

You can run librespeed-cli in a container.

  1. Build the container image:

    docker build -t librespeed-cli:latest .
    
  2. Run the container:

    docker run --rm --name librespeed-cli librespeed-cli:latest
    # With options
    docker run --rm --name librespeed-cli librespeed-cli:latest --telemetry-level disabled --no-upload
    # To avoid "Failed to ping target host: socket: permission denied" errors when using --verbose
    docker run --rm --name librespeed-cli --sysctl net.ipv4.ping_group_range="0 2147483647" librespeed-cli:latest --verbose
    

Usage

You can see the full list of supported options with librespeed-cli -h:

$ librespeed-cli -h
NAME:
   librespeed-cli - Test your Internet speed with LibreSpeed ๐Ÿš€

USAGE:
   librespeed-cli [global options] [arguments...]

GLOBAL OPTIONS:
   --help, -h                     show help (default: false)
   --version                      Show the version number and exit (default: false)
   --ipv4, -4                     Force IPv4 only (default: false)
   --ipv6, -6                     Force IPv6 only (default: false)
   --no-download                  Do not perform download test (default: false)
   --no-upload                    Do not perform upload test (default: false)
   --no-icmp                      Do not use ICMP ping. ICMP doesn't work well under Linux
                                  at this moment, so you might want to disable it (default: false)
   --concurrent value             Concurrent HTTP requests being made (default: 3)
   --bytes                        Display values in bytes instead of bits. Does not affect
                                  the image generated by --share, nor output from
                                  --json or --csv (default: false)
   --mebibytes                    Use 1024 bytes as 1 kilobyte instead of 1000 (default: false)
   --distance value               Change distance unit shown in ISP info, use 'mi' for miles,
                                  'km' for kilometres, 'NM' for nautical miles (default: "km")
   --share                        Generate and provide a URL to the LibreSpeed.org share results
                                  image, not displayed with --csv (default: false)
   --simple                       Suppress verbose output, only show basic information
                                  (default: false)
   --csv                          Suppress verbose output, only show basic information in CSV
                                  format. Speeds listed in bit/s and not affected by --bytes
                                  (default: false)
   --csv-delimiter CSV_DELIMITER  Single character delimiter (CSV_DELIMITER) to use in
                                  CSV output. (default: ",")
   --csv-header                   Print CSV headers (default: false)
   --json                         Suppress verbose output, only show basic information
                                  in JSON format. Speeds listed in bit/s and not
                                  affected by --bytes (default: false)
   --list                         Display a list of LibreSpeed.org servers (default: false)
   --server SERVER                Specify a SERVER ID to test against. Can be supplied
                                  multiple times. Cannot be used with --exclude
   --exclude EXCLUDE              EXCLUDE a server from selection. Can be supplied
                                  multiple times. Cannot be used with --server
   --server-json value            Use an alternative server list from remote JSON file
   --local-json value             Use an alternative server list from local JSON file,
                                  or read from stdin with "--local-json -".
   --source SOURCE                SOURCE IP address to bind to
   --timeout TIMEOUT              HTTP TIMEOUT in seconds. (default: 15)
   --duration value               Upload and download test duration in seconds (default: 15)
   --chunks value                 Chunks to download from server, chunk size depends on server configuration (default: 100)
   --upload-size value            Size of payload being uploaded in KiB (default: 1024)
   --secure                       Use HTTPS instead of HTTP when communicating with
                                  LibreSpeed.org operated servers (default: false)
   --skip-cert-verify             Skip verifying SSL certificate for HTTPS connections (self-signed certs) (default: false)
   --no-pre-allocate              Do not pre allocate upload data. Pre allocation is
                                  enabled by default to improve upload performance. To
                                  support systems with insufficient memory, use this
                                  option to avoid out of memory errors (default: false)
   --telemetry-json value         Load telemetry server settings from a JSON file. This
                                  options overrides --telemetry-level, --telemetry-server,
                                  --telemetry-path, and --telemetry-share. Implies --share
   --telemetry-level value        Set telemetry data verbosity, available values are:
                                  disabled, basic, full, debug. Implies --share
   --telemetry-server value       Set the telemetry server base URL. Implies --share
   --telemetry-path value         Set the telemetry upload path. Implies --share
   --telemetry-share value        Set the telemetry share link path. Implies --share
   --telemetry-extra value        Send a custom message along with the telemetry results.
                                  Implies --share

Use a custom backend server list

The librespeed-cli supports loading custom backend server list from a JSON file (remotely via --server-json or locally via --local-json). The format is as below:

[
  {
    "id": 1,
    "name": "PHP Backend",
    "server": "https://example.com/",
    "dlURL": "garbage.php",
    "ulURL": "empty.php",
    "pingURL": "empty.php",
    "getIpURL": "getIP.php"
  },
  {
    "id": 2,
    "name": "Go Backend",
    "server": "http://example.com/speedtest/",
    "dlURL": "garbage",
    "ulURL": "empty",
    "pingURL": "empty",
    "getIpURL": "getIP"
  }
]

The --local-json option can also read from stdin:

echo '[{"id": 1,"name": "a","server": "https://speedtest.example.com/","dlURL": "garbage.php","ulURL": "empty.php","pingURL": "empty.php","getIpURL": "getIP.php"}]' | librespeed-cli --local-json -

As you can see in the example, all servers have their schemes defined. In case of undefined scheme (e.g. //example.com), librespeed-cli will use http by default, or https when the --secure option is enabled.

Use a custom telemetry server

By default, the telemetry result will be sent to librespeed.org. You can also customize your telemetry settings via the --telemetry prefixed options. In order to load a custom telemetry endpoint configuration, you'll have to use the --telemetry-json option to specify a local JSON file containing the configuration bits. The format is as below:

{
  "telemetryLevel": "full",
  "server": "https://example.com",
  "path": "/results/telemetry.php",
  "shareURL": "/results/"
}

For telemetryLevel, four values are available:

  • disabled to disable telemetry
  • basic to enable telemetry with result only)
  • full to enable telemetry with result and timing
  • debug to enable the most verbose telemetry information

server defines the base URL for the backend's endpoints. path is the path for uploading the telemetry result, and shareURL is the path for fetching the uploaded result in PNG format.

Currently, --telemetry-json only supports loading a local JSON file.

Bugs?

Although we have tested the cli, it's still in its early days. Please open an issue if you encounter any bugs, or even better, submit a PR.

How to contribute

If you have some good ideas on improving librespeed-cli, you can always submit a PR via GitHub.

License

librespeed-cli is licensed under GNU Lesser General Public License v3.0

speedtest-cli's People

Contributors

adolfintel avatar andonome avatar blnprasad avatar ciscoski avatar dbrennand avatar dopstar avatar driesmp avatar maddie avatar mildis avatar servidge avatar tech189 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  avatar  avatar  avatar  avatar

speedtest-cli's Issues

Auto-select choosing a number of non-functional servers and failing when there are working servers close by

Running the command with auto-select server option, the test tries a number of servers that do not work and then the test fails.
Here is the verbose output:

Selecting the fastest server based on ping
Error checking for server status: Get "https://il1.us.backend.librespeed.org/empty.php": dial tcp 134.195.89.225:443: connect: connection refused
Server Chicago, United States (HostHatch) (il1.us.backend.librespeed.org) doesn't seem to be up, skipping
Error checking for server status: Get "https://fc81600e6362286791bf6e06fb9d1cd4.librespeed.de/backend/empty.php": dial tcp: lookup fc81600e6362286791bf6e06fb9d1cd4.librespeed.de: no such host
Server Frankfurt, Germany (active-servers) (fc81600e6362286791bf6e06fb9d1cd4.librespeed.de) doesn't seem to be up, skipping
Server Frankfurt, Germany (Clouvider) (fra.speedtest.clouvider.net) doesn't seem to be up, skipping
Error checking for server status: Get "http://speedtest.linkedtech.es/backend/empty.php": dial tcp: lookup speedtest.linkedtech.es: no such host
Server Madrid, Spain (Linked Tech Network) (speedtest.linkedtech.es) doesn't seem to be up, skipping
Error checking for server status: Get "https://lv1.backend.librespeed.nixnet.services/empty.php": remote error: tls: internal error
Server Las Vegas, United States (BuyVM) (lv1.backend.librespeed.nixnet.services) doesn't seem to be up, skipping
Error checking for server status: Get "https://la1.us.backend.librespeed.org/empty.php": dial tcp 185.198.26.89:443: connect: connection refused
Server Los Angeles, United States (2) (HostHatch) (la1.us.backend.librespeed.org) doesn't seem to be up, skipping
Error checking for server status: Get "https://ny2.us.backend.librespeed.org/empty.php": dial tcp 134.195.90.126:443: connect: connection refused
Server New York, United States (3) (HostHatch) (ny2.us.backend.librespeed.org) doesn't seem to be up, skipping
No ICMP pings returned for server Helsinki, Finland (3) (Hetzner) (finew.openspeed.org), trying TCP ping
Error checking for server status: Get "https://lux1.backend.librespeed.nixnet.services/empty.php": remote error: tls: internal error
Server Roost, Luxembourg (BuyVM) (lux1.backend.librespeed.nixnet.services) doesn't seem to be up, skipping
No ICMP pings returned for server Poznan, Poland (INEA) (speedtest.kamilszczepanski.com), trying TCP ping
Server Tokyo, Japan (A573) (librespeed.a573.net) doesn't seem to be up, skipping
Server West Europe (Azure) (ls.sergiomeloni.com) doesn't seem to be up, skipping
Error checking for server status: Get "http://in1.backend.librespeed.org/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Error checking for server status: Get "http://nl1.backend.librespeed.org/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Server Bangalore, India (DigitalOcean) (in1.backend.librespeed.org) doesn't seem to be up, skipping
Server Alblasserdam, Netherlands (RamNode) (nl1.backend.librespeed.org) doesn't seem to be up, skipping
Error checking for server status: Get "https://sxb.bandspeed.de/backend/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Server Strasbourg, France (Host Europe) (sxb.bandspeed.de) doesn't seem to be up, skipping
Selected server: Alblasserdam, Netherlands (RamNode) [nl1.backend.librespeed.org]
Sponsored by: RamNode @ https://www.ramnode.com/
Error checking for server status: Get "http://nl1.backend.librespeed.org/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Selected server Alblasserdam, Netherlands (RamNode) (nl1.backend.librespeed.org) is not responding at the moment, try again later

I am running this test from Cape Town, South Africa. There is a server in Johannesburg that works perfectly. If I specify to use that server, the test works

Selected server: Johannesburg, South Africa (Host Africa) [za1.backend.librespeed.org]
Sponsored by: HOSTAFRICA @ https://www.hostafrica.co.za
You're testing from: 197.93.145.238 - Dimension Data, ZA (1270 km)
Ping: 42 ms	Jitter: 11 ms
Download rate:	19.03 Mbps
Upload rate:	66.12 Mbps

How does the test choose the order in which servers are tried and why does it stop trying when there are, in fact, working servers?

Results very different from web version?

Running the cli vs the web version against the same self hosted server, I see very different results on the slower side from the cli...

Is this to be expected for any reason?

cliVsWebSpeedtestresults2020-03-12_8-54-59

[SOLVED] "private" Server xxx is not responding at the moment. Try again later

Hi, I have a problem with speedtest-cli not contactibg local private librespeed host,

  • set up a standalone librespeed server as a container on a synology NAS, running as http://192.168.1.220:80

  • tried from several web client on local networkand it works fine

  • set up an ubuntu desktop client as 192.168.1.24: web librespeed to local server works ok

  • on the same ubuntu desktop installed librespeed-cli_1.0.7_linux_amd64.tar.gz: tested with generic librespeed internet hosts and works fine

  • set up in ubuntu desktop a servers-json file with local librespeed server info,
    -[
    {
    "id": 1,
    "name": "PHP Backend",
    "server": "//192.168.1.220/",
    "dlURL": "garbage.php",
    "ulURL": "empty.php",
    "pingURL" :"empty.php",
    "getIpURL": "getIP.php"
    }
    ]

  • launched librespeed against local server
    labadmin@UBUDSK2004:/librespeed$ sudo ./librespeed-cli --local-json servers-json --server 1
    [sudo] password for labadmin:
    Using local JSON server list: servers-json
    Selected server: PHP Backend [192.168.1.220]
    Selected server PHP Backend (192.168.1.220) is not responding at the moment, try again later
    labadmin@UBUDSK2004:
    /librespeed$

  • ping from 192.168.1.24 to 192.168.1.220 are ok

  • curl from 192.168.1.24 to http://192.168.1.200 returns the librespeed landing page.

where i made the mistake installing/configuring librespeed-cli?

Thank you very much!

`--csv` doesn't quite work due to extra newline

Neat tool! Beats the hell out of trying to do a CLI speedtest with curl.


I'm trying to use the --csv option in a cron job like so to build up historical data:

./librespeed-cli --csv >> speedtests.csv

However, the contents of my speedtests.csv file are as follows:

Timestamp,Server Name,Address,Ping,Jitter,Download,Upload,Share,IP

2021-05-16T14:20:50.645951073-04:00,"Atlanta, United States (Clouvider)",http://atl.speedtest.clouvider.net/backend,xxx

2021-05-16T14:21:01.390014732-04:00,"Atlanta, United States (Clouvider)",http://atl.speedtest.clouvider.net/backend,xxx

An extra newline in the output is messin' up my csv. Seems to be \n\n instead of just \n.


Workaround for shell scripts: https://stackoverflow.com/a/12525977/3474615

--json option giving output for stderr instead stdout

when we pass --json option the result being printed on console is stderr instead stdout. Looks like its printing result as stderr instead stdout. it would be really helpful if the result comes as stdout and any errors as part of stderr

./out/librespeed-cli-linux-amd64 --json > file1 2> file2
~/.../speetest/speedtest-cli $ cat file1
~/.../speetest/speedtest-cli $ cat file2
Selected server: Strasbourg, France (Host Europe) [sxb.bandspeed.de]
You're testing from: 122.172.110.47 - Bharti Airtel Ltd., Telemedia Services, IN (7450 km)
{"timestamp":"2021-03-16T17:35:15.3206446+05:30","server":{"name":"Strasbourg, France (Host Europe)","url":"https://sxb.bandspeed.de/"},"client":{"ip":"122.172.110.47","hostname":"abts-kk-dynamic-047.110.172.122.airtelbroadband.in","city":"Bengaluru","region":"Karnataka","country":"IN","loc":"12.9719,77.5937","org":"AS24560 Bharti Airtel Ltd., Telemedia Services","postal":"560002","timezone":"Asia/Kolkata"},"bytes_sent":6291456,"bytes_received":77692920,"ping":206.36363636363637,"jitter":92.92,"upload":3.2,"download":39.52,"share":""}

at high speeds the downlink speed end up negative

when starting the download the speed rises up to 1,8 gbps then suddenly it drops down to -500mbps which will be the registered speed, at lower speeds it doesn't happen, I have another use case where the speed is below 1gbps then I don't see the issue

--local-json

Hi,
I'm having troubles using librespeed-cli against a local installation of Ookla Server for testing purposes.

./librespeed-cli --local-json ./servers.json --server 1 Using local JSON server list: ./servers.json Selected server: Localhost [localhost] Selected server Localhost (localhost) is not responding at the moment, try again later

Here's the content of servers.json

[{ "id": 1, "name": "Localhost", "server": "http://localhost:8080/speedtest/", "dlURL": "download", "ulURL": "upload", "pingURL": "hello", "getIpURL": "getip" }]

Trying wget to connect to each of the endpoints defined in json file results in http 200 / OK

wget http://localhost:8080/speedtest/getip -> 200 OK

Am I missing something?

Thanks!

change server url from command line.

There doesn't seem to be an option to change the server without writing a file to the system.

Even using the typical dash to try to use stdin as a file (-) didn't work.

echo '[{"id": 1,"name": "a","server": "https://speedtest.example.com/","dlURL": "garbage.php","ulURL": "empty.php","pingURL": "empty.php","getIpURL": "getIP.php"}]' | librespeed-cli --local-json -

Upload test data management and storage

Hi. How is the uploaded data for the Upload test managed? Where is it stored? Does LibreSpeed create a temp file for this on the device, which it then deletes, or the device on which the test is running will periodically need to clean this out?

Not working on Mips architecture (openwrt)

I'm trying to run speedtest-cli 1.09 on a GL-X750 LTE router.
I tried both the -mips-hardfloat and -mips-softfloat binaries, but both stall shortly after starting with no console output.
Strace shows:

root@GL-X750:~# strace /tmp/librespeed-cli-mips-hardfloat 
execve("/tmp/librespeed-cli-mips-hardfloat", ["/tmp/librespeed-cli-mips-hardflo"...], 0x7feaaa90 /* 13 vars */) = 0
open("/proc/self/exe", O_RDONLY)        = 3
mmap(NULL, 2378876, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x77d55000
mmap(0x77d55000, 2378033, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x77d55000
cacheflush(0x77f99244, 0xa38, 0x3)      = 0
mprotect(0x77f98000, 7292, PROT_READ|PROT_EXEC) = 0
readlink("/proc/self/exe", "/tmp/librespeed-cli-mips-hardflo"..., 4095) = 34
cacheflush(0x7fba0fb0, 0x114, 0x3)      = 0
mmap(0x10000, 6762496, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x10000
mmap(0x10000, 3677824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x10000
cacheflush(0x10000, 0x114, 0x3)         = 0
cacheflush(0x10114, 0x381d6c, 0x3)      = 0
mprotect(0x10000, 3677824, PROT_READ|PROT_EXEC) = 0

CPU info:

root@GL-X750:~# cat /proc/cpuinfo 
system type		: Qualcomm Atheros QCA9533 ver 2 rev 0
machine			: GL.iNet GL-X750 (NOR)
processor		: 0
cpu model		: MIPS 24Kc V7.4
BogoMIPS		: 432.53
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 16
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16
Options implemented	: tlb 4kex 4k_cache prefetch mcheck ejtag llsc dc_aliases perf_cntr_intr_bit nan_legacy nan_2008 perf
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

Am I using the right binaries ? From what I can see I don't have a 64bit architecture.
What's the difference between -softfload and -hardfloat, and between -mips and -mipsle` ?

CLI results 2x higher RTT

Hi,

I've noticed that CLI result 2x higher RTT than web speed test.

Here's my web speed test result:
https://librespeed.org/results/?id=17vfzh3

librespeedresult

I performed a speed test using cli, strangely, it shows 2x higher RTT than web test.

% librespeed-cli --server 6
Retrieving LibreSpeed.org server list
Selected server: Nuremberg, Germany (1) (Hetzner) [de1.backend.librespeed.org]
Sponsored by: Snopyta @ https://snopyta.org
You're testing from: 2405:6586:2280:1200::dead:beef - Asahi Net, JP (9080 km)
Ping: 535 ms    Jitter: 0 ms
Download rate:  5.82 Mbps
Upload rate:    2.22 Mbps

I also measured RTT using ping, the result is same as the web test.

% ping6 de1.backend.librespeed.org
PING6(56=40+8+8 bytes) 2405:6586:2280:1200::dead:beef --> 2a01:4f8:1c1c:93d6::1
16 bytes from 2a01:4f8:1c1c:93d6::1, icmp_seq=0 hlim=35 time=268.486 ms
16 bytes from 2a01:4f8:1c1c:93d6::1, icmp_seq=1 hlim=35 time=266.626 ms
16 bytes from 2a01:4f8:1c1c:93d6::1, icmp_seq=2 hlim=35 time=264.742 ms
16 bytes from 2a01:4f8:1c1c:93d6::1, icmp_seq=3 hlim=35 time=264.809 ms

I haven't dig up the code but I guess you forgot to divide some value by 2.

Best Regards,

[RFE] OpenWrt?

Would it be possible to cross compile it for OpenWrt?

Using --share with --json, the share URL should only be present in the JSON

Observed

Using the --share option along with --json outputs a two line result, the first line with the share link and the second line with the actual JSON body (which includes again the share link).

Removing the --share option produces a single JSON output but the key share obviously is missing the share url.

Expected

A single JSON body.

Example

librespeed-cli.exe --json --share --server 35 > output.json

Share your result: https://librespeed.org/results/?id=1g64or7
{"timestamp":"2021-04-22T17:41:32.1749981+02:00","server":{"name":"Roma, Italy (GARR)","url":"https://st-be-rm2.infra.garr.it"},"client":{"ip":"138.199.54.238","hostname":"","city":"Milan","region":"Lombardy","country":"IT","loc":"45.4643,9.1895","org":"AS212238 Datacamp Limited","postal":"20121","timezone":"Europe/Rome"},"bytes_sent":314507264,"bytes_received":273170432,"ping":23.727272727272727,"jitter":1.25,"upload":161.2,"download":140.05,"share":"https://librespeed.org/results/?id=1g64or7"}

Transfer size based speed test

Hi,

For my use case, I need to do upload and download speed tests based on a transfer size (a.k.a test with a specific number of bytes to be uploaded and downloaded). However, it seems that all the tests are duration-based instead.

For download, if there was a way to restrict the test to a specific number of chunks that should do the job. For example:
librespeed-cl --no-upload --chunks 1
However, with the current implementation, the test continues until the duration is exceeded.

For upload, the issue is similar, the tests continue for the specified duration regardless of the upload-size. For example:
librespeed-cli --no-download --upload-size 1024

Is there a way today to have the chunks and upload-size parameters taking preference over the duration to achieve transfer size-based speed tests?
If not is that something you have planned to do or would accept contributions for?

Thanks!

Test Duration

Good day,

I have a server which takes apparently longer to ramp up to max speeds. I played with the web interface, and adjusting the max test time and setting auto to false, I get the expected results.
While trying to do it now by CLI, I couldnยดt find an option to set the test duration.
Would it be possible to do so?
BTW, the server behaves the same with IPerf. Am not sure why it takes it so long... will also work on that End.

Thanks.

output not splitted to stdout and stderr when both --json and --verbose are used

wouldnt it make sense to split the output to stdout and stderr when using both --json and --verbose options so that we could do:

./librespeed-cli --json --verbose > result.json 2> librespeed.log

right now everything is mangled into stdout, if a person wants that behaviour with (both option set), they would then do

./librespeed-cli --json --verbose &> result.txt

Returncode is not correct in all cases

If a server that does not exist is specified, the returncode is still 0 but there is no stdout or error shown in stderr. In any case where there is no stdout, the returncode should not be 0

remote server is down - id request per backend

Hello,

Retrieving LibreSpeed.org server list
Selecting the fastest server based on ping
Selected server: Helsinki, Finland (1) (Hetzner) [fi1.backend.librespeed.org]
Selected server Helsinki, Finland (1) (Hetzner) (fi1.backend.librespeed.org) is not responding at the moment, try again later

can you add an UID for every server to force or exclude specific servers ?
maybe adolfintel need to update the server code ?

librespeed-cli --help crashes stterm on Ubuntu

When I run librespeed-cli --help on librespeed-cli 1.0.7 in my stterm terminal on Ubuntu 20.04, the terminal simply crashes.

The culprit is a cutesy rocket emoji that's too much for stterm. I do realize that this is a bug in stterm and not in librespeed-cli, but I also think you might be interested to know this. Maybe you'd consider making a release that removes the emoji and reintroduce it once common distributions have patched their stterm packages?

Windows CLI hangs on "Selecting the fastest server based on ping"

When running the librespeed-cli command on Windows, it hangs on Selecting the fastest server based on ping. It then stays like that permanently until forcibly stopped.

Verbose logs

Click to expand

$ librespeed-cli --verbose
Retrieving server list from https://librespeed.org/backend-servers/servers.php
Selecting the fastest server based on ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Error checking for server status: Get "https://speedtest5.wegozyn.eu/backend/empty.php": dial tcp: lookup speedtest5.wegozyn.eu: no such host
Server Frankfurt am Main, Germany (speedtest5.wegozyn.eu) doesn't seem to be up, skipping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Server New York, United States (1) (BuyVM) (ny1.backend.librespeed.nixnet.services) doesn't seem to be up, skipping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Error checking for server status: Get "https://il1.us.backend.librespeed.org/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Server Chicago, United States (HostHatch) (il1.us.backend.librespeed.org) doesn't seem to be up, skipping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping
Error checking for server status: Get "https://la1.us.backend.librespeed.org/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Server Los Angeles, United States (2) (HostHatch) (la1.us.backend.librespeed.org) doesn't seem to be up, skipping
Failed to ping target host: socket: The requested protocol has not been configured into the system, or no implementation for it exists.
Will try TCP ping

The cause of this is explained in go-ping/ping#17. It is also explained in the Supported Operating Systems section of the README. I'd make a PR to fix this but I know so little about Go that I can't identify where this fix would go in speedtest.go.

Version information missing on latest armv7 binary

This is what I get using the v1.0.10 armv7 binary:

pi@pi:~ $ ./librespeed-cli  --version
  (built on )
https://github.com/librespeed/speedtest-cli
Licensed under GNU Lesser General Public License v3.0
LibreSpeed	Copyright (C) 2016-2020 Federico Dossena
librespeed-cli	Copyright (C) 2020 Maddie Zhan
librespeed.org	Copyright (C)

bytes_received consistently more than bytes_sent

I think there msut be a mistake because using the --json flag for results I consistently see that bytes_received is more than bytes_sent, so the lost bytes is negative. Have these values been returned the wrong way around in the json construction?

Failed to ping target host: socket: permission denied

Hi,

Since today, i have been having issues (from whichever PC i test in the world)
I try normal: Librespeed/librespeed-cli and it just hangs with:

Retrieving server list from https://librespeed.org/backend-servers/servers.php
Selecting the fastest server based on ping

Then i try: Librespeed/librespeed-cli --debug and then it shows errors:

Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping

Something wrong with the server being pinged?

The website however isnt giving these issues. Not sure what is wrong? but it is definitely not on my side.

Inquiry

Is there a limit on the number of requests a server can take at a time? What is it?

No servers currently available when using local json list

When I try to run a speedtest with my local json server list, I get a message that no server is currently available.
$ librespeed-cli --local-json speedtestservers.json Using local JSON server list: speedtestservers.json Selecting the fastest server based on ping No server is currently available, please try again later.
I have verified that all of these servers are online and I can run a speedtest with a browser.
JSON list:

[
  {
    "name": "Server1",
    "server": "https://(server1)/speedtest/",
    "dlURL": "garbage.php",
    "ulURL": "empty.php",
    "pingURL": "empty.php",
    "getIPURL": "getIP.php"
  },
  {
    "name": "Server2",
    "server": "https://(server2)/speedtest/",
    "dlURL": "garbage.php",
    "ulURL": "empty.php",
    "pingURL": "empty.php",
    "getIPURL": "getIP.php"
  },
  {
    "name": "Server3",
    "server": "http://(server3)/speedtest/",
    "dlURL": "garbage.php",
    "ulURL": "empty.php",
    "pingURL": "empty.php",
    "getIPURL": "getIP.php"
  }
]

Any compatibility issues between librespeed and speedtest-cli?

I have a local librespeed server running, and I'm trying to connect my librespeed/speedtest-cli unit (using the --local-json option) to it, and I always get the message that "No server is currently available, please try again later.". If I add any of the 'official' servers to the local json my own speedtest-cli does manage to connect to it. However, my own server is reachable and the site loads just fine (and runs tests). I tried hosting my librespeed server remote as well on my VPS (with domain name, both http and https) with the same results. I can run the site, but not through the cli.

The librespeed server is the docker edition, and I pulled it from linuxserver and built from the latest Dockerfile on github. As for the speedtest-cli, it's just the latest from github.

I have tried all the combinations in the local json (https, http, //, escaping the '/', adding the --secure and not, running my server through https and http, verified domain names...) but always the same message.

Any hints on where to look to figure this out?

Issues with different servers

I am having an issue running the librespeed-cli binary with multiple local json files containing each only one server entry to measure latency between my office and test/prod infrastructure.

On test infrastructure everything works with the following output in debug mode:

Using local JSON server list: TEST 
Selecting the fastest server based on ping
Failed to ping target host: socket: permission denied 
Will try TCP ping
Selected server: TEST [www.test.xxx.xxx] 
Failed when parsing get IP result: json: cannot unmarshal string into Go struct field GetIPResult.rawIspInfo of type defs.IPInfoResponse 
Received payload: {"processedString":"x.x.x.x","rawIspInfo":"UNKNOWN"}
You're testing from: x.x.x.x
Failed to ping target host: socket: permission denied
Will try TCP ping 
Download test is disabled 
Upload test is disabled
{"timestamp":"2020-04-01T16:33:47.921288388+02:00","server":{"name":"TEST","url":"https://www.test.xxx.xxx/librespeed/"},"client":{"ip":"","hostname":"","city":"","region":"","country":"","loc":"","org":"","postal":"","timezone":""},"bytes_sent":0,"bytes_received":0,"ping":10.272727272727273,"jitter":0.53,"upload":0,"download":0,"share":""}

On production server I get only the following output:

Using local JSON server list: PROD
Selecting the fastest server based on ping
Server PROD (www.xxx.xxx) doesn't seem to be up, skipping 
No server is currently available, please try again later.

Both servers do not respond to ICMP ping requests and I have no clue why the test server reports Failed to ping target host: socket: permission denied and then continues with a TCP ping? Is there a possibility to always switch or fallback to a "TCP ping" when no ICMP response received?

Thanks for your help,
Raoul

IPv6 test to LibreSpeed server not working

When running the librespeed test with --ipv6 command line option, the result is Error when fetching server list: Get https://librespeed.org/backend-servers/servers.php/.well-known/librespeed: dial tcp6 [2a01:4f8:c17:xxxx::1]:443: connect: cannot assign requested address Terminated due to error on one linux machine, and Error when fetching server list: Get "https://librespeed.org/backend-servers/servers.php/.well-known/librespeed": dial tcp6 [2a01:4f8:c17:xxxx::1]:443: connect: no route to host Terminated due to error on a mac

speed tests are timing out

seems like speed test from cli failing. but same working from UI.

out/librespeed-cli-linux-amd64
Retrieving server list from https://librespeed.org/backend-servers/servers.php
Selecting the fastest server based on ping
Error checking for server status: Get "https://speedtest5.wegozyn.eu/backend/empty.php": dial tcp: lookup speedtest5.wegozyn.eu on 8.8.8.8:53: no such host
Server Frankfurt am Main, Germany (speedtest5.wegozyn.eu) doesn't seem to be up, skipping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Server New York, United States (1) (BuyVM) (ny1.backend.librespeed.nixnet.services) doesn't seem to be up, skipping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Failed to ping target host: socket: permission denied
Will try TCP ping
Error checking for server status: Get "https://la1.us.backend.librespeed.org/empty.php": dial tcp 185.198.26.89:443: connect: no route to host
Server Los Angeles, United States (2) (HostHatch) (la1.us.backend.librespeed.org) doesn't seem to be up, skipping
Failed to ping target host: socket: permission denied
Will try TCP ping
Error checking for server status: Get "https://il1.us.backend.librespeed.org/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Server Chicago, United States (HostHatch) (il1.us.backend.librespeed.org) doesn't seem to be up, skipping
Failed to ping target host: socket: permission denied
Will try TCP ping --> hangs here

telemetry howto

Hi,
I have successfully managed to compile the source code with build.sh, and run the program with a local LibreSpeed server instance.

 # ./librespeed-cli-linux-amd64 --simple --local-json server.json  --telemetry-json telemetry.json
Ping:   0 ms    Jitter: 0 ms
Download rate:  4959.95 Mbps
Upload rate:    2572.16 Mbps

Content of local server.json file:

[
  {
    "name": "PHP Backend",
    "server": "http://localhost:84/backend",
    "dlURL": "garbage.php",
    "ulURL": "empty.php",
    "pingURL": "empty.php",
    "getIpURL": "getIP.php"
  }
]

Content of local telemetry.json:

  {
    "telemetryLevel": "full",
    "server": "http://localhost:84",
    "path": "/results/telemetry.php",
    "shareURL": "/results/"
  }

But the program does not upload the results into the specified telemetry server.
I captured the communication, but I don't see any HTTP post req in the end.
Maybe this is not implemented yet?
Kind regards,
Tamas

Speedtest backend in Prague

There is another librespeed instance available:

https://speedtest.cesnet.cz

frontend is just a slightly modified, but backend is exactly the same, so it could be used by speedtest-cli:

[
  {
    "id": <ID>,
    "name": "Prague, Czech Republic (CESNET)",
    "server": "//speedtest.cesnet.cz/backend/",
    "dlURL": "garbage.php",
    "ulURL": "empty.php",
    "pingURL": "empty.php",
    "getIpURL": "getIP.php",
    "sponsorName": "CESNET",
    "sponsorURL": "https://www.cesnet.cz"
  }
]

server is connected via 10Gbps link and should be stable and online for a long time (current uptime is more than 1 year).

results not writing to stdout

when I run librespeed-cli and try to pipe the output into a file, I get very inconsistent results, some parts can be piped and some cannot.

This is very confusing, expected behavior would be, that all of the output is STDOUT which can be piped into a file.

Screenshot_20200331_105536

[Suggestion] Add option to skip certificate validation

I would like to measure how much bandwidth I can trasmit using my personal VPN. I would like to carry my tests behind a HTTPS reverse proxy, so I need NginX and its certificate. Unfortunatly it doesn't seem to work, my guess is because of failed certificate validation (I can't see any verbosity option):

cat server.json

[
 {
  "id": 1,
  "name": "Librespeed test",
  "server": "https://10.1.1.1/",
  "dlURL": "librespeed/garbage.php",
  "ulURL": "librespeed/empty.php",
  "pingURL": "librespeed/empty.php",
  "getIpURL": "librespeed/getIP.php"
  }
]

librespeed-cli --local-json server.json

Using local JSON server list: server.json
Selecting the fastest server based on ping
No server is currently available, please try again later.

If I change "server" with "https://example.org/" the test runs correctly, but it returns results from normal connection, I.E. not inside the VPN. I can also succesfully test with "server" set to "http://10.1.1.1/", as the server instance is also available without the reverse proxy.


Curl has an option to skip certificate validation:
curl https://10.1.1.1/librespeed/

curl: (60) SSL: no alternative certificate subject name matches target host name '10.1.1.1'
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

curl -k https://10.1.1.1/librespeed/

<!doctype html>
 <!-- [...] -->
</html>

Different results compared to web version

Resurrecting this old thread but have recently started using the cli and have noticed the same behavior.

Running from CLI ->
./librespeed-cli-linux-amd64 --server 22
Selected server: Helsinki, Finland (3) (Hetzner) [finew.openspeed.org]
Ping: 13 ms Jitter: 0 ms
Download rate: 549.22 Mbps
Upload rate: 312.00 Mbps

From the web version:
web_version

speedtest-cli and proxies

Is there a reliable way to use speedtest-cli with proxies?
Under certain circumstances the environment parameter http_proxy seems to be taken into account on different operating systems if this is configured.
Tested it mainly on windows. but even there on different systems there were different test results with the same exe.
However, the actual download of the server list or the transmission of the statistics at the end (--share) does not seem to run via the proxy at all. Maybe someone has a solution before I start tinkering.

Tokyo server down for a long time

Whenever I try connecting to the tokyo server, It just says "not responding, try again later". On further inspection it appears that the server has been down since a long time.
image

Speedtest CLI not working unless --server paramater is provided for a working Speedtest Server

The CLI is selecting non responsive server when left in auto server select mode. Here is the output

โฏ .\librespeed-cli.exe
Retrieving server list from https://librespeed.org/backend-servers/servers.php
Selecting the fastest server based on ping
Selected server: Alblasserdam, Netherlands (RamNode) [nl1.backend.librespeed.org]
Sponsored by: RamNode @ https://www.ramnode.com/
Selected server Alblasserdam, Netherlands (RamNode) (nl1.backend.librespeed.org) is not responding at the moment, try again later

However passing a working server (found on https://librespeed.org/) as a parameter, the CLI works as expected. (Hiding the IP shown in the result)

Retrieving server list from https://librespeed.org/backend-servers/servers.php
Selected server: Singapore (Salvatore Cahyo) [speedtest.dsgroupmedia.com]
Sponsored by: Salvatore Cahyo @ https://salvatorecahyo.my.id
You're testing from: XXX.XXX.XXX.XXX - Bharti Airtel Ltd., Telemedia Services, IN (3310 km)
Ping: 50 ms     Jitter: 1 ms
Download rate:  34.93 Mbps
Upload rate:    24.16 Mbps

Tests performed on a Win11 x64 machine
explorer_ACsxEIuwWK

CLI hangs on "Selecting the fastest server based on ping"

Hi,

Do you know if there is anything I can do to troubleshoot this issue?

When running the CLI with no options or arguments it hangs on Selecting the fastest server based on ping.

It runs absolutely fine when specifying a server ID.

I am building the CLI from scratch inside the golang:alpine docker container if that makes any difference.

Many Thanks.

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.