![]() ![]() Time before retrying a failed Speedtest (in seconds). Time before retrying a failed data upload. Use OS or Docker environmet variables to configure the program run.Įxample: docker run -d -env DB_ADDRESS= influx_db -env TEST_INTERVAL=120 -name speedtest-influx aidengilmartin/speedtest-influx InfluxDB Settings Variable Import the grafana_dashboard_template.json template as a new dashboard. InfluxDB Details - Password: db_password.InfluxDB Details - Database: speedtest_db.Login to the Grafana Dashboard (admin/admin) and create a datasource. In the docker_env/ folder you can edit the environment variables of the docker container (see below, grafana and influx). ĭocker run -d -name speedtest-influx aidengilmartin/speedtest-influx Install the InfluxDB client for library from Python.ĭocker build -t aidengilmartin/speedtest-influx. It will need to be uninstalled before installing the Ookla Speedtest CLI application with the directions on their website. NOTE: The speedtest-cli package in distro repositories is an unofficial client. Install the Speedtest CLI application by Ookla. Make sure you agree with them before running. Using Grafana you can view and explore this data easily.Īdjust the InfluxDB connection settings at the top of main.py to fit your setup and then run with one of the options listed below.īe aware that this script will automatically accept the license and GDPR statement so that it can run non-interactively. ![]() It is basically a command-line interface for checking the. You may want to do this so that you can track your internet connections consistency over time. Python provides a library called speedtest which is useful for testing the internet speed. Thank you for reading my blog.This is a small Python script that will continuously run the Speedtest CLI application by Ookla, reformat the data output and forward it on to an InfluxDB database. st.get_best_server()Īfter this, we can get the ping to this server by using the following: print ( f "Your ping is: Mbit/s" )Īnd when we run this, it outputs: Your ping is: 30.97 ms Your download speed: 64.4 Mbit/s Your upload speed: 29.2 Mbit/s Thank you for reading, and let's connect! Starting with the ping, for this to work, we need to define a server to ping. I'll be showing you how to get this data and format it nicely. This repository contains the SQL schema and the Grafana dashboard JSON so you can track your own metrics. This script was written to track internet speed using Ooklas speed test. Now that we know the basics of the speed test, we want to receive three elements: A Python script to capture speedtest JSON and insert it into a database. ![]() When we run this, we get a long number like this: 55775374.79559286 Making a full Python speed test script Now let's try our download speed and print it out: print (st.download()) Note: be aware running the speed test takes a while, so be patient □ In my case, I'm assigning it to the st variable. Now open your python file and start by importing the speed test module. Use the following command to install it: pip install speedtest-cli Installing the speedtest-cli in Python īefore we can use this package, we have to install it to become available for us to use. I choose Python as the language, seeing I'm trying that out a bit. We have Speedtest websites like this to test our ping, upload, and download speed for those who don't know.įor today's article, I was looking to automate this since I check it regularly. Today we'll be building our speed testing service in Python. How to perform a speedtest in a Python script 21 Jun, 2021 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |