加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_汕头站长网 (https://www.0754zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

linux上下 行网速测试-小白实操记录

发布时间:2023-02-09 11:16:17 所属栏目:Linux 来源:
导读:  speedtest是一个使用python编写的命令行脚本,通过调用speedtest.net测试上下行的接口来完成速度测试.最后我会测试运维生存时间所在服务器的外网速度。

  需要python2.4-3.3的支持。

  项目地址:
  speedtest是一个使用python编写的命令行脚本,通过调用speedtest.net测试上下行的接口来完成速度测试.最后我会测试运维生存时间所在服务器的外网速度。
 
  需要python2.4-3.3的支持。
 
  项目地址:
 
  安装方式有多种
 
  1 安装speedtest-cli
 
  speedtest-cli需要在python 2.4-3.4的环境下,安装方法都很简单,自己选择以下最适合你的一种.
 
  1.1 pip方式
 
  pip install speedtest-cli
  1.2 easy_install方式
 
  easy_install speedtest-cli
  1.3 github+pip方式
 
  pip install git+https://github.com/sivel/speedtest-cli.git
  或者
 
  git clone https://github.com/sivel/speedtest-cli.git
  python speedtest-cli/setup.py install
  1.4 下载脚本方式
 
  wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
  chmod +x speedtest-cli
  或者
 
  curl -o speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
  chmod +x speedtest-cli
  直接下载脚本,给予执行权限即可。
 
  2 speedtest-cli用法
 
  命令很简单,直接上帮助
 
  root@scada:~# speedtest-cli --help
  usage: speedtest-cli [-h] [--no-download] [--no-upload] [--bytes] [--share]
                       [--simple] [--csv] [--csv-delimiter CSV_DELIMITER]
                       [--csv-header] [--json] [--list] [--server SERVER]
                       [--exclude EXCLUDE] [--mini MINI] [--source SOURCE]
                       [--timeout TIMEOUT] [--secure] [--no-pre-allocate]
                       [--version]
  Command line interface for testing internet bandwidth using speedtest.net.
  --------------------------------------------------------------------------
  https://github.com/sivel/speedtest-cli
  optional arguments:
    -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. Can be supplied
                          multiple times
    --exclude EXCLUDE     Exclude a server from selection. Can be supplied
                          multiple times
    --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
  3 speedtest-cli常用命令详解
 
  3.1 list
 
  根据距离显示speedtest.net的测试服务器列表
 
  3.2 server
 
  指定列表中id的服务器来做测试
 
  3.3 share
 
  分享你的网速,该命令会在speedtest网站上生成网速测试结果的图片
 
  4 speedtest-cli测试
 
  4.1 列出所有在中国的测试服务器
 
  root@scada:~# speedtest-cli --list | grep China
  37834) Xiamen Unicom (Xiamen, China) [503.53 km]
  16171) Fuzhou China Mobile,Fujian (Fuzhou, China) [675.05 km]
   4884) China Unicom FuJian (Fuzhou, China) [675.05 km]
  23844) China Telecom Wuhan Branch (Wuhan, China) [794.23 km]
  29353) wuhan hello 5G (Wuhan, China) [794.23 km]
   5485) China Unicom,Hubei Branch (Wuhan, China) [794.23 km]
  17145) China Telecom AnHui 5G (Hefei, China) [1011.30 km]
   7509) China Telecom ZheJiang Branch (Hangzhou, China) [1016.32 km]
   4647) China Mobile Group Zhejiang Co.,Ltd (Hangzhou, China) [1016.32 km]
  33995) China Unicom ZheJiang 5G (Hangzhou, China) [1016.32 km]
   6715) China Mobile Zhejiang 5G (Ningbo, China) [1086.15 km]
  26352) China Telecom JiangSu 5G (Nanjing, China) [1094.25 km]
  13704) China Unicom (Nanjing, China) [1096.69 km]
  27249) China Mobile jiangsu 5G (Nanjing, China) [1096.69 km]
   5396) China Telecom JiangSu 5G (Suzhou, China) [1129.08 km]
  26850) China Mobile 5G (Wuxi, China) [1134.11 km]
  32291) China Mobile 5G (ChangZhou, China) [1136.29 km]
  17320) China Mobile JiangSu 5G (ZhenJiang, China) [1143.40 km]
  36663) China Telecom JiangSu 5G (Zhenjiang, China) [1143.40 km]
   5317) 江苏电信5G (Yangzhou, China) [1158.94 km]
  30852) Duke Kunshan University (Kunshan, China) [1161.46 km]
  24447) China Unicom 5G (ShangHai, China) [1181.08 km]
   3633) China Telecom (Shanghai, China) [1181.08 km]
  25637) Chinamobile-5G (Shanghai, China) [1181.08 km]
  38183) ShangDong CMCC 5G (Linyi, China) [1381.52 km]
   5039) China unicom Jinan branch (Jinan, China) [1507.11 km]
  26180) Shandong Unicom 5G (Jinan, China) [1507.11 km]
  27452) ShanDong CMCC 5G (Jinan, China) [1507.11 km]
  38185) ShangDong CMCC 5G (Qingdao, China) [1556.47 km]
  结果解释
 
  3633) China Telecom (Shanghai, China) [11983.37 km]
 
  3633: 服务器id
 
  china telecom:isp,这里是中国电信
 
  shanghai,china :服务器所在地址
 
  11983.37 km:两台服务器地理位置之间距离,我这台机器在美国linux测试网速工具,和上海相距11983.37公里,很远呐.
 
  4.2 外网速度测试
 
  speedtest-cli --server=3633
  或者
 
  speedtest-cli
  linux网速测试_linux测试网速工具_linux 测试网速命令
 
  通过结果可以看到,下载可以达到12.70mbit/s,上传可以达到2.14mbit/s.
 

(编辑:云计算网_汕头站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!