Update 测速中文
This commit is contained in:
25
测速中文
25
测速中文
@@ -1,21 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo "🚀 一键网络测速"
|
echo "🚀 一键网络测速"
|
||||||
|
|
||||||
# 方法1: 使用 ping 测试延迟
|
# 测试延迟
|
||||||
echo "🔄 测试网络延迟..."
|
echo "🔄 测试网络延迟..."
|
||||||
ping -c 5 8.8.8.8 | grep "min/avg/max" | awk -F'/' '{print "网络延迟: " $4 " ms"}'
|
ping -c 5 8.8.8.8 | grep "min/avg/max" | awk -F'/' '{print "网络延迟: " $4 " ms"}'
|
||||||
|
|
||||||
# 方法2: 使用 wget 测试下载速度
|
# 测试下载速度
|
||||||
echo "⬇️ 测试下载速度..."
|
echo "⬇️ 测试下载速度..."
|
||||||
start_time=$(date +%s)
|
start_time=$(date +%s)
|
||||||
wget -O /dev/null --timeout=10 http://cachefly.cachefly.net/100mb.test 2>&1 | grep "MB/s" | awk '{print "下载速度: " $3 " " $4}'
|
wget -O /dev/null --timeout=10 http://cachefly.cachefly.net/100mb.test 2>&1 | grep "MB/s" | awk '{print "下载速度: " $3 " " $4}'
|
||||||
end_time=$(date +%s)
|
end_time=$(date +%s)
|
||||||
|
|
||||||
# 如果上面的方法失败,使用备用方法
|
# 测试上传速度(使用 speedtest-cli 如果可用)
|
||||||
if [ $? -ne 0 ]; then
|
echo "⬆️ 测试上传速度..."
|
||||||
echo "📊 使用备用测速方法..."
|
if command -v speedtest &> /dev/null; then
|
||||||
speed=$(curl -s -w "%{speed_download}" -o /dev/null http://cachefly.cachefly.net/100mb.test)
|
# 使用官方 speedtest
|
||||||
echo "下载速度: $(echo "scale=2; $speed / 1024 / 1024" | bc) MB/s"
|
upload_result=$(speedtest --simple | grep "Upload:" | awk '{print "上传速度: " $2 " " $3}')
|
||||||
|
echo "$upload_result"
|
||||||
|
else
|
||||||
|
# 使用 Python speedtest-cli
|
||||||
|
upload_result=$(curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 - 2>/dev/null | grep "Upload:" | head -1 | awk '{print "上传速度: " $2 " " $3}')
|
||||||
|
if [ -n "$upload_result" ]; then
|
||||||
|
echo "$upload_result"
|
||||||
|
else
|
||||||
|
# 备用方法:使用 iperf3 测试(如果可用)
|
||||||
|
echo "上传测试需要额外工具"
|
||||||
|
echo "安装完整测速工具: apt-get install speedtest-cli"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ 测速完成"
|
echo "✅ 测速完成"
|
||||||
|
|||||||
Reference in New Issue
Block a user