EVERYTHING!

This commit is contained in:
Adam Rabjerg
2021-08-26 12:17:40 +02:00
commit 601a9f168b
8 changed files with 981 additions and 0 deletions

225
ookla_bin/install.deb.sh Executable file
View File

@@ -0,0 +1,225 @@
#!/usr/bin/env bash
OS_RELEASE_ID=$(grep "^ID=" /etc/os-release | cut -d '=' -f 2- | sed 's|"||g')
OS_RELEASE_VERSION_ID=$(grep "^VERSION_ID=" /etc/os-release | cut -d '=' -f 2- | sed 's|"||g')
# Matches supported platforms at: https://packagecloud.io/ookla/speedtest-cli
SUPPORTED=false
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "16.04" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "16.10" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "17.04" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "17.10" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "18.04" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "18.10" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "19.04" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "19.10" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "20.04" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "20.10" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "ubuntu" && "${OS_RELEASE_VERSION_ID}" =~ "21.04" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "debian" && "${OS_RELEASE_VERSION_ID}" == "8" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "debian" && "${OS_RELEASE_VERSION_ID}" == "9" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "debian" && "${OS_RELEASE_VERSION_ID}" == "10" ]] && SUPPORTED=true
[[ "${OS_RELEASE_ID}" == "debian" && "${OS_RELEASE_VERSION_ID}" == "11" ]] && SUPPORTED=true
[[ "${SUPPORTED}" == "false" ]] && echo "This distribution version is not currently supported via package management, please use the direct download builds per architecture found at https://www.speedtest.net/apps/cli" && exit 1
## Inlined PackageCloud installation script below
## -- source: https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh
unknown_os ()
{
echo "Unfortunately, your operating system distribution and version are not supported by this script."
echo
echo "You can override the OS detection by setting os= and dist= prior to running this script."
echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version"
echo
echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
echo
echo "Please email support@packagecloud.io and let us know if you run into any issues."
exit 1
}
gpg_check ()
{
echo "Checking for gpg..."
if command -v gpg > /dev/null; then
echo "Detected gpg..."
else
echo "Installing gnupg for GPG verification..."
apt-get install -y gnupg
if [ "$?" -ne "0" ]; then
echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work."
echo "Repository installation aborted."
exit 1
fi
fi
}
curl_check ()
{
echo "Checking for curl..."
if command -v curl > /dev/null; then
echo "Detected curl..."
else
echo "Installing curl..."
apt-get install -q -y curl
if [ "$?" -ne "0" ]; then
echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work."
echo "Repository installation aborted."
exit 1
fi
fi
}
install_debian_keyring ()
{
if [ "${os}" = "debian" ]; then
echo "Installing debian-archive-keyring which is needed for installing "
echo "apt-transport-https on many Debian systems."
apt-get install -y debian-archive-keyring &> /dev/null
fi
}
detect_os ()
{
if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
# some systems dont have lsb-release yet have the lsb_release binary and
# vice-versa
if [ -e /etc/lsb-release ]; then
. /etc/lsb-release
if [ "${ID}" = "raspbian" ]; then
os=${ID}
dist=`cut --delimiter='.' -f1 /etc/debian_version`
else
os=${DISTRIB_ID}
dist=${DISTRIB_CODENAME}
if [ -z "$dist" ]; then
dist=${DISTRIB_RELEASE}
fi
fi
elif [ `which lsb_release 2>/dev/null` ]; then
dist=`lsb_release -c | cut -f2`
os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
elif [ -e /etc/debian_version ]; then
# some Debians have jessie/sid in their /etc/debian_version
# while others have '6.0.7'
os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
if grep -q '/' /etc/debian_version; then
dist=`cut --delimiter='/' -f1 /etc/debian_version`
else
dist=`cut --delimiter='.' -f1 /etc/debian_version`
fi
else
unknown_os
fi
fi
if [ -z "$dist" ]; then
unknown_os
fi
# remove whitespace from OS and dist name
os="${os// /}"
dist="${dist// /}"
echo "Detected operating system as $os/$dist."
}
main ()
{
detect_os
curl_check
gpg_check
# Need to first run apt-get update so that apt-transport-https can be
# installed
echo -n "Running apt-get update... "
apt-get update &> /dev/null
echo "done."
# Install the debian-archive-keyring package on debian systems so that
# apt-transport-https can be installed next
install_debian_keyring
echo -n "Installing apt-transport-https... "
apt-get install -y apt-transport-https &> /dev/null
echo "done."
gpg_key_url="https://packagecloud.io/ookla/speedtest-cli/gpgkey"
apt_config_url="https://packagecloud.io/install/repositories/ookla/speedtest-cli/config_file.list?os=${os}&dist=${dist}&source=script"
apt_source_path="/etc/apt/sources.list.d/ookla_speedtest-cli.list"
echo -n "Installing $apt_source_path..."
# create an apt config file for this repository
curl -sSf "${apt_config_url}" > $apt_source_path
curl_exit_code=$?
if [ "$curl_exit_code" = "22" ]; then
echo
echo
echo -n "Unable to download repo config from: "
echo "${apt_config_url}"
echo
echo "This usually happens if your operating system is not supported by "
echo "packagecloud.io, or this script's OS detection failed."
echo
echo "You can override the OS detection by setting os= and dist= prior to running this script."
echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version"
echo
echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
echo
echo "If you are running a supported OS, please email support@packagecloud.io and report this."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
echo "curl is unable to connect to packagecloud.io over TLS when running: "
echo " curl ${apt_config_url}"
echo "This is usually due to one of two things:"
echo
echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
echo
echo "Contact support@packagecloud.io with information about your system for help."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" -gt "0" ]; then
echo
echo "Unable to run: "
echo " curl ${apt_config_url}"
echo
echo "Double check your curl installation and try again."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
else
echo "done."
fi
echo -n "Importing packagecloud gpg key... "
# import the gpg key
curl -L "${gpg_key_url}" 2> /dev/null | apt-key add - &>/dev/null
echo "done."
echo -n "Running apt-get update... "
# update apt on this system
apt-get update &> /dev/null
echo "done."
echo
echo "The repository is setup! You can now install packages."
}
main

Binary file not shown.

BIN
ookla_bin/speedtest Executable file

Binary file not shown.

430
ookla_bin/speedtest.5 Normal file
View File

@@ -0,0 +1,430 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "SPEEDTEST" "" "October 2019" "" ""
.
.SH "Name"
\fBspeedtest\fR \- Speedtest CLI by Ookla is the official command line client for testing the speed and performance of your internet connection\.
.
.SH "Version"
1\.0\.0
.
.SH "Synopsis"
.
.nf
speedtest [\-aAbBfhiIpPsv] [\-\-ca\-certificate=path] [\-\-format=[=format\-type]] [\-\-help] [\-\-interface=interface]
[\-\-ip=ip_address] [\-\-output\-header] [\-\-precision=num_decimal_places] [\-\-progress=yes|no]
[\-\-selection\-details] [\-\-server\-id=id] [\-\-servers] [\-\-unit=[=unit\-of\-measure]] [\-\-version]
.
.fi
.
.SH "Description"
\fBspeedtest\fR is an application that measures the latency, jitter, packet loss, download bandwidth, and upload bandwidth of the network connection between the client and a nearby Speedtest Server\.
.
.SH "Options"
.
.IP "\(bu" 4
\fB\-h, \-\-help\fR
.
.br
Print usage information
.
.IP "\(bu" 4
\fB\-v\fR Logging verbosity, specify multiple times for higher verbosity (e\.g\. \fB\-vvv\fR)
.
.IP "\(bu" 4
\fB\-V, \-\-version\fR Print version number
.
.IP "\(bu" 4
\fB\-L, \-\-servers\fR List nearest servers
.
.IP "\(bu" 4
\fB\-\-selection\-details\fR Show server selection details
.
.IP "\(bu" 4
\fB\-s\fR \fIid\fR, \fB\-\-server\-id\fR=\fIid\fR
.
.br
Specify a server from the server list using its id
.
.IP "\(bu" 4
\fB\-o\fR \fIhostname\fR, \fB\-\-host\fR=\fIhostname\fR
.
.br
Specify a server from the server list using its hostname
.
.IP "\(bu" 4
\fB\-f\fR \fIformat_type\fR \fB\-\-format\fR=\fIformat_type\fR
.
.br
Output format (default = human\-readable) Note: Machine readable formats (csv, tsv, json, jsonl, json\-pretty) use bytes as the unit of measure with max precision\.
.
.IP
\fIformat_type\fR values are as follows:
.
.IP "\(bu" 4
\fBhuman\-readable\fR human readable output
.
.IP "\(bu" 4
\fBcsv\fR comma separated values
.
.IP "\(bu" 4
\fBtsv\fR tab separated values
.
.IP "\(bu" 4
\fBjson\fR javascript object notation (compact)
.
.IP "\(bu" 4
\fBjsonl\fR javascript object notation (lines)
.
.IP "\(bu" 4
\fBjson\-pretty\fR javascript object notation (pretty)
.
.IP "" 0
.
.IP "\(bu" 4
\fB\-\-output\-header\fR Show output header for CSV and TSV formats
.
.IP "\(bu" 4
\fB\-u\fR\fIunit_of_measure\fR\fB,\~\-\-unit\fR\fIunit_of_measure\fR Output unit for displaying speeds (Note: this is only applicable for human\-readable output format and the default unit is Mbps)
.
.IP "\(bu" 4
\fBbps\fR bits per second (decimal prefix)
.
.IP "\(bu" 4
\fBkbps\fR kilobits per second (decimal prefix)
.
.IP "\(bu" 4
\fBMbps\fR megabits per second (decimal prefix)
.
.IP "\(bu" 4
\fBGbps\fR gigabits per second (decimal prefix)
.
.IP "\(bu" 4
\fBkibps\fR kilobits per second (binary prefix)
.
.IP "\(bu" 4
\fBMibps\fR megabits per second (binary prefix)
.
.IP "\(bu" 4
\fBGibps\fR gigabits per second (binary prefix)
.
.IP "\(bu" 4
\fBB/s\fR bytes per second
.
.IP "\(bu" 4
\fBkB/s\fR kilobytes per second
.
.IP "\(bu" 4
\fBMB/s\fR megabytes per second
.
.IP "\(bu" 4
\fBGiB/s\fR gigabytes per second
.
.IP "\(bu" 4
\fBauto\-binary\-bytes\fR automatic in binary bytes
.
.IP "\(bu" 4
\fBauto\-decimal\-bytes\fR automatic in decimal bytes
.
.IP "\(bu" 4
\fBauto\-binary\-bytes\fR automatic in binary bits
.
.IP "\(bu" 4
\fBauto\-binary\-bytes\fR automatic in decimal bits
.
.IP "" 0
.
.IP "\(bu" 4
\fB\-a\fR
.
.br
Shortcut for [\fB\-u auto\-decimal\-bits\fR]
.
.IP "\(bu" 4
\fB\-A\fR
.
.br
Shortcut for [\fB\-u auto\-decimal\-bytes\fR]
.
.IP "\(bu" 4
\fB\-b\fR
.
.br
Shortcut for [\fB\-u auto\-binary\-bits\fR]
.
.IP "\(bu" 4
\fB\-B\fR
.
.br
Shortcut for [\fB\-u auto\-binary\-bytes\fR]
.
.IP "\(bu" 4
\fB\-P\fR \fIdecimal_places\fR \fB\-\-precision\fR=\fIdecimal_places\fR
.
.br
Number of decimal_places to use (default = 2, valid = 0\-8)
.
.IP "\(bu" 4
\fB\-p\fR \fIyes\fR|\fIno\fR \fB\-\-progress\fR=\fIyes\fR|\fIno\fR
.
.br
Enable or disable progress bar (default = yes when interactive)
.
.IP "\(bu" 4
\fB\-I\fR \fIinterface\fR \fB\-\-interface\fR=\fIinterface\fR Attempt to bind to the specified interface when connecting to servers
.
.IP "\(bu" 4
\fB\-i\fR \fIip_address\fR \fB\-\-ip\fR=\fIip_address\fR Attempt to bind to the specified IP address when connecting to servers
.
.IP "\(bu" 4
\fB\-\-ca\-certificate\fR=\fIpath\fR Path to CA Certificate bundle, see note below\.
.
.IP "" 0
.
.SH "Terms of Use and Privacy Policy Notices"
You may only use this Speedtest software and information generated from it for personal, non\-commercial use, through a command line interface on a personal computer\. Your use of this software is subject to the End User License Agreement, Terms of Use and Privacy Policy at these URLs:
.
.IP "\(bu" 4
\fIhttps://www\.speedtest\.net/about/eula\fR
.
.IP "\(bu" 4
\fIhttps://www\.speedtest\.net/about/terms\fR
.
.IP "\(bu" 4
\fIhttps://www\.speedtest\.net/about/privacy\fR
.
.IP "" 0
.
.SH "Output"
Upon successful execution, the application will exit with an exit code of 0\. The result will include latency, jitter, download, upload, packet loss (where available), and a result URL\.
.
.P
Latency and jitter will be represented in milliseconds\. Download and upload units will depend on the output format as well as if a unit was specified\. The human\-readable format defaults to Mbps and any machine\-readable formats (csv, tsv, json, jsonl, json\-pretty) use bytes as the unit of measure with max precision\. Packet loss is represented as a percentage, or \fBNot available\fR when packet loss is unavailable in the executing network environment\.
.
.P
The Result URL is available to share your result, appending \fB\.png\fR to the Result URL will create a shareable result image\.
.
.P
\fIExample human\-readable result:\fR
.
.IP "" 4
.
.nf
$ speedtest
Speedtest by Ookla
Server: Speedtest\.net \- New York, NY (id = 10390)
ISP: Comcast Cable
Latency: 57\.81 ms (3\.65 ms jitter)
Download: 76\.82 Mbps (data used: 80\.9 MB)
Upload: 37\.58 Mbps (data used: 65\.3 MB)
Packet Loss: 0\.0%
Result URL: https://www\.speedtest\.net/result/c/8ae1200c\-e639\-45e5\-8b55\-41421a079250
.
.fi
.
.IP "" 0
.
.SH "Network Timeout Values"
By default, network requests set a timeout of \fB10\fR seconds\. The only exception to this is latency testing, which sets a timeout of \fB15\fR seconds\.
.
.SH "Fatal Errors"
Upon fatal errors, the application will exit with a non\-zero exit code\.
.
.P
\fBInitialization Fatal Error Examples:\fR
.
.P
\fIConfiguration \- Couldn\'t connect to server (Network is unreachable)\fR
.
.P
\fIConfiguration \- Could not retrieve or read configuration (ConfigurationError)\fR
.
.P
\fBStage Execution Fatal Error Example:\fR
.
.P
\fI[error] Error: [1] Latency test failed for HTTP\fR
.
.P
\fI[error] Error: [36] Cannot open socket: Operation now in progress\fR
.
.P
\fI[error] Failed to resolve host name\. Cancelling test suite\.\fR
.
.P
\fI[error] Host resolve failed: Exec format error\fR
.
.P
\fI[error] Cannot open socket: No route to host\fR
.
.P
\fI[error] Server Selection \- Failed to find a working test server\. (NoServers)\fR
.
.SH "SSL Certificate Locations"
By default the following paths are checked for CA certificate bundles on linux machines:
.
.IP "" 4
.
.nf
/etc/ssl/certs/ca\-certificates\.crt
/etc/pki/tls/certs/ca\-bundle\.crt
/usr/share/ssl/certs/ca\-bundle\.crt
/usr/local/share/certs/ca\-root\-nss\.crt
/etc/ssl/cert\.pem
.
.fi
.
.IP "" 0
.
.P
If the device under test does \fInot\fR have one of the above mentioned files, then the canonical and up to date CA certificate bundle provided by the curl project can be manually downloaded into a specific location\. This specific location can be provided as a parameter per the following example:
.
.IP "" 4
.
.nf
wget https://curl\.haxx\.se/ca/cacert\.pem
\./ookla \-\-ca\-certificate=\./cacert\.pem
.
.fi
.
.IP "" 0
.
.SH "Release Notes"
.
.SS "1\.0\.0 \- 10/29/2019"
.
.IP "\(bu" 4
Initial release
.
.IP "" 0
.
.SH "Copyright Notices for Third\-Party Products/Libraries"
This software incorporates free and open source third\-party libraries, including:
.
.IP "\(bu" 4
boost \fIhttps://www\.boost\.org/\fR
.
.IP "\(bu" 4
libcurl \fIhttps://curl\.haxx\.se/libcurl/\fR
.
.IP "\(bu" 4
petopt \fIhttps://www\.lysator\.liu\.se/~pen/petopt/\fR
.
.IP "\(bu" 4
mbed TLS \fIhttps://tls\.mbed\.org/\fR
.
.IP "\(bu" 4
ca\-certificates extract \fIhttps://curl\.haxx\.se/docs/caextract\.html\fR
.
.IP "\(bu" 4
L\. Peter Deutschs md5 \fIhttps://sourceforge\.net/projects/libmd5\-rfc/files/\fR
.
.IP "\(bu" 4
getopt\.h \fIin%20Windows%20version%20of%20this%20software\fR
.
.IP "\(bu" 4
tiny\-aes \fIhttps://github\.com/kokke/tiny\-AES\-c\fR
.
.IP "\(bu" 4
PicoSHA2 \fIhttps://github\.com/okdshin/PicoSHA2\fR
.
.IP "\(bu" 4
musl \fIhttps://www\.musl\-libc\.org/\fR
.
.IP "" 0
.
.P
Inclusion of mbed TLS is subject to presentation of the following license terms to recipients of this software: \fIhttp://www\.apache\.org/licenses/LICENSE\-2\.0\fR (a copy of which is included with the documentation of this software)
.
.SS "Inclusion of libcurl is subject to distribution of the software with the following notice:"
.
.nf
Copyright (c) 1996 \- 2019, Daniel Stenberg, daniel@haxx\.se, and many contributors,
see the THANKS file\. All rights reserved\. Permission to use, copy, modify, and distribute
this software for any purpose with or without fee is hereby granted, provided that
the above copyright notice and this permission notice appear in all copies\.
.
.fi
.
.SS "Inclusion of getopt\.h is subject to distribution of the software with the following notice:"
.
.nf
DISCLAIMER
This file is part of the mingw\-w64 runtime package\.
The mingw\-w64 runtime package and its code is distributed in the hope that it
will be useful but WITHOUT ANY WARRANTY\. ALL WARRANTIES, EXPRESSED OR
IMPLIED ARE HEREBY DISCLAIMED\. This includes but is not limited to
warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\.
Copyright (c) 2002 Todd C\. Miller <Todd\.Miller@courtesan\.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies\.
Copyright (c) 2000 The NetBSD Foundation, Inc\.
All rights reserved\.
This code is derived from software contributed to The NetBSD Foundation
by Dieter Baron and Thomas Klausner\.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1\. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer\.
2\. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution\.
.
.fi
.
.SS "Inclusion of PicoSHA2 is subject to distribution of the software with the following notice:"
.
.nf
Copyright (c) 2017 okdshin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software\.
.
.fi
.
.SS "Inclusion of musl is subject to distribution of the software with the following notice:"
.
.nf
Copyright © 2005\-2019 Rich Felker, et al\.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software\.
.
.fi

273
ookla_bin/speedtest.md Normal file
View File

@@ -0,0 +1,273 @@
# Speedtest
## Name
**speedtest** - Speedtest CLI by Ookla is the official command line client for testing the speed and performance of your internet connection.
## Version
1.0.0
## Synopsis
```
speedtest [-aAbBfhiIpPsv] [--ca-certificate=path] [--format=[=format-type]] [--help] [--interface=interface]
[--ip=ip_address] [--output-header] [--precision=num_decimal_places] [--progress=yes|no]
[--selection-details] [--server-id=id] [--servers] [--unit=[=unit-of-measure]] [--version]
```
## Description
**speedtest** is an application that measures the latency, jitter, packet loss, download bandwidth, and
upload bandwidth of the network connection between the client and a nearby Speedtest
Server.
## Options
* **-h, --help**
Print usage information
* **-v**
Logging verbosity, specify multiple times for higher verbosity (e.g. **-vvv**)
* **-V, --version**
Print version number
* **-L, --servers**
List nearest servers
* **--selection-details**
Show server selection details
* **-s** *id*, **--server-id**=*id*
Specify a server from the server list using its id
* **-o** *hostname*, **--host**=*hostname*
Specify a server from the server list using its hostname
* **-f** *format_type* **--format**=*format_type*
Output format (default = human-readable)
Note: Machine readable formats (csv, tsv, json, jsonl, json-pretty) use bytes
as the unit of measure with max precision.
*format_type* values are as follows:
* **human-readable** human readable output
* **csv** comma separated values
* **tsv** tab separated values
* **json** javascript object notation (compact)
* **jsonl** javascript object notation (lines)
* **json-pretty** javascript object notation (pretty)
* **--output-header**
Show output header for CSV and TSV formats
* **-u*** unit_of_measure***,&nbsp;--unit*** unit_of_measure*
Output unit for displaying speeds (Note: this is only applicable
for human-readable output format and the default unit is Mbps)
* **bps** bits per second (decimal prefix)
* **kbps** kilobits per second (decimal prefix)
* **Mbps** megabits per second (decimal prefix)
* **Gbps** gigabits per second (decimal prefix)
* **kibps** kilobits per second (binary prefix)
* **Mibps** megabits per second (binary prefix)
* **Gibps** gigabits per second (binary prefix)
* **B/s** bytes per second
* **kB/s** kilobytes per second
* **MB/s** megabytes per second
* **GiB/s** gigabytes per second
* **auto-binary-bytes** automatic in binary bytes
* **auto-decimal-bytes** automatic in decimal bytes
* **auto-binary-bytes** automatic in binary bits
* **auto-binary-bytes** automatic in decimal bits
* **-a**
Shortcut for [**-u auto-decimal-bits**]
* **-A**
Shortcut for [**-u auto-decimal-bytes**]
* **-b**
Shortcut for [**-u auto-binary-bits**]
* **-B**
Shortcut for [**-u auto-binary-bytes**]
* **-P** *decimal_places* **--precision**=*decimal_places*
Number of decimal_places to use (default = 2, valid = 0-8)
* **-p** *yes*|*no* **--progress**=*yes*|*no*
Enable or disable progress bar (default = yes when interactive)
* **-I** *interface* **--interface**=*interface*
Attempt to bind to the specified interface when connecting to servers
* **-i** *ip_address* **--ip**=*ip_address*
Attempt to bind to the specified IP address when connecting to servers
* **--ca-certificate**=*path*
Path to CA Certificate bundle, see note below.
## Terms of Use and Privacy Policy Notices
You may only use this Speedtest software and information generated from it for personal, non-commercial use,
through a command line interface on a personal computer. Your use of this software is subject to the End User
License Agreement, Terms of Use and Privacy Policy at these URLs:
* [https://www.speedtest.net/about/eula](https://www.speedtest.net/about/eula)
* [https://www.speedtest.net/about/terms](https://www.speedtest.net/about/terms)
* [https://www.speedtest.net/about/privacy](https://www.speedtest.net/about/privacy)
## Output
Upon successful execution, the application will exit with an exit code of 0. The result will include
latency, jitter, download, upload, packet loss (where available), and a result URL.
Latency and jitter will be represented in milliseconds. Download and upload units will depend on the output
format as well as if a unit was specified. The human-readable format defaults to Mbps and any machine-readable
formats (csv, tsv, json, jsonl, json-pretty) use bytes as the unit of measure with max precision. Packet loss is represented as a percentage, or **Not available** when packet loss is unavailable in the executing network environment.
The Result URL is available to share your result, appending **.png** to the Result URL will create a
shareable result image.
*Example human-readable result:*
```
$ speedtest
Speedtest by Ookla
Server: Speedtest.net - New York, NY (id = 10390)
ISP: Comcast Cable
Latency: 57.81 ms (3.65 ms jitter)
Download: 76.82 Mbps (data used: 80.9 MB)
Upload: 37.58 Mbps (data used: 65.3 MB)
Packet Loss: 0.0%
Result URL: https://www.speedtest.net/result/c/8ae1200c-e639-45e5-8b55-41421a079250
```
## Network Timeout Values
By default, network requests set a timeout of **10** seconds. The only exception to this
is latency testing, which sets a timeout of **15** seconds.
## Fatal Errors
Upon fatal errors, the application will exit with a non-zero exit code.
**Initialization Fatal Error Examples:**
*Configuration - Couldn't connect to server (Network is unreachable)*
*Configuration - Could not retrieve or read configuration (ConfigurationError)*
**Stage Execution Fatal Error Example:**
*[error] Error: [1] Latency test failed for HTTP*
*[error] Error: [36] Cannot open socket: Operation now in progress*
*[error] Failed to resolve host name. Cancelling test suite.*
*[error] Host resolve failed: Exec format error*
*[error] Cannot open socket: No route to host*
*[error] Server Selection - Failed to find a working test server. (NoServers)*
## SSL Certificate Locations
By default the following paths are checked for CA certificate bundles on linux machines:
/etc/ssl/certs/ca-certificates.crt
/etc/pki/tls/certs/ca-bundle.crt
/usr/share/ssl/certs/ca-bundle.crt
/usr/local/share/certs/ca-root-nss.crt
/etc/ssl/cert.pem
If the device under test does *not* have one of the above mentioned files, then the canonical and up to date CA certificate bundle provided by the curl project can be manually
downloaded into a specific location. This specific location can be provided as a parameter per the following example:
wget https://curl.haxx.se/ca/cacert.pem
./ookla --ca-certificate=./cacert.pem
## Release Notes
### 1.0.0 - 10/29/2019
* Initial release
## Copyright Notices for Third-Party Products/Libraries
This software incorporates free and open source third-party libraries, including:
* [boost](https://www.boost.org/)
* [libcurl](https://curl.haxx.se/libcurl/)
* [petopt](https://www.lysator.liu.se/~pen/petopt/)
* [mbed TLS](https://tls.mbed.org/)
* [ca-certificates extract](https://curl.haxx.se/docs/caextract.html)
* [L. Peter Deutschs md5](https://sourceforge.net/projects/libmd5-rfc/files/)
* [getopt.h](in Windows version of this software)
* [tiny-aes](https://github.com/kokke/tiny-AES-c)
* [PicoSHA2](https://github.com/okdshin/PicoSHA2)
* [musl](https://www.musl-libc.org/)
Inclusion of mbed TLS is subject to presentation of the following license terms
to recipients of this software: [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
(a copy of which is included with the documentation of this software)
### Inclusion of libcurl is subject to distribution of the software with the following notice:
Copyright (c) 1996 - 2019, Daniel Stenberg, daniel@haxx.se, and many contributors,
see the THANKS file. All rights reserved. Permission to use, copy, modify, and distribute
this software for any purpose with or without fee is hereby granted, provided that
the above copyright notice and this permission notice appear in all copies.
### Inclusion of getopt.h is subject to distribution of the software with the following notice:
DISCLAIMER
This file is part of the mingw-w64 runtime package.
The mingw-w64 runtime package and its code is distributed in the hope that it
will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
Copyright (c) 2000 The NetBSD Foundation, Inc.
All rights reserved.
This code is derived from software contributed to The NetBSD Foundation
by Dieter Baron and Thomas Klausner.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
### Inclusion of PicoSHA2 is subject to distribution of the software with the following notice:
Copyright (c) 2017 okdshin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
### Inclusion of musl is subject to distribution of the software with the following notice:
Copyright © 2005-2019 Rich Felker, et al.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

33
speedtest.py Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python3
import re
import subprocess
from influxdb import InfluxDBClient
import json
response = subprocess.Popen('/home/pi/speedtest/ookla_bin/speedtest -b --progress=no -f json-pretty', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
json_data = json.loads(response)
ping = round(json_data["ping"]["latency"], 2)
upload = round(json_data["upload"]["bytes"]/1024/1024, 2)
download = round(json_data["download"]["bytes"]/1024/1024, 2)
speed_data = [
{
"measurement" : "internet_speed",
"tags" : {
"host": "home"
},
"fields" : {
"download": download,
"upload": upload,
"ping": ping
}
}
]
client = InfluxDBClient("192.168.178.25", 8086, 'no', 'credentials', 'here')
client.write_points(speed_data)
print(f"Ping: {ping}; Download: {download}; Upload: {upload}")

11
speedtest_report.service Normal file
View File

@@ -0,0 +1,11 @@
[Unit]
Description=Reporting speedtest results to InfluxDB server
[Service]
Type=oneshot
ExecStart=/home/pi/speedtest/speedtest.py
User=pi
StandardOutput=journal
KillMode=process
TimeoutSec=45

9
speedtest_report.timer Normal file
View File

@@ -0,0 +1,9 @@
[Unit]
Description=Report speedtest results to InfluxDB server
[Timer]
OnCalendar=*:0/15:20
[Install]
WantedBy=timers.target