Sign inSign up

techniktueftler/speedtest

By techniktueftler

•Updated over 4 years ago

Perform a Internet speed test with adjustable time intervals with help from Fritzbox

Image
0

414

techniktueftler/speedtest repository overview

You can find the documentation here: https://github.com/Technik-Tueftler/Speedtest⁠

⁠Speedtest

Docker image build Pylint

Speedtest is an app that performs an Internet speed test at adjustable time intervals. The averaged value of the online service is not taken as the result, but the peak value from the Fritzbox is read in the local network. In this way, you get an approximately real value when, for example, streaming is running in the local network and the network is additionally loaded.

English readme⁠ • deutsche readme⁠

⁠Function overview

graph TB
    subgraph Main
        A([Start App]) --> |Timer = 1s| B[check local network load]
        B --> C{below limits?}
        C -->|no <br> Timer = TEST_REPEAT_TIME| B[[check local network load]]
        C -->|yes| D[[Fritzbox monitoring]] & E[[Online Speedtest]]
        D --> F{both finished?}
        E --> F
        F --> |yes <br> Timer = TEST_REPETITION_TIME| B
        F --> |no <br> runtime error| G([End App])
    end
graph TB
    subgraph check local network load
        H([Start subprocess]) --> |Timer = S_TIME_CHECK_LOW_NETWORK_LOAD| I[measure current network load]
        I --> |MBIT_THR_FROM_NETWORK_UPLOAD_TO_RUN > real upload <br> MBIT_THR_FROM_NETWORK_DOWNLOAD_TO_RUN > real download| J{Below limits?}
        J --> |yes -> low network load| K[/return network load/]
        J --> |no -> high network load| K
        K --> L([End subprocess])
    end

⁠Installation / Execution

  1. locally runs the program by executing the main file. To do this, simply copy the repository and run main.py. Currently, first environment variables must be loaded into the IDE or environment. The program was tested and developed under Python 3.10. However, it should be backward compatible up to at least 3.8.
  2. via a Docker container. See documentation: https://hub.docker.com/r/techniktueftler/speedtest⁠

⁠Environment variables

VariableExplanationUnitDefault value
IP_FRITZBOXIP address or hostname of the Fritzbox in the local network-fritz.box
S_TIME_CHECK_LOW_NETWORK_LOADRuntime of measurement to check network loadseconds10
MBIT_THR_FROM_NETWORK_DOWNLOAD_TO_RUNLimit value for the download when checking the network load. If this is exceeded, no speed test is performed.Mbit/s10
MBIT_THR_FROM_NETWORK_UPLOAD_TO_RUNLimit for the upload when checking the network load. If this is exceeded, no speed test is performed.Mbit/s2
TEST_REPETITION_TIMERepeat time of the speed test.seconds21600
TEST_REPEAT_TIMERepeat time for the test if the network load test failed. Example, if the network load has exceeded the limitsseconds3600
DB_CONNECTORConnection string for configuring the database connection. See chapter Database Connections.-sqlite:///./Speedtest/files/measurements.sqlite3

⁠Database connection

Currently the following databases are supported, which can be initialized via a connection string.

DatabaseExample
MariaDBmariadb+mariadbconnector://user_name:[email protected]:3306/database_name
SQLitesqlite:///path_to_file/database_name.sqlite3
PostgreSQLpostgresql+psycopg2://user_name:[email protected]/database_name

If no connection string is specified, the program automatically creates an SQLite file and saves it:

  • If started locally via main.py: Speedtest/files/
  • If started as Docker container without specifying the volume: /user/app/Speedtest/files/
  • If started as Docker container with volume specified: /spec_path/

⁠Database structure

nametypenullstandardexplanationunit
idint(11)NoAUTO_INCREMENTUnique ID of the entry-
timestamptimestampNoON UPDATE CURRENT_TIMESTAMP()Time of finished and entered measurement-
max_download_fritzboxint(11)YesNULLMaximum value for download from FritzboxBits/s
max_upload_fritzboxint(11)YesNULLMaximum value for upload from FritzboxBits/s
avg_download_speedtestint(11)YesNULLReturned value for download from www.speedtest.net⁠Bits/s
avg_upload_speedtestint(11)YesNULLReturned value for upload of www.speedtest.net⁠bits/s
ping_speedtestint(11)YesNULLReturned value for the response time of www.speedtest.net⁠. This value varies widely and is usually very high. The assumption is that the program runtime is also included here and does not reflect the true response time.ms

⁠Docker Compose Example

version: "2"
services:
  internet_speedtest:
    image: techniktueftler/speedtest:latest
    container_name: speedtest
    environment:
      - MBIT_THR_FROM_NETWORK_DOWNLOAD_TO_RUN=30
      - MBIT_THR_FROM_NETWORK_UPLOAD_TO_RUN=10
      - TZ=Europe/Berlin
      - DB_CONNECTOR=mariadb+mariadbconnector://User:[email protected]:3306/speedtest
    volumes:
      - /srv/dev-disk-by-uuid-0815/data/speedtest:/user/app/Speedtest/files/
    restart: unless-stopped

Tag summary

Content type

Image

Digest

Size

337 MB

Last updated

over 4 years ago

docker pull techniktueftler/speedtest