Skip to content

kkrruumm/librespeed.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

librespeed.sh

A simple speedtest.net/fast.com-esque CLI for LibreSpeed servers written in POSIX shell

Dependencies

  • curl
  • awk
  • jq
  • dd (used for upload payload generation)
  • A terminal that understands the standard ANSI cursor-hide/show sequences if you want the spinner to look correct
  • any POSIX-capable shell

Installation

  • Put the script in $PATH somewhere. Generally, on Linux, a good location is /usr/local/bin.

Usage

  • Run the script with no arguments to autoselect the first server in Librespeeds public list and run a full latency/download/upload test
  • Run with --list to print the available servers and their IDs, then rerun with --server <id> to use a specific one
  • {download,upload} tests can be skipped with --no-download or --no-upload, an example using a specific server with a shorter duration and IPv4 only could be librespeed.sh --server 51 --duration 5 -4

Options

All configuration is via CLI flags.

  • --list - Print the server list (ID, name, hostname) and exit
  • --server <id> - Use a specific server ID from --list, defaults to the first server in the Librespeed list
  • --duration <seconds> - How long each throughput test (download, upload) runs for, defaults to 10
  • --concurrent <n> - Number of parallel curl workers per throughput test, defaults to 8. Bump this on fast connections as needed, though, this will result in increased CPU usage
  • --chunk-mb <mb> - Size of each download request in megabytes, passed as ckSize to garbage.php, defaults to 100. Librespeeds backend caps this at 100 and the script will clamp anything higher
  • --ping-count <n> - Number of latency samples to take. One extra is taken and dropped as a warmup, defaults to 10.
  • --timeout <seconds> - curl --connect-timeout value, applied to every request, defaults to 10
  • --interface <name> - Bind curl to a specific network interface, this is useful if you want to test a specific NIC or VPN interface as opposed to the default route
  • --secure - Pass curl --ssl-reqd, forcing TLS on every request, this is off by default and most or all of Librespeeds servers are HTTPS already
  • -4 / -6 - Force IPv4 or IPv6 respectively
  • --no-download - Skip the download test
  • --no-upload - Skip the upload test
  • --debug - After each throughput test, print a per-worker breakdown of bytes transferred, test duration, and resulting Mbit/s, off by default. This can be useful if your results look wrong and you want to see if a worker stalled

Server list

The server list is pulled from https://librespeed.org/backend-servers/servers.php at runtime, so the available servers are whatever Librespeed currently has in that list.

Notes

  • Yes, Librespeed already has a CLI client- I got tired of compiling it for use all over the place as not everything has it packaged and chose to write one in shell to solve that.
  • The script hides the terminal cursor while running and restores it on exit via an EXIT/INT/TERM/HUP trap, so if you kill -9 the script the cursor will stay hidden- run tput cnorm or printf '\033[?25h' to get your cursor back
  • This was fucking difficult.

About

A simple speedtest.net/fast.com-esque CLI for Librespeed servers written in POSIX shell

Resources

License

Stars

Watchers

Forks

Contributors

Languages