找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 185|回复: 0

CentOS下用命令行测试网速

[复制链接]

141

主题

17

回帖

525

积分

超级版主

积分
525
发表于 2024-1-7 18:46:15 | 显示全部楼层 |阅读模式

很多时候我们需要测试Linux服务器的上行和下行宽带。在可用于测试宽带速度的网站中,Speedtest.net也许是使用最广泛的应用“之一”。
Speedtest.net提供了一个命令行版本——speedtest-cli。下面将向你演示如何在Linux的命令行中使用speedtest-cli来测试宽带连接速度。

一、安装speedtest-cli
speedtest-cli是一个用Python编写的轻量级Linux命令行工具,在Python2.4至3.4版本下均可运行。它基于Speedtest.net的基础架构来测量网络的上/下行速率。安装speedtest-cli很简单——只需要下载其Python脚本文件。

[root@localhost temp]# wget https://raw.github.com/sivel/spe ... er/speedtest_cli.py
[root@localhost temp]# chmod a+rx speedtest_cli.py
[root@localhost temp]# mv speedtest_cli.py /usr/local/bin/speedtest-cli
[root@localhost temp]# chown root:root /usr/local/bin/speedtest-cli

也可以在自己电脑上下载好 speedtest_cli.py 然后上传到服务器上。

二、使用speedtest-cli测试网速
使用speedtest-cli命令也很简单,它不需要任何参数即可工作。

[root@localhost temp]# speedtest-cli

输入这个命令后,它会自动发现离你最近的Speedtest.net服务器(地理距离),然后打印出测试的网络上/下行速率。

[root@localhost temp]# speedtest-cli
Retrieving speedtest.net configuration…
Retrieving speedtest.net server list…
Testing from China Telecom (219.135.214.145)…
Selecting best server based on latency…
Hosted by CTM Internet Services (Macau) [106.48 km]: 55.974 ms
Testing download speed………………………………….
Download: 3.15 Mbit/s
Testing upload speed…………………………………………..
Upload: 0.58 Mbit/s

测试结果说明:上行为 0.58Mbit/s 下行为 3.15 Mbit/s
当然对于测试结果,一般在实际应用中不一定能达到这个值,仅作为参考使用。

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

本版积分规则

Archiver|手机版|小黑屋|333cm ( 京ICP备16037542号 )

GMT+8, 2024-5-10 21:24 , Processed in 0.083928 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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