Giter Site home page Giter Site logo

momu / speedtest-plotter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ansemjo/speedtest-plotter

0.0 1.0 0.0 264 KB

running scheduled speedtests inside docker and plotting the results with gnuplot

License: MIT License

Shell 7.93% Dockerfile 9.55% Python 82.52%

speedtest-plotter's Introduction

speedtest-plotter

This is a collection of scripts, which takes internet speedtest measurements with speedtest-cli and plot them with gnuplot. A crontab schedule can be used to automate measurements every couple of minutes and save them to a database. The results can optionally be displayed through a simple Flask webserver.

example plot of speedtest results

USAGE

CONTAINER

Docker Cloud Automated build Docker Cloud Build Status

The main distribution method is the automatically built container at ansemjo/speedtest. Obviously, you need to have a container runtime like docker or podman installed to run the container.

To start the container with default settings run:

docker run -d -p 8000:8000 ansemjo/speedtest

This will take a measurement every 15 minutes, save them to a SQLite database in /data/speedtests.db and run the webserver on port 8000. Visit http://localhost:8000 to look at the plotted results. (Note: The smoothed bezier curves require at least two measurements and the image will stay blank otherwise. So you might have to wait a while first.)

For data persistence, either mount a volume at /data to save the database file or set the environment variable DATABASE to an SQLAlchemy-compatible URI. A PostgreSQL URI might look like this:

docker run -d \
  -p 8000:8000 \
  -e DATABASE=postgresql://user:password@hostname:5432/database' \
  ansemjo/speedtest

You can modify the measurement schedule with the environment variables MINUTES and SCHEDULE. The former takes a measurement every n minutes and the latter may define an entirely custom cron schedule like "four times a day":

docker run -d -p 8000:8000 -e SCHEDULE="0 3,9,15,21 * * *" ansemjo/speedtest

The webserver is a single-threaded Flask application, which may not be suitable for production usage. To disable the webserver completely set the PORT environment variable to an empty string. This will only take measurements and save them to the database.

docker run -d -e PORT= -v speedtests:/data ansemjo/speedtest

To dump the results as CSV from a running container use the dump command:

docker exec $containerid speedtest-plotter dump > results.csv

To reimport a previous dump in a fresh container use import:

docker exec $containerid speedtest-plotter import < results.csv

This can also be used to import results obtained manually with speedtest-cli.

PYTHON SCRIPT

You can use the Python script by itself locally, too. First install the requirements:

pip install -r requirements.txt

Choose a database location and take any number of measurements:

./speedtest-plotter -d sqlite:///$PWD/measurements.db measure
...

Then start the flask webserver to look at the results:

./speedtest-plotter -d sqlite:///$PWD/measurements.db serve

GNUPLOT SCRIPT

To keep things really simple, you can also take measurements manually with speedtest-cli and only plot an image with gnuplot.

The plotscript expects the format that speedtest-cli outputs when using the --csv flag and a header line from --csv-header. To take some measurements manually with a simple sleep-loop:

speedtest-cli --csv-header > results.csv
while true; do speedtest-cli --csv | tee -a results.csv; sleep 600; done
^C

Afterwards plot the results to a PNG picture with:

gnuplot -c plotscript results.csv plot.png

LICENSE

Copyright (c) 2019 Anton Semjonov Licensed under the MIT License

speedtest-plotter's People

Contributors

ansemjo avatar

Watchers

 avatar

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.