GithubHelp home page GithubHelp logo

speedtest-cli-extras's Introduction

speedtest-cli-extras

The speedtest-cli-extras repository contains tools that enhance the speedtest-cli command-line interface to speedtest.net for benchmarking an internet connection.

Requirements

  • The speedtest-csv tool requires:
    • a Bash shell or be called via bash speedtest-csv.
    • speedtest-cli which in turn requires Python.
    • that speedtest-cli is on the PATH or in the same directory as speedtest-csv.

Windows users: The MinGW project's MSYS package is an straightforward way to get Bash on Windows. Note, there is a speedtest-csv.bat Windows Batch wrapper script that calls the Bash script for you. In other words, if you call speedtest-csv at the Windows command prompt, it will work just as if you called it from Bash. Regardless, you do need Bash also on Windows.

speedtest-csv

The speedtest-csv tool calls speedtest-cli, captures its multi-line output, reformats it, adds time stamps, and outputs the benchmark statistics on a single well formatted line, e.g.

$ speedtest-csv --header
start	stop	from	from_ip	server	server_dist (km)	server_ping (ms)	download (Mbit/s)	upload (Mbit/s)	share_url
$ speedtest-csv
2016-04-04 16:35:01	2016-04-04 16:35:51	Comcast Cable	24.130.241.190	Fastmetrics Inc. (San Francisco, CA)	20.46	18.168	4.88	1.34	http://www.speedtest.net/result/5224137223.png

Collecting statistics over time

By running the above on a regular basis (e.g. once an hour) and appending the output to a TAB-delimited file one can gather statistics over time. To add meaningful column names to the top of this file, start off by adding a header:

$ speedtest-csv --header > speedtest_stats.tsv
# At 00:00 UTC
$ speedtest-csv >> speedtest_stats.tsv
# At 01:00 UTC
$ speedtest-csv >> speedtest_stats.tsv
# ...

$ less speedtest_stats.tsv
start	stop	from	from_ip	server	server_dist	server_ping	download	upload	share_url
2016-04-04 08:00:01	2016-04-04 08:01:01	Comcast Cable	24.130.241.190	Fastmetrics Inc. (San Francisco, CA)	20.46	18.168	4.88	1.34	http://www.speedtest.net/result/5224137223.png
2016-04-04 09:00:02	2016-04-04 09:00:42	Comcast Cable	24.130.241.190	Monkey Brains (San Francisco, CA)	21.36	16.723	3.40	0.21	http://www.speedtest.net/result/5224152283.png
[...]

If you're on Linux or macOS, you can use Cron jobs to automate the above.

Usage

$ speedtest-csv --help
speedtest-csv 2.0.1

Usage:
 speedtest-csv [options]

Options:
 --header          Display field names (only)

 --header-units    Units (ms, Mbit/s and km) are in header (default)
 --no-header-units Units are in the values
 --standardize     Standardize units and number formats (default)
 --no-standardize  Disable --standardize
 --share           Generate and provide a URL to the speedtest.net
                   share results image (default)
 --no-share        Disable --share

 --quote <str>     Quote fields using <str> (default: none)
 --sep <str>       Separate fields using <str> (default '\t')

 --help            This help
 --version         Display version

 --debug           Output extra debug information
 --last            Use most recent stats, if available
                   (avoids calling `speedtest-cli`)

Any other options are passed to speedtest-cli as is.

Example:
 speedtest-csv --header
 speedtest-csv

 # Defaults in speedtest-csv (<= 1.3.0):
 speedtest-csv --sep ';' --no-standardize --no-header-units

Installed dependencies:
 speedtest-cli 1.0.1 (https://github.com/sivel/speedtest-cli)
 python 2.7.12

Copyright: 2014-2017 Henrik Bengtsson
License: GPL (>= 2.1) (https://www.gnu.org/licenses/gpl.html)

Notes

As of Nov 2016, speedtest-cli (>= 1.0.0) itself supports outputting the results a single comma-separated value line. The format is slightly different from here, but the idea is very similar.

speedtest-cli-extras's People

Contributors

henrikbengtsson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

speedtest-cli-extras's Issues

Error on line 38

Hi I have copied your code onto my pi and when I run the SH script I get the following:
speedtest-csv.sh: 38: speedtest-csv.sh: Syntax error: "(" unexpected

server id

Hello,

is it possible to set the server ID´s? He check always with the closest ... but I want to set the server for speedtest.

speedtest-cli can use the server id: --server SERVER

Thank you!

When called in CRON log is empty

Hi when I call speedlink-csv >> /home/pi/speedlink.log using cron, I get a dtae and time and the following fields are all empty. Basically it is just a number of ; with no content!

ROBUSTNESS: Agile to exit code/value of speedtest-cli

Background

If there's an error running speedtest-cli it returns with a non-zero exit value (in bash queried by $?).

Currently, speedtest-csv ignores the exit value and simply assumes everything was correct, i.e. it outputs data (mostly missing) regardless.

Wish

The speedtest-csv wrapper should check this value and proceed accordingly, e.g. in turn generate an informative error message and return with a non-zero exit code (probably the same one as speedtest-cli).

See also

This is related to Issue #10.

Blank responce detection

Hello, is it possible for the script to test if the results come back blank?

Every so often i just get the date the test started and finished and no data

urllib2.HTTPError: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.

Hi there,

since yesterday I got the following error when executing speedtest-csv:

Cron root@merz-netbook /usr/local/bin/speedtest-cli/speedtest-csv.sh --standardize --sep '\t' >> /usr/local/bin/speedtest-cli/results-date +%Y-%m.csv
09:50
(Cron Daemon)
An root@merz-netbook
Traceback (most recent call last):
File "/usr/local/bin/speedtest-cli/speedtest-cli.py", line 674, in
main()
File "/usr/local/bin/speedtest-cli/speedtest-cli.py", line 668, in main
speedtest()
File "/usr/local/bin/speedtest-cli/speedtest-cli.py", line 518, in speedtest
servers = closestServers(config['client'])
File "/usr/local/bin/speedtest-cli/speedtest-cli.py", line 336, in closestServers
uh = urlopen('http://www.speedtest.net/speedtest-servers.php')
File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib64/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 469, in error
result = self._call_chain(_args)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(_args)
File "/usr/lib64/python2.7/urllib2.py", line 656, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib64/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 469, in error
result = self._call_chain(_args)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(_args)
File "/usr/lib64/python2.7/urllib2.py", line 656, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib64/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 469, in error
result = self._call_chain(_args)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(_args)
File "/usr/lib64/python2.7/urllib2.py", line 656, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib64/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 469, in error
result = self._call_chain(_args)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(_args)
File "/usr/lib64/python2.7/urllib2.py", line 656, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib64/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 469, in error
result = self._call_chain(_args)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(_args)
File "/usr/lib64/python2.7/urllib2.py", line 646, in http_error_302
self.inf_msg + msg, headers, fp)
urllib2.HTTPError: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Found

speedtest-cli.py works fine:

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Unitymedia (xxx)...
Selecting best server based on latency...
Hosted by xxx (xxx) [3.46 km]: 20.014 ms Testing download speed........................................
Download: 91.74 Mbit/s
Testing upload speed..................................................
Upload: 4.81 Mbit/s

Kind regards
Thomas

Support comma-separated output

Currently it's not safe to use commas for separated values, because some servers return some values with commas rather than periods (probably due to their locale settings).

One solution would be to bluntly replace any commas with periods (in each of the fields/variables) before generating the one-line output, e.g. via sed.

Contributions appreciated.

HEADS UP: Making --sep '\t' --standardize the new default

Just a heads up to everyone:

I'm planning to make --sep '\t' and --standardize the default in the next a near-future release. For backward compatibility with the current defaults, make sure to update your scripts to use --sep ';' and --no-standardize.

Report generation using R

Hi @normcyr, I'm sorry for the long delay (been swamped) and thanks a bunch for your PR #6 providing an R script that generates several figures summarizing the Speedtest stats graphically.

I've actually already created a (private) HTML report generator based on R to do similar things. Here is an HTML report that I used to convince my ISP that there was something wrong with our connection - it turned out that squirrels had been chewing on the incoming cable for quite some time.

I'll see if I can clean up the report generator and add it to this repository. All that will be required is the R software. The rest will be taken care of using R packages available on CRAN.

BTW, I happy to see that this repository got lots of stars recently. Does anyone know the background?

https://

Hi Henrik
Any chance of adding an https:// option to allow everything to run securely and generate https:// paths?

I'm currently using a perl script to tweet the results like so:-
speedtest_dev.zip

but it would be nice if I could eliminate some code and have everything run securely :)

SteveW

Invalid number format

Hi,
I run speedtest-csv every hour:

T-Mobile CZ, Prague
sh speedtest-csv --server 3989 >> stats.tsv

And in some cases I got wrong download results (there is . added before the number):

start stop from from_ip server server_dist (km) server_ping (ms) download (Mbit/s) upload (Mbit/s) share_url
2017-02-07 00:25:02 2017-02-07 00:25:29 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 47.129 55.11 43.30 http://www.speedtest.net/result/6031287998.png
2017-02-07 01:25:02 2017-02-07 01:25:21 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 45.565 119.57 46.82 http://www.speedtest.net/result/6031379719.png
2017-02-07 02:25:02 2017-02-07 02:25:21 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 47.038 144.27 47.96 http://www.speedtest.net/result/6031469289.png
2017-02-07 03:25:03 2017-02-07 03:25:23 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 63.191 136.84 41.40 http://www.speedtest.net/result/6031562050.png
2017-02-07 04:25:02 2017-02-07 04:25:22 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 51.054 126.69 43.30 http://www.speedtest.net/result/6031652500.png
2017-02-07 05:25:02 2017-02-07 05:25:21 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 47.473 126.45 48.20 http://www.speedtest.net/result/6031740129.png
2017-02-07 06:25:03 2017-02-07 06:25:22 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 47.64 128.41 43.98 http://www.speedtest.net/result/6031825283.png
2017-02-07 07:25:02 2017-02-07 07:25:22 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 46.879 .119.43 42.38 http://www.speedtest.net/result/6031913227.png
2017-02-07 08:25:02 2017-02-07 08:25:23 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 47.663 134.29 35.31 http://www.speedtest.net/result/6032008971.png
2017-02-07 09:25:03 2017-02-07 09:25:22 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 49.25 113.60 44.47 http://www.speedtest.net/result/6032114417.png
2017-02-07 10:25:02 2017-02-07 10:25:21 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 48.958 .115.94 45.34 http://www.speedtest.net/result/6032229700.png
2017-02-07 11:25:02 2017-02-07 11:25:21 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 28.699 85.19 43.51 http://www.speedtest.net/result/6032351494.png
2017-02-07 12:25:03 2017-02-07 12:25:23 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 37.643 118.09 44.09 http://www.speedtest.net/result/6032479826.png
2017-02-07 13:25:02 2017-02-07 13:25:25 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 61.414 41.71 24.25 http://www.speedtest.net/result/6032613165.png
2017-02-07 14:25:02 2017-02-07 14:25:22 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 39.195 97.09 40.79 http://www.speedtest.net/result/6032755547.png
2017-02-07 15:25:03 2017-02-07 15:25:24 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 46.253 63.34 34.55 http://www.speedtest.net/result/6032910971.png
2017-02-07 16:25:02 2017-02-07 16:25:25 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 39.249 69.24 27.82 http://www.speedtest.net/result/6033075147.png
2017-02-07 17:25:02 2017-02-07 17:25:23 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 57.186 67.98 34.45 http://www.speedtest.net/result/6033245636.png
2017-02-07 18:25:03 2017-02-07 18:25:24 T-Mobile 193.179.12.180 T-Mobile CZ (Prague) 90.01 52.787 94.07 37.07 http://www.speedtest.net/result/6033420776.png

Am I doing something wrong or is it a bug? Thx

Minor bash script issues

Very useful extras. Here's some minor issues:

You need the shebang #!/usr/bin/env bash to be the first line to be effective

Also, if you rename it to speedtest-csv.sh then github will colorize the bash when you look at it, whihc is minorly useful.

Finally, I had to mark the script executable before it could be run. Git can remember this file mode, so if you mark it as executable then commit that change no one else would have to do this

Speedtest-csv Stopped Working with Speedtest.net beta

Without any action on my part speedtest-csv stopped working between 1500 and 1600 on 8th of June. Trouble shooting I discover that speedtest.net how has a new display http://beta.speedtest.net. If this is the real problem, will there be a code update? How should I modify speedtest-csv to work with the beta version of speedtest.net.

Thank you for your replay and assistance is restoring this excellent device.

speedtest-csv --help incorrectly claims speedtest-cli needs to be installed

Example:

$ speedtest-csv --help
speedtest-csv 2.0.0
[...]
Installed dependencies:
 speedtest-cli <PLEASE INSTALL> (https://github.com/sivel/speedtest-cli)
 python 2.7.12

Copyright: 2014-2017 Henrik Bengtsson
License: GPL (>= 2.1) (https://www.gnu.org/licenses/gpl.html)

This is with:

$ which speedtest-cli
/usr/bin/speedtest-cli
$ which speedtest-csv
/home/hb/bin/speedtest-csv

Not a critical problem, but misleading.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.