使用Speedtest® CLI为Linux机器测速(互联网连接)

https://www.speedtest.net/
Speedtest® CLI
面向开发人员的互联网连接测量
Speedtest CLI 为命令行带来 Speedtest 背后的可信技术和全球服务器网络。Speedtest CLI 专为软件开发人员、系统管理员和计算机爱好者等打造,是 Ookla® 提供技术支持的首款正式 Linux 本机 Speedtest 应用程序。

使用 Speedtest CLI,您可以轻松完成以下操作:

  • 无需依靠网络浏览器,在本机测量下载、上传、延迟和丢包等互联网连接性能指标
  • 使用 Speedtest Server Network™ 测试 Linux 台式机、远程服务器甚至 Raspberry Pi® 等低功率设备的互联网连接
  • 设置自动脚本收集连接性能数据,包括随时间变化的趋势
  • 在自己的程序中使用自己所选的编程语言对 Speedtest 包装后进行使用
  • 通过 CSV、JSONL 或 JSON 查看测试结果

Speedtest® CLI虽然已经出了很久并且官网都有安装教程这个已无意义但还是想水。
其实在官方没有出之前好像还不乏有过第三方大佬出的也是基于Ookla®的节点在Linux的cli。
最后只在Centos系统安装并且成功使用,Debian系统gnupg1安装失败而没有能使用。

安装

macOS

brew tap teamookla/speedtest
brew update
brew install speedtest --force

Ubuntu/Debian

sudo apt-get install gnupg1 apt-transport-https dirmngr
export INSTALL_KEY=379CE192D401AB61
# Ubuntu versions supported: xenial, bionic
# Debian versions supported: jessie, stretch, buster
export DEB_DISTRO=$(lsb_release -sc)
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
echo "deb https://ookla.bintray.com/debian ${DEB_DISTRO} main" | sudo tee  /etc/apt/sources.list.d/speedtest.list
sudo apt-get update
# Other non-official binaries will conflict with Speedtest CLI
# Example how to remove using apt-get
# sudo apt-get remove speedtest-cli
sudo apt-get install speedtest

Fedora/Centos/Redhat

sudo yum install wget
wget https://bintray.com/ookla/rhel/rpm -O bintray-ookla-rhel.repo
sudo mv bintray-ookla-rhel.repo /etc/yum.repos.d/
# Other non-official binaries will conflict with Speedtest CLI
# Example how to remove using yum
# rpm -qa | grep speedtest | xargs -I {} sudo yum -y remove {}
sudo yum install speedtest

FreeBSD

sudo pkg update && sudo pkg install -g libidn2 ca_root_nss
sudo pkg add "https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-freebsd.pkg"

因为在Debian安装失败就只好在安装成功的Centos8上面跑来玩玩了。

虽然一开始不知道怎么运行但还是猜测使用speedtest运行:

==============================================================================

You may only use this Speedtest software and information generated
from it for personal, non-commercial use, through a command line
interface on a personal computer. Your use of this software is subject
to the End User License Agreement, Terms of Use and Privacy Policy at
these URLs:

        https://www.speedtest.net/about/eula
        https://www.speedtest.net/about/terms
        https://www.speedtest.net/about/privacy

==============================================================================

Do you accept the license? [type YES to accept]:

第一次运行:

Do you accept the license? [type YES to accept]: yes
License acceptance recorded. Continuing.


   Speedtest by Ookla

     Server: ColoCrossing - Buffalo, NY (id = 9276)
        ISP: ColoCrossing
    Latency:     0.39 ms   (0.08 ms jitter)
   Download:   861.25 Mbps (data used: 1.5 GB)
     Upload:   868.60 Mbps (data used: 413.5 MB)
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/4d59d882-3c5f-40ab-873f-3d62093d12aa

看看是否有speedtest -h然后:

Speedtest by Ookla is the official command line client for testing the speed and performance of your internet connection.

Version: speedtest 1.0.0.2

Usage: speedtest [<options>]
  -h, --help                        Print usage information
  -V, --version                     Print version number
  -L, --servers                     List nearest servers
  -s, --server-id=#                 Specify a server from the server list using its id
  -I, --interface=ARG               Attempt to bind to the specified interface when connecting to servers
  -i, --ip=ARG                      Attempt to bind to the specified IP address when connecting to servers
  -o, --host=ARG                    Specify a server, from the server list, using its host's fully qualified domain name
  -p, --progress=yes|no             Enable or disable progress bar (Note: only available for 'human-readable'
                                    or 'json' and defaults to yes when interactive)
  -P, --precision=#                 Number of decimals to use (0-8, default=2)
  -f, --format=ARG                  Output format (see below for valid formats)
  -u, --unit[=ARG]                  Output unit for displaying speeds (Note: this is only applicable
                                    for ‘human-readable’ output format and the default unit is Mbps)
  -a                                Shortcut for [-u auto-decimal-bits]
  -A                                Shortcut for [-u auto-decimal-bytes]
  -b                                Shortcut for [-u auto-binary-bits]
  -B                                Shortcut for [-u auto-binary-bytes]
      --selection-details           Show server selection details
      --ca-certificate=ARG          CA Certificate bundle path
  -v                                Logging verbosity. Specify multiple times for higher verbosity
      --output-header               Show output header for CSV and TSV formats

 Valid output formats: human-readable (default), csv, tsv, json, jsonl, json-pretty

 Machine readable formats (csv, tsv, json, jsonl, json-pretty) use bytes as the unit of measure with max precision

 Valid units for [-u] flag:
   Decimal prefix, bits per second:  bps, kbps, Mbps, Gbps
   Decimal prefix, bytes per second: B/s, kB/s, MB/s, GB/s
   Binary prefix, bits per second:   kibps, Mibps, Gibps
   Binary prefix, bytes per second:  kiB/s, MiB/s, GiB/s
   Auto-scaled prefix: auto-binary-bits, auto-binary-bytes, auto-decimal-bits, auto-decimal-bytes

使用speedtest -L查看最近节点:

Closest servers:

    ID  Name                           Location             Country
==============================================================================
  9276  ColoCrossing                   Buffalo, NY          United States
 24813  Advance2000                    Amherst, NY          United States
 26573  NRBN                           Niagara Falls, ON    Canada
 18756  Apsis Communications           St Catharines, ON    Canada
 21275  HCE Telecom                    Hamilton, ON         Canada
 28706  Taridium Canada                Hamilton, ON         Canada
 17394  Bell Canada                    Toronto, ON          Canada
 13030  FibreStream                    Toronto, ON          Canada
  3575  TELUS                          Toronto, ON          Canada
 16753  Bell Mobility                  Toronto, ON          Canada

指定个节点 speedtest -s 24813看看:

  Speedtest by Ookla

     Server: Advance2000 - Amherst, NY (id = 24813)
        ISP: ColoCrossing
    Latency:     1.20 ms   (0.08 ms jitter)
   Download:  2625.89 Mbps (data used: 2.7 GB)
     Upload:   959.18 Mbps (data used: 842.5 MB)
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/ee2caf6f-372c-485b-9b52-71ae6da41f41

话说如果能知道各节点的ID不就可以测到达全球的网络质量了!

刚刚才发现官网上面贴出来的图片地址竟然是失效(不能显示数据)的https://www.speedtest.net/result/c94e2659-faab-485f-868f-01c88df4e880.png替换成https://www.speedtest.net/result/c/c94e2659-faab-485f-868f-01c88df4e880.png或者https://www.speedtest.net/zh-Hans/result/c/c94e2659-faab-485f-868f-01c88df4e880.png就能正常显示出数据了。

2019年11月17日 01:50更新:

为macOS安装brew支持。安装很简单正常情况下只需要一条命令(期间需要输入密码):

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

由于网络原因经过漫长的等待终于安装完成:

MacOStekiMac:~ MacOS$ brew
^C
MacOStekiMac:~ MacOS$ brew -v
Homebrew 2.1.16
Homebrew/homebrew-core (git revision 3239d; last commit 2019-11-16)

终于可以愉快的安装各种软件包(包括但不限于Speedtest® CLI)了。

参考
Speedtest® CLI:https://www.speedtest.net/apps/cli
Speedtest® CLI(zh-Hans):https://www.speedtest.net/zh-Hans/apps/cli

Homebrew:https://brew.sh
Homebrew(zh-cn):https://brew.sh/index_zh-cn

Ookla®, Speedtest®, and Speedtest Intelligence® are among some of the federally registered trademarks of Ookla, LLC and may only be used with explicit written permission.

ChiuYut

2019年11月10日

发布者

ChiuYut

咦?我是谁?这是什么地方? Ya ha!我是ChiuYut!这里是我的小破站!

发表评论

电子邮件地址不会被公开。 必填项已用*标注