Run ISP speed tests and save results

Related tags

Testing Speedmon
Overview

SpeedMon

GitHub commit activity Master Travis (.com) semver CodeFactor Grade

Screenshot

Automatically run periodic internet speed tests and save results to a variety of storage backends.

Supported Backends

  • InfluxDB v1
  • InfluxDB v2
  • Graphite

Speed tests are run using the official speedtest.net CLI tool.

Docker, Windows, and Linux are supported. Linux users are required to install the speedtest package first. It will automatically download on Windows.

Configuration

Speedmon can be configured from a configuration file or environment variables. The preferred method is via ENV.

Configuring From ENV

You only need to include the variables for the storage backends you wish to use.

General

DELAY
SERVERS (1234,5431,ect)

Influx v1

--Required--
INFLUXV1_URL
INFLUXV1_DATABASE_NAME
--Optional--
INFLUXV1_NAME
INFLUXV1_PORT
INFLUXV1_USER
INFLUXV1_PASSWORD
INFLUXV1_VERIFY_SSL
INFLUXV1_SSL

Influx v2

--Required--
INFLUXV2_URL
INFLUXV2_TOKEN
INFLUXV2_ORG
INFLUXV2_BUCKET
--Optional--
INFLUXV2_NAME
INFLUXV2_VERIFY_SSL

Graphite v2

--Required--
GRAPHITE_URL
GRAPHITE_PREFIX
--Optional--
GRAPHITE_NAME
GRAPHITE_PORT

Configuring From .ini

When initializing Speedmon looks for the SPEEDTEST_CONFIG ENV Variable to know what config file to load. If this variable is not provided, Speedmon will attempt to load settings from ENV.

Storage backends are dynamically loaded based on what is in the config file. You can safely delete the sections for backends not in use.

[GENERAL]
Delay = 360
Servers = 
[INFLUXV1]
Name = Whatever You want
Url = http://localhost
Port = 8086
Database_name = speedtests
User = 
Password =
SSL = False
Verify SSL = False
[INFLUXV2]
Name = Whatever You want
Url = http://localhost
Token =
Org = 
Bucket = 
Verify SSL = False
[Graphite]
Name = Whatever You want
Url = http://localhost
Port = 2003
Prefix = speedtest

Usage

With Docker

See ENV Variable List For Your Storage Backend

docker run -d \
--name="speedtest" \
--restart="always" \
--env INFLUXV2_URL=http://example.com \
--env INFLUXV2_TOKEN=my-long-token \
--env INFLUXV2_ORG=my-org \
--env INFLUXV2_BUCKET=speedtests \
--env DELAY=360 \
barrycarey/speedmon:latest

Using Optional Configuration File

If you do not want to configure Speedmon with ENV variables you can us configuration file

  1. Make a directory to hold the config.ini file. Navigate to that directory and download the sample config.ini in this repo.
mkdir speedmon
curl -o speedmon/config.ini https://raw.githubusercontent.com/barrycarey/Speedmon/master/config.ini
cd speedmon
  1. Modify the config file with your influxdb settings.
nano config.ini

Remove the unneeded storage backend sections. Modify the remaining settings to fit our requirements

[GENERAL]
Delay = 360
# Leave blank to auto pick server
Servers =


[INFLUXV2]
Name = Influx v2
URL = = http://localhost:8086
Token = abc12345676
Org = my-org
Bucket = speedtests
Verify_SSL = False


  1. Run the container, pointing to the directory with the config file. This should now pull the image from Docker hub.
docker run -d \
--name="speedtest" \
-v config.ini:/src/config.ini \
--restart="always" \
--env SPEEDTEST_CONFIG=config.ini
barrycarey/speedmon:latest

Before the first use run pip3 install -r requirements.txt

Enter your desired information in config.ini

Run influxspeedtest.py

Adding Additional Backends

If you wish to contribute support for additional backends the process is straight forward.

Add a new Package under speedmon.storage. Create a new Storage Handler that inherits from StorageHandlerBase. Create a new config that inherits from StorageConfig. Add the new storage backed to speedmon.storage.storage_config_map

Add the example config options to config.ini and name the section [HANDLERNAME]. This must match the name you specified in the map

The handler will automatically be loaded and initialized if the config options are available in the config.ini or ENV vars

Comments
  • Default Download/Upload Units

    Default Download/Upload Units

    I have been using Speedtest/InfluxDB1 for a while and recently migrated to Speedmon/InfluxDB2. What are the default upload/download units used for Speedmon? I can't seem to figure out how to covert it to Mbps for Grafana.

    I'm getting _values returned around 25,137,682 when my connection speed is 200Mbps so it doesn't seem like the units are bits.

    opened by ksnell88 2
  • gdpr warning

    gdpr warning

    can you call speedtest with the --accept-gdpr parameter to prevent logging (when using docker)?

    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/terms
    https://www.speedtest.net/about/privacy
    
    ==============================================================================
    
    License acceptance recorded. Continuing.
    
    ==============================================================================
    
    Ookla collects certain data through Speedtest that may be considered
    personally identifiable, such as your IP address, unique device
    identifiers or location. Ookla believes it has a legitimate interest
    to share this data with internet providers, hardware manufacturers and
    industry regulators to help them understand and create a better and
    faster internet. For further information including how the data may be
    shared, where the data may be transferred and Ookla's contact details,
    please see our Privacy Policy at:
    
    http://www.speedtest.net/privacy
    
    ==============================================================================
    
    To accept the message please run speedtest interactively or use the following:
    
    speedtest --accept-gdpr
    
    opened by techie2000 2
  • InfluxDBv1 Write error -

    InfluxDBv1 Write error - "partial write: field type conflict"

    Hey, thanks for the previous package and this shiny new one.

    I'm trying to replace my current setup with this and just going thru seeing how well it works with my setup before I delete stuff. I've noticed a few bugs so I've submitted PRs for them (#1, #2, #3)

    I'm getting this error:

    ➜ SPEEDTEST_CONFIG=config.ini python3 speedmon.py
    2021-10-04 20:05:37,884 - config_manager:__init__:19 - INFO: Loading config from config.ini
    2021-10-04 20:05:37,884 - config_manager:__init__:27 - INFO: Configuration Successfully Loaded
    2021-10-04 20:05:37,888 - storage_handler_base:__init__:18 - INFO: Built storage handler influx
    2021-10-04 20:05:37,889 - storage_builder:init_storage_handler_from_ini:65 - INFO: No config section defined for INFLUXV2 in INI
    2021-10-04 20:05:37,889 - storage_builder:init_storage_handler_from_ini:65 - INFO: No config section defined for GRAPHITE in INI
    2021-10-04 20:05:37,889 - influxv1_storage_handler:validate_connection:37 - DEBUG: Testing connection to InfluxDb using provided credentials
    2021-10-04 20:05:37,898 - influxv1_storage_handler:validate_connection:39 - DEBUG: Successful connection to InfluxDb
    2021-10-04 20:05:37,899 - utils:run_speed_test:65 - DEBUG: Running with args: speedtest -f json
    27368096 1949397 2.421 36.593 None
    2021-10-04 20:06:03,296 - influxv1_storage_handler:save_results:71 - ERROR: Failed To Write To InfluxDB
    Traceback (most recent call last):
      File "/home/jack/Personal/speedmon/speedmon/storage/influxv1/influxv1_storage_handler.py", line 61, in save_results
        self.client.write_points(self.format_results(data))
      File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 608, in write_points
        consistency=consistency)
      File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 685, in _write_points
        protocol=protocol
      File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 419, in write
        headers=headers
      File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 378, in request
        raise InfluxDBClientError(err_msg, response.status_code)
    influxdb.exceptions.InfluxDBClientError: 400: {"error":"partial write: field type conflict: input field \"download\" on measurement \"speed_test_results\" is type integer, already exists as type float dropped=1"}
    

    I fixed the error by changing format_influxdb_results like so:

        return [
            {
                'measurement': 'speed_test_results',
                'fields': {
    -               'download': data.download,
    +               'download': float(data.download),
    -               'upload': data.upload,
    +               'upload': float(data.upload),
    -               'ping': data.latency,
    +               'ping': float(data.latency),
    -               'jitter': data.jitter,
    +               'jitter': float(data.jitter),
    -               'packetloss': data.packetloss,
    +               'packetloss': 0 if data.packetloss == None else data.packetloss,
                },
                'tags': {
    

    But I am not a python programmer so I am not sure why that fixes it to be honest...

    config file:

    [GENERAL]
    Delay = 1
    # Leave blank to auto pick server
    Servers =
    
    [INFLUXV1]
    Name = influx
    URL = 192.168.1.7
    Port = 8086
    Database_name = speedtests2
    Username =
    Password =
    SSL = False
    Verify_SSL = False
    

    Using InfluxDB v1.8.0 & python 3.6.9. Clean database freshly created with create database speedtest2.

    Let me know if you need more info.

    opened by jack828 2
  • Fix readme & example config.ini using incorrect name for database name option

    Fix readme & example config.ini using incorrect name for database name option

    For me this was causing whatever was put in Database = config option to be ignored and data got dumped into the default speedtests.

    I think this is the only place it is shown.

    opened by jack828 2
  • [Influxdb v2] Failed to connect to InfluxDB v2: Invalid value for `name`, must not be `None` using default configuration

    [Influxdb v2] Failed to connect to InfluxDB v2: Invalid value for `name`, must not be `None` using default configuration

    I've tried to spin up this container with no success using the bare bone default configuration for influxdb v2. URL, TOKEN, ORG and BUCKET replaced with my infludb 2.0 values.

    docker run -d \
    --name="speedtest" \
    --restart="always" \
    --env INFLUXV2_URL=http://example.com \
    --env INFLUXV2_TOKEN=my-long-token \
    --env INFLUXV2_ORG=my-org \
    --env INFLUXV2_BUCKET=speedtests \
    --env DELAY=5 \
    barrycarey/speedmon:latest
    
    2022-01-31 21:28:14,368 - storage_builder:init_storage_handler_from_ini:65 - INFO: No config section defined for INFLUXV1 in INI
    2022-01-31 21:28:14,370 - storage_handler_base:__init__:18 - INFO: Built storage handler Influx V2
    2022-01-31 21:28:14,370 - storage_builder:init_storage_handler_from_ini:65 - INFO: No config section defined for GRAPHITE in INI
    2022-01-31 21:28:14,377 - influxv2_storage_handler:validate_connection:31 - ERROR: Failed to connect to InfluxDB v2: Invalid value for `name`, must not be `None`
    2022-01-31 21:28:14,377 - speedmon:<module>:40 - ERROR: No active storage handlers available
    
    opened by maxiride 4
  • Allow InfluxV1 connection test to be skipped

    Allow InfluxV1 connection test to be skipped

    This adds a new option, INFLUXV1_SKIP_TEST to skip the connection test.

    I need to disable the test, because my influx-user only has the WRITE permission, so get_list_users() (which requires admin) always fails. I did not find a suitable replacement (ping() works even without credentials, get_list_series() requires READ), so I added a way to simply skip the check.

    Thanks for your work, it really is super useful!

    opened by tribut 0
Owner
Matthew Carey
IT Technician by day, wannabe developer at night.
Matthew Carey
A pytest plugin to run an ansible collection's unit tests with pytest.

pytest-ansible-units An experimental pytest plugin to run an ansible collection's unit tests with pytest. Description pytest-ansible-units is a pytest

Community managed Ansible repositories 9 Dec 9, 2022
To automate the generation and validation tests of COSE/CBOR Codes and it's base45/2D Code representations

To automate the generation and validation tests of COSE/CBOR Codes and it's base45/2D Code representations, a lot of data has to be collected to ensure the variance of the tests. This respository was established to collect a lot of different test data and related test cases of different member states in a standardized manner. Each member state can generate a folder in this section.

null 160 Jul 25, 2022
pytest splinter and selenium integration for anyone interested in browser interaction in tests

Splinter plugin for the pytest runner Install pytest-splinter pip install pytest-splinter Features The plugin provides a set of fixtures to use splin

pytest-dev 238 Nov 14, 2022
a plugin for py.test that changes the default look and feel of py.test (e.g. progressbar, show tests that fail instantly)

pytest-sugar pytest-sugar is a plugin for pytest that shows failures and errors instantly and shows a progress bar. Requirements You will need the fol

Teemu 963 Dec 28, 2022
:game_die: Pytest plugin to randomly order tests and control random.seed

pytest-randomly Pytest plugin to randomly order tests and control random.seed. Features All of these features are on by default but can be disabled wi

pytest-dev 471 Dec 30, 2022
Given some test cases, this program automatically queries the oracle and tests your Cshanty compiler!

The Diviner A complement to The Oracle for compilers class. Given some test cases, this program automatically queries the oracle and tests your compil

Grant Holmes 2 Jan 29, 2022
a wrapper around pytest for executing tests to look for test flakiness and runtime regression

bubblewrap a wrapper around pytest for assessing flakiness and runtime regressions a cs implementations practice project How to Run: First, install de

Anna Nagy 1 Aug 5, 2021
A library to make concurrent selenium tests that automatically download and setup webdrivers

AutoParaSelenium A library to make parallel selenium tests that automatically download and setup webdrivers Usage Installation pip install autoparasel

Ronak Badhe 8 Mar 13, 2022
Let your Python tests travel through time

FreezeGun: Let your Python tests travel through time FreezeGun is a library that allows your Python tests to travel through time by mocking the dateti

Steve Pulec 3.5k Dec 29, 2022
User-oriented Web UI browser tests in Python

Selene - User-oriented Web UI browser tests in Python (Selenide port) Main features: User-oriented API for Selenium Webdriver (code like speak common

Iakiv Kramarenko 575 Jan 2, 2023
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. An example o

pytest-dev 9.6k Jan 2, 2023
Data-Driven Tests for Python Unittest

DDT (Data-Driven Tests) allows you to multiply one test case by running it with different test data, and make it appear as multiple test cases. Instal

null 424 Nov 28, 2022
Selects tests affected by changed files. Continous test runner when used with pytest-watch.

This is a pytest plug-in which automatically selects and re-executes only tests affected by recent changes. How is this possible in dynamic language l

Tibor Arpas 614 Dec 30, 2022
Docker-based integration tests

Docker-based integration tests Description Simple pytest fixtures that help you write integration tests with Docker and docker-compose. Specify all ne

Avast 326 Dec 27, 2022
Show surprise when tests are passing

pytest-pikachu pytest-pikachu prints ascii art of Surprised Pikachu when all tests pass. Installation $ pip install pytest-pikachu Usage Pass the --p

Charlie Hornsby 13 Apr 15, 2022
Django-google-optimize is a Django application designed to make running server side Google Optimize A/B tests easy.

Django-google-optimize Django-google-optimize is a Django application designed to make running Google Optimize A/B tests easy. Here is a tutorial on t

Adin Hodovic 39 Oct 25, 2022
LuluTest is a Python framework for creating automated browser tests.

LuluTest LuluTest is an open source browser automation framework using Python and Selenium. It is relatively lightweight in that it mostly provides wr

Erik Whiting 14 Sep 26, 2022
Statistical tests for the sequential locality of graphs

Statistical tests for the sequential locality of graphs You can assess the statistical significance of the sequential locality of an adjacency matrix

null 2 Nov 23, 2021
Automated tests for OKAY websites in Python (Selenium) - user friendly version

Okay Selenium Testy Aplikace určená k testování produkčních webů společnosti OKAY s.r.o. Závislosti K běhu aplikace je potřeba mít v počítači nainstal

Viktor Bem 0 Oct 1, 2022