No description
  • Python 54.1%
  • HTML 43.5%
  • Dockerfile 2.4%
Find a file
Brian ed2133755e
All checks were successful
Build and Deploy / build (push) Successful in 9s
Build and Deploy / deploy (push) Successful in 2s
Mirror latest-results and 24h-average cards per source
Add a Cloudflare row to both the Latest results and 24-hour average sections,
matching the per-source layout used by the history graphs. /api/status now also
returns the latest Cloudflare reading; 24h averages are computed per source.
Both Cloudflare rows auto-hide when there is no Cloudflare data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 16:32:24 -06:00
.forgejo/workflows Map dashboard to host port 8765 (8000 was in use on the host) 2026-06-01 00:56:21 -06:00
internet_monitor Mirror latest-results and 24h-average cards per source 2026-06-07 16:32:24 -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 Align build-deploy with Forgejo registry + Portainer API 2026-06-01 00:45:58 -06:00
README.md Add connectivity monitoring app, Docker, and Forgejo/Portainer deploy 2026-06-01 00:32:59 -06:00
requirements.txt Add Cloudflare as a secondary speed test source 2026-06-07 14:55:55 -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 speedtest-cli — 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

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