奇诺分享 | ccino.org

  • 首页
  • VPS
    • VPS申请
    • VPS配置
    • 科学上网
  • 网站建设
    • WordPress
  • 程序猿
    • 开发工具
    • 微服务
    • 容器
    • 分布式
    • 数据库
  • 杂项
  • 关于
  • Privacy Policy
生活不只是眼前的苟且,还有诗和远方!
  1. 首页
  2. VPS
  3. VPS配置
  4. 正文

linux下使用speedtest测速

2017年8月8日 2271点热度 0人点赞 0条评论

Speedtest测试网络上传/下载速度还是挺不错的,windows下非常方便。Linux下也可以很方便的使用命令行speedtest-cli来测试。speedtest-cli是一个用Python编写的轻量级Linux命令行工具,在Python2.4至3.4版本下均可运行。它基于Speedtest.net的基础架构来测量网络的上/下行速率。安装speedtest-cli很简单——只需要下载其Python脚本文件。以下步骤参考了linuxtoday的文章。

wget https://raw.github.com/sivel/speedtest-cli/master/speedtest.py
chmod a+rx speedtest.py
mv speedtest.py /usr/local/bin/speedtest
chown root:root /usr/local/bin/speedtest

 

执行以上几个命令就安装好了,然后运行的时候只要输入
speedtest

linux下使用speedtest测速

如上图所示,我拿搬瓦工洛杉矶测试了下速度,果然是G口的速度。如果你想分享测试结果,你可以使用参数“–share”。它将会把你的测试结果上传到Speedtest.net服务器并以图形的方式分享给其他人。

如果你对目前所有可用的Speedtest.net服务器感兴趣,你可以使用参数“–list”。它会打印出所有的Speedtest.net服务器(按照离你的地理距离由近及远排序)。

linux下使用speedtest测速

在上面的列表中,每一行前面都有一个与服务器对应的ID。如果想使用指定的节点来测试你的网速,你只需要在speedtest-cli命令后指定其ID即可。例如,如果想使用上图中的QuadraNet服务器,你只需要指定相对应的服务器ID7456即可。

linux下使用speedtest测速

电脑测试网速这个功能估计大家都用过,但是服务器需要测试外网的速度相比大家做法各有不同,有的人使用自己的服务器来测试上下行速度,有些通过下载某个网站的资源来测试下行速度,鉴于这些节点比较少,而且测试麻烦,我向大家推荐speedtest-cli.
speedtest是一个使用python编写的命令行脚本,通过调用speedtest.net测试上下行的接口来完成速度测试.最后我会测试运维生存时间所在服务器的外网速度。

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@li229-122 ~]# speedtest-cli --help
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
  --share          Generate and provide a URL to the speedtest.net share
                   results image
  --simple         Suppress verbose output, only show basic information
  --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
  --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@li229-122 ~]# speedtest-cli --list | grep China
1185) China Unicom (Changchun, China) [10534.35 km]
3784) China Mobile (Urumqi, China) [10581.15 km]
2667) Beijing Normal University (Beijing, China) [11117.03 km]
2529) Beijing Normal University (Beijing, China) [11117.03 km]
2816) Capital Online Data Service (Beijing, China) [11117.03 km]
4354) SXmobile (Taiyuan, China) [11383.17 km]
3973) China Telecom (Lanzhou, China) [11615.43 km]
3633) China Telecom (Shanghai, China) [11983.37 km]
3927) China Mobile Jiangsu Co., Ltd. (Suzhou, China) [11989.27 km]
2461) China Unicom (Chengdu, China) [12213.35 km]
1028) Shepherd Software (Xiamen, China) [12785.57 km]
1628) Xiamen Guangdian Xinxu (Xiamen, China) [12785.57 km]
3891) GZinternet (Guangzhou, China) [13005.36 km]
3871) SZWCDMA (Shenzhen, China) [13059.20 km]
3819) SZU (Shenzhen, China) [13059.20 km]
1536) STC (Hong Kong, China) [13088.37 km]
1890) Telin (Hong Kong, China) [13088.37 km]

 

结果解释
3633) China Telecom (Shanghai, China) [11983.37 km]

3633: 服务器id
china telecom:isp,这里是中国电信
shanghai,china :服务器所在地址
11983.37 km:两台服务器地理位置之间距离,我这台机器在美国,和上海相距11983.37公里,很远呐.

4.1 外网速度测试
咱们运维生存时间的服务器在美国linode,我测试到上海这台机器的速度,并且生成图片报告

[root@li229-122 ~]# speedtest-cli --server=3633 --share
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Linode (173.255.219.122)...
Hosted by China Telecom (Shanghai) [11983.37 km]: 23.603 ms
Testing download speed........................................
Download: 24.84 Mbit/s
Testing upload speed..................................................
Upload: 4.57 Mbit/s
Share results: http://www.speedtest.net/result/3240988007.png

 

本文出自:https://www.cmsky.com/linux-speedtest-cli/

https://www.ttlsa.com/linux/use-speedtest-cli-test-internet-speed/

相关文章

  • Linux流量监控工具 - iftop

  • linux内存大量sendmail、postdrop进程占用

  • 在这里插入图片描述

    CentOS7防火墙之firewall-cmd命令详解

  • esxi6.0-6.7下添加USB硬盘作为数据存储

  • 宝塔面板python项目管理器部署netease-cloud项目创建失败,解决方法

标签: SpeedTest
最后更新:2017年8月8日

奇诺分享 | ccino.org

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据。

COPYRIGHT © 2022 奇诺分享 | ccino.org. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang