Linux下利用Speedtest测试网速教程

美丽的神话  金牌会员 | 2024-12-17 15:10:49 | 来自手机 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 871|帖子 871|积分 2613

有时间我们会需要测试一下当前本机的下载速度和上行速度,但是不可,Linux并没有自带这种技能,那就只能借助外力get此技能啦!!!

这里我们利用的是Speedtest工具,下面先容该工具的两种测试网速的方法
   

  • 通过浏览器测试网速
  • 通过下载源码,在下令行中测试网速
  一、通过Speedtest官网直接测试网络速度


  • Speedtest的官方网址
    网址: https://www.speedtest.net/
通过浏览器打开该网址,点击Go 即可开启网速测试之旅

2、测试效果如下:


二、通过下载源码,在下令行中测试网速

   这里用到一个Python工具speedtest,speedtest是一个用Python编写的轻量级Linux下令行工具,现在支持几乎所有的python版本Python 2.4-3.7。它基于Speedtest.net的底子架构来丈量网络的上/下行速率。安装speedtest很简朴——只需要下载其Python脚本文件。
  1、下载安装

Speedtest的github的下载地点:
   https://github.com/sivel/speedtest-cli
  Speedtest有多种安装方式,选一种你喜欢的方式去安装它吧!方法如下:

  • 直接用pip安装
  1. pip install speedtest-cli
复制代码

  • 用easy_install 安装
  1. easy_install speedtest-cli
复制代码

  • 用pip联合git下载安装
  1. pip install git+https://github.com/sivel/speedtest-cli.git
复制代码

  • 用git先下载,然后在用python执行安装程序安装
  1. git clone https://github.com/sivel/speedtest-cli.git
  2. python speedtest-cli/setup.py install
复制代码

  • 用wget下载,不安装
  1. wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
  2. chmod +x speedtest-cli
复制代码

  • 用curl下载,不安装
  1. curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
  2. chmod +x speedtest-cli
复制代码
2、Speedtest的参数利用:

  1. $ speedtest-cli -h
  2. usage: speedtest-cli [-h] [--no-download] [--no-upload] [--bytes] [--share]
  3.                      [--simple] [--csv] [--csv-delimiter CSV_DELIMITER]
  4.                      [--csv-header] [--json] [--list] [--server SERVER]
  5.                      [--exclude EXCLUDE] [--mini MINI] [--source SOURCE]
  6.                      [--timeout TIMEOUT] [--secure] [--no-pre-allocate]
  7.                      [--version]
  8. Command line interface for testing internet bandwidth using speedtest.net.
  9. -https://github.com/sivel/speedtest-cli
  10. optional arguments:
  11.   -h, --help            show this help message and exit
  12.   --no-download         Do not perform download test
  13.   --no-upload           Do not perform upload test
  14.   --bytes               Display values in bytes instead of bits. Does not
  15.                         affect the image generated by --share, nor output from
  16.                         --json or --csv
  17.   --share               Generate and provide a URL to the speedtest.net share
  18.                         results image, not displayed with --csv
  19.   --simple              Suppress verbose output, only show basic information
  20.   --csv                 Suppress verbose output, only show basic information
  21.                         in CSV format. Speeds listed in bit/s and not affected
  22.                         by --bytes
  23.   --csv-delimiter CSV_DELIMITER
  24.                         Single character delimiter to use in CSV output.
  25.                         Default ","
  26.   --csv-header          Print CSV headers
  27.   --json                Suppress verbose output, only show basic information
  28.                         in JSON format. Speeds listed in bit/s and not
  29.                         affected by --bytes
  30.   --list                Display a list of speedtest.net servers sorted by
  31.                         distance
  32.   --server SERVER       Specify a server ID to test against. Can be supplied
  33.                         multiple times
  34.   --exclude EXCLUDE     Exclude a server from selection. Can be supplied
  35.                         multiple times
  36.   --mini MINI           URL of the Speedtest Mini server
  37.   --source SOURCE       Source IP address to bind to
  38.   --timeout TIMEOUT     HTTP timeout in seconds. Default 10
  39.   --secure              Use HTTPS instead of HTTP when communicating with
  40.                         speedtest.net operated servers
  41.   --no-pre-allocate     Do not pre allocate upload data. Pre allocation is
  42.                         enabled by default to improve upload performance. To
  43.                         support systems with insufficient memory, use this
  44.                         option to avoid a MemoryError
  45.   --version             Show the version number and exit
复制代码
Reference:
1、https://blog.csdn.net/catoop/article/details/50350623
2、https://linux.cn/article-9558-1.html
3、https://blog.csdn.net/wh211212/article/details/52735229
4、https://blog.csdn.net/h952520296/article/details/78458072





♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

美丽的神话

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表