Raspberry Piで回線速度を計測する
2020/12/11
Speedtest公式のCLIを使って計測する。
https://www.speedtest.net/apps/cli
手順
インストール
$ sudo apt-get install gnupg1 apt-transport-https dirmngr
$ export INSTALL_KEY=379CE192D401AB61
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
$ echo "deb https://ookla.bintray.com/debian generic main" | sudo tee /etc/apt/sources.list.d/speedtest.list
$ sudo apt-get update
$ sudo apt-get install speedtest
実行
$ speedtest
Speedtest by Ookla
Server: BudgetVM - Tokyo (id = 38241)
ISP: NTT
Latency: 263.89 ms (7.30 ms jitter)
Download: 8.19 Mbps (data used: 12.2 MB)
Upload: 63.13 Mbps (data used: 104.9 MB)
Packet Loss: 0.0%
Result URL: https://www.speedtest.net/result/c/xxxxxxxxx
この時間帯は8Mbpsしか出ないみたい。。。(23時30分頃)
出力形式をJSONにする
$ speedtest -f json
{"type":"result","timestamp":"2020-12-11T14:25:02Z","ping":{"jitter":9.9019999999999992,"latency":190.52000000000001},"download":{"bandwidth":1176527,"bytes":10501778,"elapsed":9616},"upload":{"bandwidth":6299498,"bytes":84801822,"elapsed":15002},"isp":"NTT","interface":{"internalIp":"192.168.10.2","name":"wlan0","macAddr":"XX:XX:XX:XX:XX:XX","isVpn":false,"externalIp":"xxx.xxx.xxx.xxx"},"server":{"id":34122,"name":"Boingo Wireless","location":"Tokyo","country":"Japan","host":"b-speed01.jptransit.net","port":8080,"ip":"216.218.221.202"},"result":{"id":"xxxxxxxxx","url":"https://www.speedtest.net/result/c/xxxxxxxxx"}}"}}}