0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SpeedTestの結果をjsonで取得 【SpeedTestCLI】

0
Last updated at Posted at 2021-03-16

自分用メモ

できること

  • ブラウザに依存せずスピードテストができる
  • csv/json/jsonlで結果を取得できる

Speedtest CLIを使うと、次のようなことを簡単に行うことができます。

Webブラウザーに依存せずに、ダウンロード、アップロード、遅延、パケット損失などのインターネット接続パフォーマンスメトリックをネイティブに測定
Speedtest Server Network™を使用して、Linuxデスクトップ、リモートサーバー、またはRaspberry Pi® のような低電力デバイスのインターネット接続をテスト
自動化されたスクリプトをセットアップして、経時的な傾向を含む接続パフォーマンスデータを収集
任意のプログラミング言語でSpeedtestをラップして自分のプログラムで使用
CSV、JSONL、JSONでテスト結果を表示

テスト環境

$ sw_vers
ProductName:	macOS
ProductVersion:	11.2.2
BuildVersion:	20D80

インストール

mac

$ brew tap teamookla/speedtest
$ brew update
$ brew install speedtest --force

※brewでインストールが推奨されている

Ubuntu/Debian

$ 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

freeBSD

$ sudo pkg update && sudo pkg install -g libidn2 ca_root_nss
$ sudo pkg add "https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-freebsd.pkg"

使い方

通常の測定

$ speedtest-cli

Retrieving speedtest.net configuration...
Testing from Softbank BB (***.***.***.***)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Rakuten Mobile, Inc (Tokyo) [1.80 km]: 61.43 ms
Testing download speed................................................................................
Download: 17.10 Mbit/s
Testing upload speed................................................................................................
Upload: 12.24 Mbit/s

ダウンロードのみ測定

$ speedtest-cli --no-upload

アップロードのみ測定

$ speedtest-cli --no-download  

結果画像表示リンクの生成

$ speedtest-cli --share
Retrieving speedtest.net configuration...
Testing from Softbank BB (***.***.***.***)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by i3D.net (Tokyo) [1.80 km]: 47.902 ms
Testing download speed................................................................................
Download: 22.58 Mbit/s
Testing upload speed................................................................................................
Upload: 8.61 Mbit/s
Share results: http://www.speedtest.net/result/11099268446.png

出力をシンプルに

$ speedtest-cli --simple 

Ping: 50.771 ms
Download: 22.74 Mbit/s
Upload: 10.18 Mbit/s

結果をjsonで表示

※json部分は{CSV、JSONL、JSON}でフォーマットの指定が可能

$ peedtest-cli --json

{
	"client": {
		"rating": "0",
		"loggedin": "0",
		"isprating": "3.7",
		"ispdlavg": "0",
		"ip": "***.***.***.***",
		"isp": "Softbank BB",
		"lon": "139.7002",
		"ispulavg": "0",
		"country": "JP",
		"lat": "35.6918"
	},
	"bytes_sent": 13533184,
	"download": 19007189.86290613,
	"timestamp": "2021-03-16T07:00:25.536911Z",
	"share": null,
	"bytes_received": 24176112,
	"ping": 53.276,
	"upload": 10081568.704870753,
	"server": {
		"latency": 53.276,
		"name": "Tokyo",
		"url": "http://jp.as.speedtest.i3d.net:8080/speedtest/upload.php",
		"country": "Japan",
		"lon": "139.6833",
		"cc": "JP",
		"host": "jp.as.speedtest.i3d.net:8080",
		"sponsor": "i3D.net",
		"lat": "35.6833",
		"id": "21569",
		"d": 1.7952481967622678
	}
}

サーバの指定

$ speedtest  --server SERVER

さらに詳しく

$ speedtest-cli --help


via: SPEEDTEST® CLI

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?