Help us understand the problem. What is going on with this article?

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

追記

公式の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の測定サーバーはほとんどがボランティアで低速サーバーもあるので、OPEN Project (via 20G SINET)を手動で選んだほうが良い。

測定サーバー指定は--server サーバー番号で一発だけど、番号指定(定期更新)のため、毎回調べる必要がある。

OPEN_Project狙いうち
./speedtest-cli --list | grep "OPEN Project" | cut -d' ' -f1 | rev | cut -c 2- | rev | \
xargs ./speedtest-cli --server
日本サーバー一覧表示
./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
CloudRemix
I Love RentalServer / VPS / Cloud / DataCenter / CentOS / Nginx / PHP / MySQL / WordPress どうぞよろしく!!
https://www.cloudremix.net/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした