用Speedtest-CLI来测试你的上下行网速

我们经常需要检查服务器的网络状况,于是便了有此文的主题Speedtest-CLI,这是个十分好用的工具,使用简单的命令就能达到我们的目的。

Speedtest-CLI是什么?

Speedtest-CLI是基于python开发的脚本程序,利用了speedtest.net的服务来测量出上下行的宽带速度。Speedtest-cli能根据机房离测速服务器的物理距离来列出测速服务器,或者针对某一服务器进行测速,同时还能为你生成一个URL以便你分享你的测速结果。

在Linux上安装Speedtest-CLI

准备条件

服务器上必须安装了2.4-3.5的python版本

安装方法

  • pip方式安装

    pip install speedtest-cli

    easy_install speedtest-cli

    注:这种安装方式的前提是系统安装了python-pip包管理器,这样你才能使用pip命令安装

移动脚本到用户下,这样就不用每次输入完整的脚本路径

sudo mv speedtest-cli /usr/bin/

使用Speedtest-CLI

键入speedtest-cli -h可以得到相关的命令

Usage: speedtest-cli [options]

Command line interface for testing internet bandwidth using speedtest.net.
--------------------------------------------------------------------------
https://github.com/sivel/speedtest-cli

Options:
  -h, --help            show this help message and exit
  --no-download         Do not perform download test
  --no-upload           Do not perform upload test
  --bytes               Display values in bytes instead of bits. Does not
                        affect the image generated by --share, nor output from
                        --json or --csv
  --share               Generate and provide a URL to the speedtest.net share
                        results image, not displayed with --csv
  --simple              Suppress verbose output, only show basic information
  --csv                 Suppress verbose output, only show basic information
                        in CSV format. Speeds listed in bit/s and not affected
                        by --bytes
  --csv-delimiter=CSV_DELIMITER
                        Single character delimiter to use in CSV output.
                        Default ","
  --csv-header          Print CSV headers
  --json                Suppress verbose output, only show basic information
                        in JSON format. Speeds listed in bit/s and not
                        affected by --bytes
  --list                Display a list of speedtest.net servers sorted by
                        distance
  --server=SERVER       Specify a server ID to test against
  --mini=MINI           URL of the Speedtest Mini server
  --source=SOURCE       Source IP address to bind to
  --timeout=TIMEOUT     HTTP timeout in seconds. Default 10
  --secure              Use HTTPS instead of HTTP when communicating with
                        speedtest.net operated servers
  --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 a MemoryError
  --version             Show the version number and exit

命令介绍

  • speedtest-cli --bytes以字节计算的方式来测试上下行速度
  • speedtest-cli --share将速度测试的结果生成一张图片的连接,便于你分享
  • speedtest-cli --simple只显示ping和上下行速度
  • speedtest-cli --list 列出speedtest.net所有的服务器距离你的物理距离,单位是千米(km)

  • 其它命令自己去看文档吧,写得很清楚,传送门

好了,这里就说这么多了.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值