This repository contains tools that enhance the speedtest-cli command-line interface to speedtest.net. This fork of speedtest-cli-extras extends the script by adding options to send results to an IFTTT Maker Channel or Loggly.
$ pip install speedtest-cli
./speedtest-extras.sh [-d] [-c] [-h] [-i secret-key] [-l] -d: debugging-mode (reuses previously logged speedtest result instead of queriying speedtest - faster) -c: CSV mode -h: Print CSV header (only if used together with the -c flag) -i: IFTTT mode. Takes an IFTTT Maker Channel secret key as argument (required) -l: Loggly mode. Takes a Loggly Customer Token as argument (required) -j: JSON mode. Posts the result as a JSON document to any URL passed as argument (required)
Example: CSV Mode
Generate headers (e.g. to start a new CSV file):
$ ./speedtest-extras.sh -c -h start;stop;from;from_ip;server;server_dist;server_ping;download;upload;share_url
Run speedtest and output results in CSV format:
$ ./speedtest-extras.sh -c 2014-09-06 10:07:51;2014-09-06 10:09:31;Comcast Cable;188.8.131.52;AT&T (San Francisco, CA);20.22 km;24.536 ms;44.25 Mbits/s;4.93 Mbits/s;http://www.speedtest.net/result/3741180214.png
The above examples print the output to STDOUT (the terminal). To record results into a file instead, use something like:
$ ./speedtest-extras.sh -c -h >> file.csv $ ./speedtest-extras.sh -c >> file.csv
Every subsquent run of speedtest-extras.sh will add another line to file.csv.
Example: IFTTT Mode
You will need to setup a IFTTT Maker Channel first. Once this is done, IFTTT will display a unique key for you to send events to that channel. You will need this key to run speedtest-extras.sh in IFTTT mode.
$ ./speedtest-extras.sh -i <YOUR-PRIVATE-KEY>
If the event was successfully triggered, the script will not generate any output. Check your IFTTT channel to make sure everything is working. Connect this channel to another action as you like, for example to add a line to a Google Spreadsheet.
Example: Loggly Mode
You will need a Loggly account for this to work (the free account should be fine). Use your own customer token (found under Source Setup > Customer Tokens in your Loggly dashboard) to call the script:
$ ./speedtest-extras.sh -l <YOUR-CUSTOMER-TOKEN>
If the event was successfully triggered, the script will not generate any output. Check your Loggly events to make sure everything is working.
Example: JSON Mode
$ ./speedtest-extras.sh -j https://zapier.com/hooks/catch/xxxxxxx/xxxxx
(replace the dummy URL above by the one Zapier creates for you when setting up your Webhook). I cover this use case in more details on my blog.
speedtest-extras bash script calls
speedtest-cli, captures its output, reformats it, and either outputs it on a single line with time stamps and values separated by semicolons*, sends it to an IFTTT Maker Channel called speedtest or to Loggly tagged as speedtest.
(*) Commas are not safe to use to separate the values, because some test servers report speeds with commas instead of periods. Because of this, semicolons are used instead.
This is a fork of speedtest-cli-extras by Henrik Bengtsson. The export to IFTTT was inspired by a project on Make: Magazine by Alasdair Allan. The export to Loggly was inspired by this post from Stephen Phillips.