九里 真夏 @orumin そういえば speedtest.net って Linux の CLI client もありますね。
ってことでLinuxのcliで動くPython製のspeedtest-cliをちょっと試してみた.
speedtest.netでの回線速度計測をcliで行えます.python製でpipとかで各種環境に導入可能.
Debianだとjessie以降all, Ubuntuだと16.04LTS以降allにpkgもあるのでapt一発で入るし,Raspberry PiなどのARMアーキテクチャなんかでも問題なく動きました.
規定値の動作はipからロケーション拾ってそこから近いサーバーで計測した結果を返すようです.
自宅のipアドレスでの自動判定では静岡になってたので手動で計測サーバを変更して鹿児島と東京を試しました.
help
$ speedtest-cli -h
usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list]
[--server SERVER] [--mini MINI] [--source SOURCE]
[--timeout TIMEOUT] [--secure] [--version]
Command line interface for testing internet bandwidth using speedtest.net.
--------------------------------------------------------------------------
https://github.com/sivel/speedtest-cli
optional arguments:
-h, --help show this help message and exit
--bytes Display values in bytes instead of bits. Does not affect
the image generated by --share
--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
--timeout TIMEOUT HTTP timeout in seconds. Default 10
--secure Use HTTPS instead of HTTP when communicating with
speedtest.net operated servers
--version Show the version number and exit
|
規定値では自宅は静岡になっていて静岡サーバで計測する(実際は鹿児島)
$ speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from FreeBit (180.131.110.140)...
Selecting best server based on latency...
Hosted by ClickL Network (Shizuoka) [0.02 km]: 110.464 ms
Testing download speed........................................
Download: 2.07 Mbit/s
Testing upload speed..................................................
Upload: 0.92 Mbit/s
|
日本のサーバを確認する
$ speedtest-cli --list|grep -i japan
14180) ClickL Network (Shizuoka, Japan) [0.02 km]
8407) Allied Telesis Capital Corporation (Sagamihara, Japan) [111.58 km]
6087) Allied Telesis Capital Corporation (Fussa-shi, Japan) [120.41 km]
6508) at2wn (Yokohama, Japan) [125.30 km]
7510) ASEINet (Tokyo, Japan) [141.71 km]
12546) TB (Tokyo, Japan) [141.71 km]
12511) h3zjp (Nerima, Japan) [142.66 km]
8348) Foxcore-LS (Sodegaura, Japan) [167.71 km]
7139) SoftEther Corporation (Tsukuba, Japan) [192.41 km]
6368) gatolabo (Maibara, Japan) [194.62 km]
6766) JAIST(ino-lab) (Nomi, Japan) [232.28 km]
13641) NextechNetworkSolutions (Nara, Japan) [237.53 km]
6476) rxy (individual) (Osaka, Japan) [264.80 km]
8832) prize3046 (Ikeda, Japan) [269.86 km]
8193) kamiari (Sendai, Japan) [427.67 km]
7976) denpa893 (Hikari, Japan) [601.03 km]
6405) Allied Telesis Capital Corporation (Misawa, Japan) [686.38 km]
13568) KSL (Kagoshima, Japan) [820.38 km]
811) GLBB Japan KK (Chatan, Japan) [1397.84 km]
6581) haza (Haebaru, Japan) [1410.56 km]
|
鹿児島サーバで計測してみる
$ speedtest-cli --server 13568
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from FreeBit (180.131.110.140)...
Hosted by KSL (Kagoshima) [820.38 km]: 103.499 ms
Testing download speed........................................
Download: 2.20 Mbit/s
Testing upload speed..................................................
Upload: 0.92 Mbit/s
|
東京を–simple optionで計測してみる
$ speedtest-cli --simple --server 7510
Ping: 150.627 ms
Download: 1.88 Mbit/s
Upload: 0.84 Mbit/s
|
サーバの数を確認してみる
$ speedtest-cli --list | wc -l
6509
|
speedtestはJavaScriptやAdobe Flashが必要なことが多くてヘッドレス環境などでは面倒でした.
iperfやnetcatなんかはお手軽ですが,速度テスト先のサーバの用意が必要です.
今回のspeedtest-cliはお手軽に導入できて世界各地のサーバ相手にcliでspeed testも出来ていい感じです.