RTFM.WIKI

Ordnung muß sein. Ordnung über alles (18+)

Инструменты пользователя

Инструменты сайта


web:speedtest

Speedtest

speedtest-cli

Установка в CentOS

# yum install python-pip
# pip install speedtest-cli

Установка в Debian

# apt-get nstall python-pip
# pip install speedtest-cli

Обновление

# pip install speedtest-cli --upgrade

Help

# speedtest-cli --help
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

Testing from 2com (188.x.y.z)...
Selecting best server based on latency...
Hosted by VL-Telecom Ltd (Odintsovo) [12.90 km]: 6.25 ms
Testing download speed........................................
Download: 189.45 Mbit/s
Testing upload speed..................................................
Upload: 153.55 Mbit/s

Поделиться результатом, ключ −−share

[root@localhost ~]# speedtest-cli --share
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from 2com (188.x.y.z)...
Selecting best server based on latency...
Hosted by Beeline (Moscow) [15.29 km]: 6.665 ms
Testing download speed........................................
Download: 190.77 Mbit/s
Testing upload speed..................................................
Upload: 144.92 Mbit/s
Share results: http://www.speedtest.net/result/4917045704.png

Вывести минимум инфы, ключ −−simple

# speedtest-cli --simple
Ping: 6.166 ms
Download: 193.04 Mbit/s
Upload: 168.93 Mbit/s

Посмотреть доступные серверы в Москве

# speedtest-cli --list | grep Moscow
3682) Rostelecom (Moscow, Russian Federation) [15.44 km]
1907) MTS (Moscow, Russian Federation) [15.44 km]
6386) Megafon (Moscow, Russian Federation) [15.44 km]
4718) Beeline (Moscow, Russia) [15.44 km]
6325) OAO Transtelecom (Moscow, Russian Federation) [15.44 km]
6053) MaximaTelecom (Moscow, Russian Federation) [15.44 km]
4984) CLN (Moscow, Russian Federation) [15.44 km]
6827) MGTS (Moscow, Russian Federation) [15.44 km]
6985) CIFRA1 (Moscow, Russian Federation) [15.44 km]
4381) LLC "SouthNets" (Moscow, Russian Federation) [15.44 km]
5201) NK-NET (Moscow, Russia) [15.44 km]
4472) Dataline Ltd (Moscow, Russia) [15.44 km]
6562) Tele2 Russia (Moscow, Russian Federation) [15.44 km]
5581) Retn SJC (Moscow, Russian Federation) [15.44 km]
2322) RuTube (Moscow, Russian Federation) [15.44 km]
6307) AVK Komputer ltd. (Moscow, Russian Federation) [15.44 km]
5040) Alfa Net Telecom (Moscow, Russian Federation) [15.44 km]
5580) H1 LLC (Moscow, Russian Federation) [15.44 km]
7531) Net By Net Holding LLC (Moscow, Russian Federation) [15.44 km]

Посмотреть доступные серверы в России

# speedtest-cli --list | grep Russia

Возьмем для проверки сервер MIPT-Telecom, его код 874

# speedtest-cli --server 874

Если у вас есть свой Speedtest mini сервер, то можно указать для проверки и его

# speedtest-cli --mini http://speedtest.foobar.com

Автоматическое обновление Speedtest Mini на сервере

Самый простой вариант выглядит так

Добавляем в /etc/cron.monthly/speedtest.sh

#!/bin/sh
rm /tmp/mini.zip
curl --output /tmp/mini.zip http://c.speedtest.net/mini/mini.zip
cd /tmp
unzip mini.zip
rm -rf /var/www/html/speedtest
mv mini /var/www/html/speedtest
mv /var/www/html/speedtest/index-php.html /var/www/html/speedtest/index.php

или так

#!/bin/bash
cd /var/tmp/
wget http://c.speedtest.net/mini/mini.zip
unzip -o mini.zip -d /var/www/speedtest.site.ru/
rm -f mini.zip

Варианты чуть посложнее

via https://gist.github.com/sparanoid/abb6e26d968accef9aa2

Показать

Скрыть

#!/usr/bin/env bash
# Speedtest.net Auto Update Script
# Usage: Download the latest SpeedTest script monthly as in 1st of every month at 00:00 
# 0 0 1 * *     nice -n 19 bash /srv/www/speedtest.sh >/dev/null 2>&1
# Make sure speedtest.sh is executable
# chmod +x /srv/www/speedtest.sh

DES_PATH=/usr/share
PUB_PATH=/srv/www/speedtest.tokyo.sparanoid.com/public_html
ST_DIR=speedtest

wget http://c.speedtest.net/mini/mini.zip -O $DES_PATH/$ST_DIR.zip --limit-rate=200000k
unzip -o $DES_PATH/$ST_DIR.zip -d $DES_PATH/$ST_DIR

# Remove old public files
rm -rf $PUB_PATH/$ST_DIR

# Link from private directory to $ST_DIR in public directory
ln -sf $DES_PATH/$ST_DIR/mini $PUB_PATH/$ST_DIR

# Rename index-php.html to index.php
mv $DES_PATH/$ST_DIR/mini/index-php.html $DES_PATH/$ST_DIR/mini/index.php


via http://www.purple.org.ua/speedtest-mini-auto-update/

Показать

Скрыть

cat /opt/speedtest/update.bash
#!/bin/bash
cd /opt/speedtest/

strPathToWebRoot=”/path/to/speedtest/webroot/”

echo “Downloading Archive”
wget http://files.speedtest.ookla.com/releases/mini.zip

echo “Removing Past scripts”
rm -rf $strPathToWebRoot

echo “Unzipping”
unzip mini.zip -d $strPathToWebRoot

echo “Removing Archive”
rm -f mini.zip

echo “Renaming index script”
mv $strPathToWebRoot/index-php.html $strPathToWebRoot/index.html

echo “Done”


via https://github.com/szepeviktor/debian-server-tools/blob/master/monitoring/speedtest-mini-update.sh

Показать

Скрыть

#!/bin/bash
#
# Check Speedtest Mini expiration time and update it.
#
# VERSION       :0.3.1
# DATE          :2016-09-24
# AUTHOR        :Viktor Szépe <[email protected]>
# LICENSE       :The MIT License (MIT)
# URL           :https://github.com/szepeviktor/debian-server-tools
# BASH-VERSION  :4.2+
# DEPENDS       :apt-get install swfmill unzip
# LOCATION      :/usr/local/bin/speedtest-mini-update.sh
# CRON-WEEKLY   :/usr/local/bin/speedtest-mini-update.sh

echo "As of June 30, 2017 Speedtest Mini will no longer be available" 1>&2
echo "http://www.ookla.com/speedtest-custom" 1>&2
exit 100

# Set your document root
MINI_PATH="/home/USER/website/html/speed"
# Date-style expiration time
MINI_EXPIRE="2 months ago"

# http://www.speedtest.net/mini.php
MINI_URL="http://c.speedtest.net/mini/mini.zip"

Die() {
    local RET="$1"

    shift
    echo -e "$@" 1>&2
    exit "$RET"
}

Check_expiration() {
    local MODIFY_DATE
    local -i MODIFY_SECONDS="0"
    local -i MONTH_AGO_SECONDS

    if hash swfmill 2> /dev/null && [ -f "${MINI_PATH}/speedtest.swf" ]; then
        MODIFY_DATE="$(swfmill -n -e latin1 swf2xml "${MINI_PATH}/speedtest.swf" 2> /dev/null \
            | sed -n -e 's|^.*<xmp:ModifyDate>\(.*\)</xmp:ModifyDate>.*$|\1|p')"

        if [ -n "$MODIFY_DATE" ]; then
            MODIFY_SECONDS="$(date --date "$MODIFY_DATE" "+%s" 2> /dev/null || echo 0)"
        fi
    fi

    MONTH_AGO_SECONDS="$(date --date="$MINI_EXPIRE" "+%s")"
    # Expired, return with the exit code
    [ "$MODIFY_SECONDS" -lt "$MONTH_AGO_SECONDS" ]
}

Update_mini() {
    local ZIP

    ZIP="$(basename "$MINI_URL")"

    # Limit the download speed (2 MB/s)
    wget -q --limit-rate=2m -O "${MINI_PATH}/${ZIP}" "$MINI_URL" || Die 1 "ZIP download"

    # Remove old files
    if [ -d "${MINI_PATH}/mini" ]; then
        rm -r "${MINI_PATH}/mini" || Die 2 "Failed to remove old files: ./mini"
    fi
    if [ -d "${MINI_PATH}/speedtest" ]; then
        rm -r "${MINI_PATH}/speedtest" || Die 3 "Failed to remove old files: ./speedtest"
    fi

    # Extract ZIP
    unzip -q "${MINI_PATH}/${ZIP}" -d "${MINI_PATH}/" || Die 4 "Extraction failed."
    rm "${MINI_PATH}/${ZIP}" || Die 5 "ZIP cannot be removed."

    # Deploy speedtest mini
    mv "${MINI_PATH}/mini/speedtest.swf" "${MINI_PATH}/" || Die 6 "Flash file cannot be moved in place."
    mv "${MINI_PATH}/mini/speedtest" "${MINI_PATH}/" || Die 7 "Payload files cannot be moved in place."
    mv "${MINI_PATH}/mini/crossdomain.xml" "${MINI_PATH}/" || Die 8 "crossdomain.xml cannot be moved in place."
    mv "${MINI_PATH}/mini/index-php.html" "${MINI_PATH}/index.php" || Die 9 "Index file cannot be moved in place."

    # Remove files for other platforms
    rm -r "${MINI_PATH}/mini" || Die 10 "Failed to remove unnecassary files."
    # Set permissions
    find "${MINI_PATH}" -type f -exec chmod -x "{}" ";" || Die 11 "Failed to turn off execution bit."
}

Check_expiration && Update_mini

exit 0
Сайт rtfm.wiki использует cookies и трекинг посещений. Продолжая использовать этот сайт, вы соглашаетесь с сохранением файлов cookie на вашем компьютере. Если вы не согласны покиньте сайт или включите Adblock 😎 Что такое cookies? 🍪

Обсуждение

Ваш комментарий. Вики-синтаксис разрешён:
 
web/speedtest.txt · Последнее изменение: 2018/02/05 13:48 — 127.0.0.1