No description
This repository has been archived on 2026-10-02. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Python 57.6%
  • HTML 39.1%
  • Dockerfile 3.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Brian e8165c500a Stop deploying on push; production now runs the C port
homeinternettest-c deploys to the same Portainer stack and volume, so a
push here would silently replace it with the Python version. Keep the
workflow as a manual (workflow_dispatch) rollback only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 21:38:43 -06:00
.forgejo/workflows Stop deploying on push; production now runs the C port 2026-10-01 21:38:43 -06:00
internet_monitor Keep Cloudflare downloads under 10 MB and back off on 429 2026-10-01 21:08:10 -06:00
static Mirror latest-results and 24h-average cards per source 2026-06-07 16:32:24 -06:00
.dockerignore Add connectivity monitoring app, Docker, and Forgejo/Portainer deploy 2026-06-01 00:32:59 -06:00
.gitignore Align build-deploy with Forgejo registry + Portainer API 2026-06-01 00:45:58 -06:00
config.yaml Add connectivity monitoring app, Docker, and Forgejo/Portainer deploy 2026-06-01 00:32:59 -06:00
DEPLOYMENT.md Map dashboard to host port 8765 (8000 was in use on the host) 2026-06-01 00:56:21 -06:00
docker-compose.yml Wire deploy job to Portainer stack 18; fix compose image typo 2026-06-01 00:50:17 -06:00
Dockerfile Use Ookla CLI and multi-stream Cloudflare test for accurate gigabit speeds 2026-09-29 11:45:04 -06:00
README.md Use Ookla CLI and multi-stream Cloudflare test for accurate gigabit speeds 2026-09-29 11:45:04 -06:00
requirements.txt Use Ookla CLI and multi-stream Cloudflare test for accurate gigabit speeds 2026-09-29 11:45:04 -06:00

Internet Monitor

A Python backend that continuously monitors your home internet connection, runs periodic speed tests, detects outages, and serves a live web dashboard.

What it does

  • Speed tests on a configurable schedule (default every 5 minutes) using Ookla's official Speedtest CLI, plus an optional multi-stream test against speed.cloudflare.com — records download, upload, and ping.
  • Connectivity probing — every 10 seconds (configurable) lightweight TCP probes hit public DNS resolvers to decide whether you're online. Probes are tried in order and the first success means "online", so a single dead address is harmless; an outage is only declared once at least two addresses fail (failure_threshold). Successful checks are not logged — only failures are.
  • Outage detection — when the connection drops it logs the outage (including which hosts were unreachable) and keeps polling every 10 seconds until the connection returns, then records the recovery time and total duration.
  • Web dashboard — current status, latest download/upload/ping, an interactive history graph (1h / 6h / 24h / 7d / all), and a table of past outages.
  • SQLite storage — all results persist in monitor.db; an outage that was ongoing when the process stopped is recovered on restart.

Setup

python -m venv .venv
source .venv/bin/activate            # fish: source .venv/bin/activate.fish
pip install -r requirements.txt

Outside Docker, the Speedtest.net test also needs Ookla's speedtest binary on your PATH (see https://www.speedtest.net/apps/cli). Note the unrelated pip package speedtest-cli installs a command with the same name — uninstall it. The Docker image installs the Ookla binary for you.

Run

python -m internet_monitor

Then open the dashboard at http://127.0.0.1:8000.

Options:

python -m internet_monitor --config config.yaml --host 0.0.0.0 --port 8080

Use --host 0.0.0.0 (or set it in config.yaml) to reach the dashboard from other devices on your network.

Docker

docker compose up -d --build

The dashboard is then on http://localhost:8000. The SQLite database persists on the monitor-data volume, so speed-test history and the outage log survive restarts and image updates. See docker-compose.yml and the Dockerfile.

For the full CI/CD path — build in Forgejo Actions, push to the Forgejo container registry, and have Portainer pull the updated image — see DEPLOYMENT.md and .forgejo/workflows/build-deploy.yml.

Configuration

Edit config.yaml:

Key Default Meaning
speed_test_interval 300 Seconds between full speed tests
check_interval 10 Seconds between connectivity probes while online
outage_check_interval 10 Seconds between probes while offline
connectivity_timeout 3 Per-probe socket timeout (seconds)
connectivity_hosts DNS servers host:port targets, tried in order
failure_threshold 2 How many hosts must fail before declaring an outage
run_speed_test_on_start true Run one speed test immediately at launch
database_path data/monitor.db SQLite database file
host / port 127.0.0.1:8000 Dashboard bind address

API

Endpoint Description
GET /api/status Current online/outage state + latest test
GET /api/history?hours= Speed-test history (hours=0 for all)
GET /api/outages?limit= Recorded outages, most recent first

Layout

internet_monitor/
  config.py            # YAML config loader
  database.py          # SQLite persistence
  speedtest_runner.py  # single speed-test execution
  monitor.py           # background engine (scheduling + outage logic)
  app.py               # FastAPI app + JSON API
  __main__.py          # CLI entry point
static/index.html      # dashboard (Chart.js)
config.yaml            # configuration