VPS测速安装speedtest-cli测试网速教程

speedtest-cli -h这个和之前介绍的Speedtest一键包功能类似,都是去speedtest测速。

工具开源地址:https://github.com/sivel/speedtest-cli

工具安装方法:

Installation

pip / easy_install

pip install speedtest-cli

or

easy_install speedtest-cli

Github

pip install git+https://github.com/sivel/speedtest-cli.git

or

git clone https://github.com/sivel/speedtest-cli.git
python speedtest-cli/setup.py install

Just download (Like the way it used to be)

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

or

curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

Usage

$ 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

Python API

See the wiki.

Inconsistency

It is not a goal of this application to be a reliable latency reporting tool.

Latency reported by this tool should not be relied on as a value indicative of ICMP style latency. It is a relative value used for determining the lowest latency server for performing the actual speed test against.

There is the potential for this tool to report results inconsistent with Speedtest.net. There are several concepts to be aware of that factor into the potential inconsistency:

  1. Speedtest.net has migrated to using pure socket tests instead of HTTP based tests
  2. This application is written in Python
  3. Different versions of Python will execute certain parts of the code faster than others
  4. CPU and Memory capacity and speed will play a large part in inconsistency between Speedtest.net and even other machines on the same network

Issues relating to inconsistencies will be closed as wontfix and without additional reason or context.

 

安装过程中,如果提示

-bash: pip: command not found

请先安装pip
CentOS
easy_install pip
Ubuntu
apt-get install python-pip

Speedtest一键包 可用于检测VPS网速带宽 vps测速

前面分享的VPS测试脚本虽然都带有网络测试脚本,不过测试到速度可能并非VPS的带宽大小到速度,因为测速节点可能不是你VPS最近到机房,那么速度肯定会受到影响,通过Speedtest脚本可以选择你VPS最近到机房测速,这样测出来到带宽大小和你机器实际带宽大小应该差不多。

一、环境准备

我们使用的工具名称叫做 Speedtest,基于Python2.7编写。

因此支持大部分主流的操作系统版本,比如CentOS、Debian 、Ubuntu等,只要有Python2.7就可以。

二、下载脚本并赋予权限

使用如下命令获取最新版本:

wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py

赋权:

chmod +x speedtest.py

三、运行测试

使用如下命令来运行测试脚本:

./speedtest.py

或者使用Python命令来执行脚本,原理都是相同的:

python speedtest.py

系统会自动判断你服务器所在位置,并找到最近的节点进行测速

四、手动设置测速节点

有时候我们并不满足于测试服务器的出入网带宽,还想测试下到中国的网络速度,那么我们可以使用 –server参数来指定节点。

节点的信息可以从下方网址找到:

http://www.speedtest.net/speedtest-servers-static.php

然后用 ctrl+F 搜索想要使用的节点地址,找到其中节点的id ,加在--server参数后面就可以了。

比如我想使用北京的节点,就可以直接搜索“Beijing”

这样就可以直接找到北京节点,比如我想用北京的联通网络,其id是5145,那我们就可以测试到北京联通的网络速度了。

 

文章转至VPS大学

测试VPS性能和网速的一键脚本bench.sh

通常我们购买vps后会在意VPS的性能和网速,所以就需要来给vps跑一个性能测试。

目前用的最多的就是bench.sh这个脚本了。使用方法也很简单。直接输入下面的命令。

wget -qO- bench.sh | bash

或者

curl -Lso- bench.sh | bash

如果提示wget或者curl命令不存在的话,就需要自己安装,命令如下:

apt-get install wget 或者 yum install wget

Debian和Ubuntu用apt-get命令,Centos用Yum命令,如果要安装curl直接替换命令就行了。

最后测试出来的结果如下:

[root@localhost ~]# bash bench.sh

------------------------VPS基本信息------------------------------------
CPU model : Common KVM processor
Number of cores : 1
CPU frequency : 3199.998 MHz
Total size of Disk : 20.0 GB (1.1 GB Used)
Total amount of Mem : 992 MB (67 MB Used)
Total amount of Swap : 0 MB (0 MB Used)
System uptime : 7 days, 14 hour 28 min
Load average : 0.18, 0.07, 0.06
OS : CentOS 7.2.1511
Arch : x86_64 (64 Bit)
Kernel : 3.10.0-327.el7.x86_64
-----------------------VPS硬盘读写------------------------------------
I/O speed(1st run) : 769 MB/s
I/O speed(2nd run) : 1.0 GB/s
I/O speed(3rd run) : 1.0 GB/s
Average I/O speed : 939.0 MB/s
-----------------------VPS网速测试------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 90.7MB/s
Linode, Tokyo, JP 106.187.96.148 15.2MB/s
Linode, Singapore, SG 139.162.23.4 3.21MB/s
Linode, London, UK 176.58.107.39 2.39MB/s
Linode, Frankfurt, DE 139.162.130.8 3.51MB/s
Linode, Fremont, CA 50.116.14.9 12.5MB/s
Softlayer, Dallas, TX 173.192.68.18 34.5MB/s
Softlayer, Seattle, WA 67.228.112.250 7.78MB/s
Softlayer, Frankfurt, DE 159.122.69.4 3.44MB/s
Softlayer, Singapore, SG 119.81.28.170 2.40MB/s
Softlayer, HongKong, CN 119.81.130.170 4.32MB/s
----------------------------------------------------------------------
Node Name IPv6 address Download Speed
Linode, Atlanta, GA 2600:3c02::4b 6.89MB/s
Linode, Dallas, TX 2600:3c00::4b 13.5MB/s
Linode, Newark, NJ 2600:3c03::4b 4.20MB/s
Linode, Singapore, SG 2400:8901::4b 3.87MB/s
Linode, Tokyo, JP 2400:8900::4b 20.7MB/s
Softlayer, San Jose, CA 2607:f0d0:2601:2a::4 13.1MB/s
Softlayer, Washington, WA 2607:f0d0:3001:78::2 3.72MB/s
Softlayer, Paris, FR 2a03:8180:1301:8::4 7.48MB/s
Softlayer, Singapore, SG 2401:c900:1101:8::2 3.28MB/s
Softlayer, Tokyo, JP 2401:c900:1001:16::4 9.33MB/s
----------------------------------------------------------------------