No description
Find a file
neil a17f2b502c Proxmox nodes: install in an LXC container instead of Docker on the node
Run on a Proxmox VE node (pct and /etc/pve present), the installers now
default to INSTALL_MODE=lxc: create or reuse (by tag netmon-hub /
netmon-probe) an unprivileged Debian LXC on vmbr0 with nesting and onboot,
push the installer into it (rebuilt from its own functions) and run it there
in native mode. LXC_* variables override ID, storage, template storage,
bridge, IP and size. Docker on a node now needs an explicit
INSTALL_MODE=docker and prints a warning; an earlier Docker install is
pointed out with removal steps.

Ping setup inside an unprivileged container stays within the mapped group
range, which the kernel requires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 18:28:21 -08:00
app Proxmox nodes: install in an LXC container instead of Docker on the node 2026-11-04 18:28:21 -08:00
container Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
native Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
scripts Proxmox nodes: install in an LXC container instead of Docker on the node 2026-11-04 18:28:21 -08:00
tests Proxmox nodes: install in an LXC container instead of Docker on the node 2026-11-04 18:28:21 -08:00
.dockerignore Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
.env.example Serve installers from the hub; document the private-repo install 2026-11-04 18:13:19 -08:00
.env.probe.example Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
.gitignore Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
CLAUDE.md Proxmox nodes: install in an LXC container instead of Docker on the node 2026-11-04 18:28:21 -08:00
compose.dev.yml Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
compose.probe.yml Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
compose.yml Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
install-probe.sh Proxmox nodes: install in an LXC container instead of Docker on the node 2026-11-04 18:28:21 -08:00
install.sh Proxmox nodes: install in an LXC container instead of Docker on the node 2026-11-04 18:28:21 -08:00
pytest.ini Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
README.md Proxmox nodes: install in an LXC container instead of Docker on the node 2026-11-04 18:28:21 -08:00
requirements-dev.txt Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00
requirements.txt Network monitor: hub, probes, Docker and native installers 2026-11-04 18:10:29 -08:00

Network Monitor

Watch a home network from one page: how healthy the mesh and the internet link are, which devices are on the network, and what they look up in DNS.

It has two parts, built from this one repo and one Docker image:

  • The hub (install.sh). The web UI and API. It stores probe results in SQLite and reads DNS data from AdGuard Home.
  • Probes (install-probe.sh). Small containers on machines around the house. Each one serves a test endpoint, tests every other probe (ping, HTTP and a timed download), the gateway, the LAN DNS server, public DNS servers and the internet, then reports to the hub. A probe can also run on a VPS in serve-only mode, so the others measure the ISP link against it.
           ┌──────────── report every 30 s (token) ────────────┐
           │                                                   ▼
 probe A ◄─┼── ping / HTTP / download ──► probe B ──────────► hub ──► AdGuard Home /control API
  │        │                                │                 │
  └── gateway, LAN DNS, 1.1.1.1, 8.8.8.8, VPS ┘                 └── web UI :8000

What you get

  • Network health (home page)

    • A matrix of every probe against every target over the last 5 minutes.
    • Status strips over 1 h to 30 d showing OK, degraded, down or no data.
    • A list of incidents. Failed or slow checks are merged into one outage per probe and target.
  • Probes. Add a probe, which gives you its install command. Remove a probe, or set the address its peers use. Each probe has a page with latency and throughput charts per target.

  • Clients. Every device seen on the network, merged from several sources:

    • AdGuard Home's client list
    • DHCP leases
    • the query log
    • the probes' ARP tables

    A device is keyed by MAC address when one is known. You can name a device, give it a category (Computer, Mobile, IoT, Server…), mark it suspicious, and keep notes. Each client has a page with its top domains and its DNS requests.

  • Query log. Search AdGuard's log, filter to blocked or allowed, or filter by client.

  • Domains. For any domain:

    • how many requests, how many were blocked, and which clients asked
    • requests per hour over 24 h
    • other names under the same registrable domain, such as api. and cdn.
  • Blocked domains. What AdGuard blocked, how often, by which rule, and for whom.

Install

Both installers are one pasted line. They work on Linux and macOS. Settings can be passed as environment variables; the top of install.sh lists them. Where it installs depends on the machine (INSTALL_MODE):

Mode What it is Default on
lxc Creates a small Debian LXC container (or reuses the one it made before) and installs natively inside it. The node itself gets no Docker and no packages. Proxmox VE nodes
native A Python virtualenv plus a boot service: systemd on Linux, launchd on macOS macOS, and inside LXC containers
docker The app in a container (compose), Docker installed if missing other Linux hosts (VMs, bare metal)

Pass INSTALL_MODE=... to choose another mode. Outside Proxmox, the mode is saved in .env, so re-runs keep it. Native mode needs Python 3.11+ (Debian 12, Ubuntu 24.04 or newer; the installer installs it with apt or Homebrew). On Linux it runs as root and creates a netmon system user for the service.

Either way, the service starts on boot and restarts if it crashes.

Which machine gets what

  • Proxmox VE nodes: run the installer on the node as root. It creates an LXC container for the hub or probe and installs inside it. Don't use Docker on the node itself: Docker changes the host firewall, and with the Proxmox firewall on that can cut traffic to guests.
  • Mac mini: native mode. Docker Desktop runs containers in a Linux VM, so a probe there would measure the VM, and it only starts at login. The installer refuses Docker on macOS.
  • Other Linux machines or VMs: Docker mode (the default), or INSTALL_MODE=native if you prefer no Docker.

1. The hub

curl -fsSL https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install.sh | bash

Inside an LXC you are root, so that's it. On another Linux machine in native mode, use | sudo env INSTALL_MODE=native bash.

Then connect AdGuard Home in /opt/network-monitor/.env:

ADGUARD_URL=http://192.168.1.2:3000    # AdGuard Home's web UI address
ADGUARD_USERNAME=admin
ADGUARD_PASSWORD=...

and restart the hub: docker restart network-monitor (Docker) or systemctl restart network-monitor (native).

Open http://<hub-ip>:8000. The hub listens on the LAN (HOST_BIND=0.0.0.0) because probes report to it. Set UI_PASSWORD in .env to put a password on the UI.

2. Probes

On the hub, open Probes → Add probe and give the probe a name. The hub shows a command with that probe's token. The hub serves the installer itself, so fetching it needs no Gitea access. Open the hub at its LAN address, not localhost, so the command has a HUB_URL the probe can reach. Run it on the probe machine:

# Linux host (Docker), an LXC as root (native, detected automatically), or macOS as your user
curl -fsSL http://192.168.1.10:8000/install-probe.sh | HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash

# Linux, native, not root
curl -fsSL http://192.168.1.10:8000/install-probe.sh | sudo env HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash

The same installer is also at https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh.

The probe's test server listens on port 8765 (PROBE_PORT) on all interfaces.

Ping on Linux. Linux needs unprivileged ping allowed (net.ipv4.ping_group_range). The installer sets it and persists it in /etc/sysctl.d/60-network-probe-ping.conf. That needs root. Without it, the probe skips ping and keeps its HTTP, DNS and throughput checks.

Docker probes use host networking, so they measure the machine's real link and see its ARP table.

Proxmox: what the installer does on a node

Run the same commands as above on the node, as root. The installer:

  1. Finds or creates a container, tagged netmon-hub or netmon-probe. Re-running finds it again, so it never makes a second one. A new container is:
    • unprivileged Debian 12 or 13, from the newest template in local, downloaded if missing
    • 1 core, 512 MB, 4 GB on local-lvm (or local-zfs, or the first storage that holds containers)
    • nesting=1, start on boot
    • on vmbr0 with DHCP
    • named netmon-hub or netmon-probe-<node>
  2. Starts it and waits for network.
  3. Copies the installer in and runs it in native mode. It installs Python, sets up ping and creates the systemd service.
  4. Prints the container's IP and the pct exec commands to update it, read its logs and edit its settings.

To change the defaults, set these before bash:

Variable Default
LXC_ID the next free ID
LXC_STORAGE local-lvm, else local-zfs, else the first container storage
LXC_TEMPLATE_STORAGE local
LXC_BRIDGE vmbr0
LXC_IP dhcp; a static address looks like 192.168.68.50/24 together with LXC_GW=192.168.68.1
LXC_CORES, LXC_MEMORY, LXC_DISK 1, 512, 4 (GB)

For example: curl -fsSL .../install.sh | LXC_IP=192.168.68.50/24 LXC_GW=192.168.68.1 bash.

Notes:

  • Fixed IP for the hub: give its container a DHCP reservation or a static IP. Probes report to it, and the Add probe command contains its address.
  • What the probe measures: the container sits on the node's bridge, so its traffic leaves through the node's NIC, and the probe measures that node's link.
  • Neighbors: a probe in a container sees only the devices it has talked to, not everything the node sees. AdGuard is the main source of the client list, so this rarely matters.
  • Ping: inside an unprivileged container, the ping setting is limited to the container's mapped groups (0–65535). The installer handles that.

Removing a Docker install from a Proxmox node

An earlier version of the installer used Docker when run directly on a node. To undo that, as root on the node:

cd /opt/network-monitor && docker compose down -v --rmi all; cd / && rm -rf /opt/network-monitor   # same for network-probe
apt-get purge -y $(dpkg-query -W -f='${binary:Package}\n' 'docker-*' containerd.io 2>/dev/null)
rm -rf /var/lib/docker /var/lib/containerd /etc/apt/sources.list.d/docker.* /etc/apt/keyrings/docker.*

Docker also changes the firewall: its rules and a DROP policy on the FORWARD chain stay until the next reboot.

  • Check: iptables -S FORWARD | head -1.
  • Fix: if it says -P FORWARD DROP and guests have trouble talking to each other or the internet, run iptables -P FORWARD ACCEPT, or reboot the node when convenient.

Mac mini

  1. Run the probe command above as your user. It needs the Xcode Command Line Tools (xcode-select --install) and Python 3.11+. If Python is missing, it installs python@3.13 with Homebrew.
  2. It installs a LaunchDaemon (/Library/LaunchDaemons/dev.neilbantoc.network-probe.plist) that runs as your user from boot, with no login needed.
  3. Logs go to /opt/network-probe/data/service.log.
  4. Keep the Mac awake. In System Settings → Energy, turn on "Prevent automatic sleeping", or the probe stops while the Mac sleeps.

Optional: a VPS as an internet reference

On the VPS, run install-probe.sh with no HUB_URL or PROBE_TOKEN, and open 8765/tcp in its firewall. Then set VPS_URL=http://<vps>:8765 in the hub's .env. Every probe then tests the VPS too.

If the repo becomes private

The installers ask for a read-only token on the terminal when they can't read the repo, and save it in that machine's .env for updates (GIT_TOKEN). Probe install commands keep working, because they fetch the installer from the hub. To fetch the hub installer, pass the token to curl (Gitea's header):

read -rsp 'Gitea token: ' GIT_TOKEN && export GIT_TOKEN && curl -fsSL -H "Authorization: token $GIT_TOKEN" https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install.sh | bash

Deploy changes

git push                                   # from your machine
docker exec network-monitor update         # hub, Docker
sudo network-monitor-update                # hub, native Linux   (macOS: network-monitor-update)
docker exec network-probe update           # probe, Docker
sudo network-probe-update                  # probe, native Linux (macOS: network-probe-update)

Both forms work the same way, with no rebuild:

  • fetch the commit and check it out
  • install requirements if they changed
  • check that the app imports
  • restart the app and wait for /healthz to report the new commit

If any step fails, they put the previous commit back. Other forms:

  • --check shows what an update would bring in.
  • --rollback returns to the commit before the last update.
  • <ref> deploys a specific tag, branch or commit.

Re-run the installer when container/ (Docker) or native/setup.sh (native) changes. It keeps .env.

Uninstall

The installer prints the uninstall command at the end. In short:

Install Command
Docker cd /opt/<name> && docker compose -f <compose.yml or compose.probe.yml> down -v, then rm -rf /opt/<name>
Native Linux systemctl disable --now <name> && rm -rf /opt/<name> /etc/systemd/system/<name>.service /usr/local/bin/<name>-update
macOS sudo launchctl bootout system/dev.neilbantoc.<name>; sudo rm -rf /opt/<name> /Library/LaunchDaemons/dev.neilbantoc.<name>.plist /usr/local/bin/<name>-update

<name> is network-monitor (hub) or network-probe.

Settings

The hub's settings live in /opt/network-monitor/.env; .env.example lists them all. The Settings page shows the current values and the exact restart command for this install. Settings are re-read on every restart and update.

Variable Default Meaning
ADGUARD_URL, ADGUARD_USERNAME, ADGUARD_PASSWORD empty AdGuard Home web address and admin login (HTTP basic auth on /control/*).
UI_PASSWORD empty Password for the web UI. Any username works.
HOST_BIND, HOST_PORT 0.0.0.0, 8000 Where the hub listens.
PROBE_INTERVAL 30 Seconds between probe reports.
LAN_DNS_SERVERS the AdGuard host DNS servers tested as LAN.
DNS_SERVERS 1.1.1.1,8.8.8.8,9.9.9.9 DNS servers tested as internet.
WAN_HTTP_URLS gstatic generate_204 Internet HTTP checks.
VPS_URL empty A serve-only probe on a VPS.
THROUGHPUT_EVERY, THROUGHPUT_BYTES 10, 4000000 Timed download from each peer every N reports. 0 turns it off.
SLOW_LAN_MS, SLOW_WAN_MS, SLOW_DNS_MS 100, 200, 250 When a check counts as slow.
RETENTION_DAYS 14 How long measurements are kept.
HUB_PUBLIC_URL browser address The hub URL shown in probe install commands.

Probe settings live in /opt/network-probe/.env; .env.probe.example lists them:

Variable Meaning
HUB_URL The hub to report to.
PROBE_TOKEN This probe's token, from the Add probe dialog.
PROBE_PORT Port of the probe's test server. Default 8765.
ADVERTISE_ADDR The address peers should use for this probe. By default the hub uses the address it sees.

How it works

  • One codebase, two roles, two modes. app/main.py picks the app by ROLE.

    • Docker: compose.yml runs the hub and compose.probe.yml runs a probe (host networking), both from the same image.
    • Native: native/setup.sh creates .venv and a systemd unit or launchd daemon that runs native/run.sh.
  • Probe loop (app/probe/server.py). Each cycle, the probe:

    1. runs its checks in parallel: ICMP through unprivileged sockets (icmplib), HTTP, a hand-built DNS A query over UDP, and the default gateway from /proc/net/route
    2. runs the throughput download, one peer at a time
    3. posts the results and its ARP neighbors to /api/probe/report. On Linux the gateway and neighbors come from /proc/net; on macOS from route and arp.

    The hub's reply is the probe's configuration: its peers and targets. The probe caches that reply in /data. While the hub is unreachable, results queue in memory, up to 20,000 measurements (hours of data), and upload once the hub is back. Outages are therefore recorded from the probe's side even when the hub can't hear it.

  • Health maths (app/hub/health.py). Each check is OK, slow or failed. Slow means over the threshold, or 30% or more ping loss. A time slice is:

    • down when at least half its checks failed
    • degraded when at least a fifth were slow or failed

    Failed or slow checks for the same probe and target are merged into one incident when they are less than 2.5 report intervals apart. A single slow sample on its own is ignored.

  • Clients (app/hub/devices.py).

    • Every source reports sightings. When an IP becomes linked to a MAC, the IP-only entry is merged into the MAC entry, and your labels carry over.
    • An IP moving to a new MAC is released from the old device.
    • ARP entries on Docker, VM and VPN interfaces are ignored.
  • AdGuard (app/hub/adguard.py). Detail pages read pages of /control/querylog with search and older_than, and filter exactly on the hub. The status bar says how much of the log a page is based on. Top lists come from /control/stats.

Develop

The host needs only Docker and git.

docker compose -f compose.yml -f compose.dev.yml up --build        # hub at http://127.0.0.1:8000, reloads on save
docker compose -f compose.yml -f compose.dev.yml run --rm app pytest

The frontend is plain HTML, CSS and ES modules in app/static/, with no build step. It uses the house UI kit (css/house.css, js/ui.js, js/shell.js), project styles in css/app.css, and one module per page in js/views/. The charts are inline SVG (js/charts.js).

app/main.py                 picks the hub or the probe by ROLE
app/hub/                    server, probes, health, dns (AdGuard views), devices, adguard client, db
app/probe/                  server (test endpoints + report loop), checks
app/static/                 the web UI
tests/                      pytest (fake AdGuard through httpx.MockTransport)
install.sh                  the installer (hub); the only one to edit
install-probe.sh            generated from install.sh by scripts/build-installers.sh
container/                  Docker mode: Dockerfile, entrypoint (setup + supervisor), update script
native/                     native mode: setup.sh (venv + service), run.sh, update.sh, lib.sh

Data

  • The hub's data is hub.sqlite3. Back it up to keep client names and history.
    • Docker: in the network-monitor_data volume.
    • Native: in /opt/network-monitor/data/.
  • Probes keep only their last config, in network-probe_data (Docker) or /opt/network-probe/data/ (native).