Sử dụng công cụ speedtest-cli (viết bằng Python) để test tốc độ mạng từ dòng lệnh Linux.
Yêu cầu
- Python 3
- pip (Python package installer)
Cài đặt
# Cài pip (nếu chưa có) sudo apt update sudo apt install python3-pip # Cài speedtest-cli pip3 install speedtest-cli # Hoặc cài system-wide sudo pip3 install speedtest-cli
Chạy test tốc độ
$ speedtest-cli Retrieving speedtest.net configuration... Retrieving speedtest.net server list... Testing from ISP (IP)... Selecting best server based on latency... Hosted by Server Name (City) [distance]: latency ms Testing download speed........................................ Download: 23.32 Mbit/s Testing upload speed.......................................... Upload: 14.30 Mbit/s
Tùy chọn hữu ích
speedtest-cli --help # Xem tất cả tùy chọn speedtest-cli --simple # Chỉ hiển thị download/upload/ping speedtest-cli --bytes # Hiển thị bytes thay vì bits speedtest-cli --share # Tạo URL chia sẻ kết quả (ảnh) speedtest-cli --list # Liệt kê server, sắp xếp theo khoảng cách speedtest-cli --server ID # Chỉ định server test speedtest-cli --secure # Dùng HTTPS speedtest-cli --timeout 30 # Timeout 30 giây
Ví dụ output --simple
Ping: 2.75 ms Download: 23.32 Mbit/s Upload: 14.30 Mbit/s
Lưu ý
- Kết quả phụ thuộc server test, giờ cao điểm, loại kết nối
- Chạy nhiều lần lấy trung bình cho chính xác
- Có thể dùng trong script cron để monitoring