12345678910111213141516171819202122232425262728293031 |
- #!/usr/bin/env bash
- # This script will perform speedtests over wireguard and the
- # native connections and print their output
- #
- _speedTestData() {
- local pingbps ping_f bps_f bps_int
- export ping_int mbps_int
- pingbps=$(speedtest-cli --no-upload --csv "$@" | cut -d"," -f7-8)
- ping_f="${pingbps%,*}" # grab first value
- ping_int="${ping_f%.*}" # make integer
- bps_f="${pingbps#*,}" # grab second value
- bps_int="${bps_f%.*}" # make integer
- mbps_int=$((bps_int / 1000000)) # convert to mbps
- }
- # Test Wireguard using automatic server selection
- if _speedTestData; then
- echo "Wireguard:"
- echo -e "\tPing: $ping_int"
- echo -e "\tMbps: $mbps_int"
- fi
- # Test native connection to ISP
- if _speedTestData --server 17170; then
- echo "Native:"
- echo -e "\tPing: $ping_int"
- echo -e "\tMbps: $mbps_int"
- fi
|