• This repository has been archived on 07/Sep/2023
  • Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🛎️ Monitor the speed your ISP is delivering

Tests Coverage Maintainability

My Internet Speed

I wrote this app so I can periodically monitor my internet speed and:

  • Collect data to build a report about the quality of the service provided by my ISP
  • Automatically tweet my ISP when the speed is lower than expected – surely optional
  • Store speed test results in PostgreSQL
  • Check all speed test results in a web API
  • Monitor all speed test tasks

At home this runs on my Raspberry Pi, but not all services are compatible — check my ideal setup for a suggestion on how to run these services.

Installing

Requirements

It is important to run this app in a computer connected to the internet via ethernet cable, not via wireless – this is the way to have some accuracy in testing the speed.

Optionally, if you want the Twitter feature to work (it will only tweet when the speed is below the configures threshold):

  • Twitter consumer key and secret
  • Twitter access token and access token secret

You can get these Twitter credentials at the Twitter Application Management dashboard.

Some speed test backends do not provide a URL with the results. In these cases we take a screenshot from the speed test result and upload it to Imgur. If you want to use this feature, you need an account there and a client ID for a registered application.

Settings

Before you get started, copy .env.sample as .env and edit as follows:

  1. Set INTERVAL according to how often (in minutes) you want to run the speed test (e.g.: 20 for 20min)
  2. Set your TIMEZONE accordingly

The default speed test backend is SpeedTest but you can use EAQ (Entidade Aferidora da Qualidade de Banda Larga) certified by ANATEL setting BACKEND to brasil_banda_larga.

If you want the app to post tweets:

  1. Add your Twitter credentials at the top of the file
  2. Set CONTRACT_SPEED to the speed in Mbps you are paying for (e.g.: 60 if you contract says 60Mbps)
  3. Set THRESHOLD to the minimum percentage of the contract speed you contract or local laws enforces your ISP (e.g.: 0.4 for 40%)
  4. Set your tweet message using {contract_speed} where the contract speed in Mbps should be (for example, 60 for 60Mbps), {real_speed} where the measured speed should be, and {percentage} where comparing both should be (feel free to use the Twitter handle of your ISP too)
  5. Add {result_url} in order to add the link to the result provided by the speed test backend

For example, if:

  • the measured speed is 20Mpbs
  • your CONTRACT_SPEED is 60
  • the THRESHOLD is 0.4
  • and TWEET is configures as I pay for {contract_speed}, but now @MyISP is working at {real_speed} – merely {percentage} of what I'm paying for :( {result_url}

The final tweet would be:

I pay for 60Mbps, but now @MyISP is working at 20Mbps – merely 33% of what I'm paing for :( http://www.speedtest.net/result/7307126311

If you like this app, add #MyInternetSpeed https://github.com/cuducos/my-internet-speed to your tweets ; )

Database

This docker-compose.yml lefts out the db container from all possible depends_on in order to make it easier to use an external/remote database to persist data (just point POSTGRESs variables and the PGRST ones to somewhere else).

Thus if you are using the Docker database it is useful to start it manually first:

$ docker-compose up -d db

In both cases run this one off command to create the database tables:

$ docker-compose run --rm beat python \
  -c "from my_internet_speed.models import Result; Result.create_table()"

Spinning up the app

$ docker-compose up -d

Services and compatibility

Containers

This spins up different services that might be useful to check the status of the speed tests:

Name URL ARM (RaspberryPi) compatibility Description
beat Main app that periodically runs the speed tests
dashboard http://localhost:3000/ 🚫 Minimalist dashboard with monthly speed test results
api http://localhost:3001/result/ 🚫 API to the database with all speed test results (check Postgrest for advanced filtering and exporting formats)
flower http://localhost:5555/ Flower dashboard for asynchronous tasks
db Database to store the speed test results
broker Queue to run the speed tests
chrome 🚫 Selenium web driver used for backends that requires a browser
Backends
Name Python path ARM (RaspberryPi) compatibility
SpeedTest my_internet_speed.backends.speed_test_net.SpeedTest
Barsil Banda Larga my_internet_speed.backends.brasil_banda_larga.SpeedTest 🚫

My ideal setup

Given the ARM processor incompatibilities, I actually use three computers to run these services:

  1. In my RaspberryPi (ARM processor, but it is still the only device with ethernet cable I have) I run beat, broker and flower:
    $ docker-compose up -d beat flower
  2. In my main computer (x86 processor) I run the api and the dashboard so I can check the results:
    $ docker-compose up -d beat dashboard
  3. The database I run in the cloud, a free tier at tiny turtle (free) at ElephantSQL

Troubleshooting

UnixHTTPConnectionPool(host='localhost', port=None): Read timed out.

I was getting this error in my Raspberry Pi when trying to run docker-compose up. This seams to be a workaround:

$ export DOCKER_CLIENT_TIMEOUT=600
$ export COMPOSE_HTTP_TIMEOUT=600

Testing

$ docker-compose run --rm beat py.test

Also we use Black code formatter:

$ docker-compose run --rm beat black . --check

More Repositories

1

minha-receita

🏢 Sua API web para consulta de informações do CNPJ da Receita Federal
Go
1,204
star
2

twitter-cleanup

🛁 Clean-up inactive accounts and bots from your Twitter
Python
288
star
3

yaml.nvim

🍒 YAML toolkit for Neovim users
Lua
169
star
4

calculadora-do-cidadao

💵 Tool for Brazilian Reais monetary adjustment/correction
Python
149
star
5

alchemydumps

SQLAlchemy backup/dump tool for Flask
Python
116
star
6

bot-followers

🍊 Find out how many bots follow any given Twitter acount
Python
115
star
7

getgist

🖥️ Easily download any file from a GitHub Gist, with one single command.
Python
103
star
8

docs-cpi-pandemia

😷 Dowload dos documentos da CPI da Pandemia
Go
99
star
9

whiskyton

Whiskyton, find whiskies that you like!
Python
84
star
10

fio-de-ariadne

🪁 Structuiring data on missing kids in Brazil
Python
77
star
11

elm-format-number

✨Format numbers as pretty strings
Elm
60
star
12

chunk

🧱 Chunk is a download manager for slow and unstable servers
Go
53
star
13

pwned-antifas

HTML
50
star
14

brazilian-cities

A script to generate list with all Brazilian cities and states
Python
48
star
15

createnv

🧞‍♀️Automagically creates .env files
Python
40
star
16

django-public-admin

🔓 A public and read-only version of the Django Admin
Python
37
star
17

webassets-elm

📦Filter for compiling Elm files using webassets
Python
36
star
18

cunhajacaiu

Brazilian website counting the days to the fall of Cunha
Elm
27
star
19

django-ajax-contacts

Web app to discuss responsabilities of backend and frontend code
Python
26
star
20

raspadorlegislativo

Testes de código para integrar, futuramente, o Radar Legislativo
Python
19
star
21

go-cpf

CPF validation in Go
Go
17
star
22

go-cnpf

🇧🇷 CPF and CNPJ validation in Go
Go
16
star
23

fuckoff-twitter

Fuck off @twitter, let me have "latest tweets" as a default.
Rust
14
star
24

PhD

My PhD writings
CSS
14
star
25

cara-de-nordestino

Você tem cara de nordestino?
Elm
14
star
26

grupy-python-tdd-flask

Palestra para encontro do Grupy-SP em 12 de março de 2016.
Python
14
star
27

dotfiles

🥰 My dot files
Lua
13
star
28

em-nome-da-lai

🧑‍⚖️ Em nome da LAI! Gerador de petições com base na LAI.
Elm
13
star
29

hangouts-django-ajax

Source for a Hangouts On Air about Django & AJAX
Python
11
star
30

UOLEsportesSexista

Chrome Extension that redacts sexist contents from UOL sports coverage.
CoffeeScript
11
star
31

ezz

🎦 ezz is a simple CLI tool to schedule Zoom meetings
Rust
10
star
32

scrapy-memcached-cache

🗂Memcached HTTP cache storage backend for Scrapy
Python
10
star
33

hangouts-mock

Source code for a live coding session about Python's unittest.mock
Python
9
star
34

findaconf

Mock-up for Find a Conference
Python
7
star
35

vamos-aprender-elm-api

API created for educational purposes while teaching Elm
Python
7
star
36

wed

🌤 Track the weather for event days
Rust
7
star
37

lista-de-compras

🛒 Bot de lista de compras compartilhada para o Telegram
Python
6
star
38

its-wednesday

Captain, it's Wednesday!
Go
5
star
39

vamos-aprender-elm

Source codes from a series of live coding in Elm
Elm
5
star
40

pagamentos-alesc

Python
5
star
41

from-my-ex

💕 Sending all the love from my ex to my new happy and promisucous social media life
Python
4
star
42

spellfile.nvim

🌕 Port of spellfile.vim to Lua without depending on netrw
Lua
4
star
43

go-cnpj

CNPJ validation in Go
Go
4
star
44

boteco

CLI to create redirections in CloudFlare to Zoom meetings.
Rust
4
star
45

grrs

This is me studying Rust having Command Line Applications in Rust book as a starting point.
Rust
4
star
46

triathlon-live-calendar

📅 Calendar file generator for triathlonlive.tv upcoming events
Python
4
star
47

grupy-porque-elm

Código fonte para a palestra que ofereci no encontro do Grupy-SP, em 17 de setembro de 2016.
Elm
3
star
48

sortimages

Python
3
star
49

twitter-filtered-stream-client

🏞️ Twitter Filtered Stream API Client
Go
3
star
50

hangouts-django-react

Source for a Hangouts On Air about Django & ReactJS
Python
3
star
51

filterss

FilteRSS - More power over your feeds
HTML
3
star
52

palestra-relampago-git-bisect

Mini-calculadora escrita como exemplo para uma palestra relâmpago sobre `git bisect`
Python
3
star
53

ironbot

🚵 CLI to get information about Ironman professional races
Python
2
star
54

repo-birthday

🎂 Know when your repos are celebrating their birthdays!
Rust
2
star
55

MeDontLikeFB

Make your Facebook better, stop liking things.
JavaScript
2
star
56

astronomer

⭐️ Astronomer looks at the stars. At all the stars you’ve got on GitHub.
Rust
1
star
57

not-my-ex

🐝 Tiny CLI to post simultaneously to Mastodon and Bluesky
Python
1
star
58

minha-receita-mirror

Simple UI for R2 objects
1
star
59

ftp-based-zones

⚡ Cycling FTP-based training zones
Elm
1
star
60

cuducos.me

Source files of my personal webpage
HTML
1
star
61

manifestacoes-no-twitter

Python
1
star
62

airnope

☔ AirNope keeps Telegram groups clean from ”airdrop” spam
Rust
1
star