Skip to content

neverabsolute/netwatch

Repository files navigation

Netwatch - Network Uptime Dashboard

A tiny FastAPI app that periodically measures your internet connection and shows it on a simple dashboard.

It runs three background checks and stores results in SQLite:

  • Speedtest: download/upload and latency via fast.com (headless Chromium)
  • Ping: ICMP latency and packet loss to configurable targets
  • DNS: Resolution status and query time against configurable resolvers

Open the dashboard at http://localhost:8000.

Features

  • Lightweight UI with charts (Chart.js)
  • Configurable schedules and targets via config.yaml
  • HTTP API for raw data (/api/speedtests, /api/pings, /api/dns, /api/config)
  • Zero external services; data stored locally in SQLite

Prerequisites

  • Python 3.11+
  • System tools: ping (iputils) and dig (dnsutils)
  • For speedtest: Playwright + Chromium

On Linux/macOS, if running locally, you'll likely need to install Playwright's browser and system deps once:

# Install Chromium browser for Playwright (installs needed libs too)
python -m playwright install --with-deps chromium

Quick start (local)

# 1) Create and activate a virtualenv
python -m venv .venv
source .venv/bin/activate

# 2) Install dependencies
pip install -r requirements.txt

# 3) Install Playwright + Chromium (one-time)
python -m playwright install --with-deps chromium

# 4) Run the app
python app.py
# Then open http://localhost:8000

Optional environment variables:

  • NETDASH_DB - path to the SQLite file (default: ./netdash.sqlite3)
  • NETDASH_CONFIG - path to config YAML (default: ./config.yaml)
  • PORT - server port (default: 8000)

Configuration

Update config.yaml to control what runs and how often:

speedtest:
  enabled: true
  interval_seconds: 1800

ping:
  enabled: true
  interval_seconds: 60
  targets: ["1.1.1.1", "1.0.0.1", "8.8.8.8", "8.8.4.4"]
  count: 5
  interval: 0.2

dns:
  enabled: true
  interval_seconds: 120
  resolvers: ["1.1.1.1", "1.0.0.1", "8.8.8.8", "8.8.4.4"]
  domains: ["example.com"]
  timeout: 5

retention_days: 30

Changes are picked up on restart.

Run with Docker

# Build
docker build -t netwatch .

# Run (persists DB under ./data)
mkdir -p data
docker run --rm -p 8000:8000 -v "$(pwd)/data:/data" --name netwatch netwatch
# Then open http://localhost:8000

The image already contains ping, dig, and a headless Chromium via Playwright.

API endpoints

  • GET /api/speedtests?limit=2000&since=<unix_ts>
  • GET /api/pings?limit=4000&since=<unix_ts>
  • GET /api/dns?limit=4000&since=<unix_ts>
  • GET /api/config

All responses are JSON; timestamps are UNIX seconds.

Troubleshooting

  • If speedtests fail locally, ensure Chromium is installed for Playwright:
    • python -m playwright install --with-deps chromium
  • If ping or dig fail, make sure the system tools are installed (e.g., iputils-ping, dnsutils).
  • In restricted environments, headless browsers may need extra libraries; the Docker image includes these by default.

About

Simple self-hostable network uptime dashboard

Resources

Stars

Watchers

Forks