LoginSignup
46
48

More than 1 year has passed since last update.

LinuxでもSpeedtestがしたい(speedtest-cli)

Last updated at Posted at 2018-07-14

追記

公式のCLIツールが公開。正確に計測したい方はこっちがおすすめ(要:root)
Speedtest.net の公式 CLI が公開されたので試してみる

はじめに

speedtest.net鯖運営者ということもあって、サーバーを借りるとまずネットワーク速度を計測します。
・・・の割に、コマンドをよく忘れるのでメモ。

speedtest-cli

https://github.com/sivel/speedtest-cli

読んで字のごとくコマンドラインからspeedtestができるツール。Python製。Apache License Version 2.0。
speedtest-cliと叩くだけで適当な測定サーバにつないでPINGとDOWN/UP速度を計測する。

作者様曰く言語の関係で公式とは値が微妙に違うらしい

使用例
# speedtest-cli
Retrieving speedtest.net configuration...
Testing from NTTPC Communications,Inc (140.227.81.7)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by OPEN Project (via 20G SINET) (Tokyo) [5.41 km]: 4.916 ms
Testing download speed................................................................................
Download: 76.57 Mbit/s
Testing upload speed................................................................................................
Upload: 68.58 Mbit/s

インストール方法

pipとかeasy_installとか、いろいろ用意されているけど以下のどっちかがおすすめ

easy_install speedtest-cli
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

使い方

speedtest-cliと叩くだけ

デフォルトだとIPから場所を特定して、最寄りサーバにパケット投げて応答がはやいサーバーを選ぶ

がしかし、speedtest.netの測定サーバーはほとんどがボランティアで低速サーバーもあるので、IPA CyberLab 400Gを手動で選んだほうが良い。

IPA_CyberLab_400G狙いうち
./speedtest-cli --server 48463

エラーになる場合はSoftEther Corporationもオススメ

SoftEther_Corporation狙いうち
./speedtest-cli --server 7139
日本サーバー一覧表示
./speedtest-cli --list | grep "Japan"

便利なオプション

DOWNLOAD速度だけ計測
./speedtest-cli --no-upload
UPLOAD速度だけ計測
./speedtest-cli --no-download 
結果のURLを発行
./speedtest-cli --share
CSVに出力
./speedtest-cli --csv

その他にもいろいろオプションがあるっぽい

# ./speedtest-cli -h
usage: speedtest-cli [-h] [--no-download] [--no-upload] [--bytes] [--share]
                     [--simple] [--csv] [--csv-delimiter CSV_DELIMITER]
                     [--csv-header] [--json] [--list] [--server SERVER]
                     [--exclude EXCLUDE] [--mini MINI] [--source SOURCE]
                     [--timeout TIMEOUT] [--secure] [--no-pre-allocate]
                     [--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
  --no-download         Do not perform download test
  --no-upload           Do not perform upload test
  --bytes               Display values in bytes instead of bits. Does not
                        affect the image generated by --share, nor output from
                        --json or --csv
  --share               Generate and provide a URL to the speedtest.net share
                        results image, not displayed with --csv
  --simple              Suppress verbose output, only show basic information
  --csv                 Suppress verbose output, only show basic information
                        in CSV format. Speeds listed in bit/s and not affected
                        by --bytes
  --csv-delimiter CSV_DELIMITER
                        Single character delimiter to use in CSV output.
                        Default ","
  --csv-header          Print CSV headers
  --json                Suppress verbose output, only show basic information
                        in JSON format. Speeds listed in bit/s and not
                        affected by --bytes
  --list                Display a list of speedtest.net servers sorted by
                        distance
  --server SERVER       Specify a server ID to test against. Can be supplied
                        multiple times
  --exclude EXCLUDE     Exclude a server from selection. Can be supplied
                        multiple times
  --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
  --no-pre-allocate     Do not pre allocate upload data. Pre allocation is
                        enabled by default to improve upload performance. To
                        support systems with insufficient memory, use this
                        option to avoid a MemoryError
  --version             Show the version number and exit
46
48
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
46
48