Probe: no access log, nothing written while reports get through. When the hub can't be reached, failed reports go to data/outage.jsonl and unsent results to data/backlog.jsonl (survives restarts). The first report that gets through uploads both and they are deleted. Hub: a probe that misses reports gets a "Not reporting" incident. When it reports again, the runs from its outage log become confirmed "Hub unreachable" incidents; the rest of the silence (probe off or restarting) is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| app | ||
| container | ||
| native | ||
| scripts | ||
| tests | ||
| .dockerignore | ||
| .env.example | ||
| .env.probe.example | ||
| .gitignore | ||
| CLAUDE.md | ||
| compose.dev.yml | ||
| compose.probe.yml | ||
| compose.yml | ||
| install-probe.sh | ||
| install.sh | ||
| pytest.ini | ||
| README.md | ||
| requirements-dev.txt | ||
| requirements.txt | ||
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.andcdn.
-
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=nativeif 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:
- Finds or creates a container, tagged
netmon-hubornetmon-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(orlocal-zfs, or the first storage that holds containers) nesting=1, start on boot- on
vmbr0with DHCP - named
netmon-hubornetmon-probe-<node>
- unprivileged Debian 12 or 13, from the newest template in
- Starts it and waits for network.
- Copies the installer in and runs it in native mode. It installs Python, sets up ping and creates the systemd service.
- Prints the container's IP and the
pct execcommands to update it, read its logs and edit its settings.pct execruns commands with a minimal PATH that doesn't include/usr/local/bin, so the update command needs its full path:pct exec <ctid> -- /usr/local/bin/network-monitor-update. Inside the container (pct enter <ctid>), plainnetwork-monitor-updateworks.
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:
.localnames: the installer runs Avahi in the container, so it answers at<hostname>.local. The hub's container isnetmon-hub, sohttp://netmon-hub.local. The hub has the container to itself and listens on port 80, so no port is needed; passHOST_PORTto choose another. Native installs inside an LXC you made yourself work the same way.- 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. Opened at
netmon-hub.local, the hub puts its IP in the command anyway, because Linux probes usually can't resolve.localnames. - 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.
- Quorum: a node in a cluster without quorum can't create containers, because
/etc/pveis read-only. The installer checks first and stops with an explanation. On a lone node left from a dead cluster,pvecm expected 1restores quorum until the next reboot. Separating the node from the cluster fixes it for good, and without quorum guests also won't start at boot.
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 DROPand guests have trouble talking to each other or the internet, runiptables -P FORWARD ACCEPT, or reboot the node when convenient.
Mac mini
- 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 installspython@3.13with Homebrew. - It installs a LaunchDaemon (
/Library/LaunchDaemons/dev.neilbantoc.network-probe.plist) that runs from boot, with no login needed.- It runs as root. On macOS 15, Local Network privacy blocks a background service running as your user from reaching LAN addresses: you'd see
No route to hostwhilecurlworks. A service running as root is exempt, and a background service can't show the permission prompt. - Your user still owns the checkout, the Python environment and updates.
- It runs as root. On macOS 15, Local Network privacy blocks a background service running as your user from reaching LAN addresses: you'd see
- Logs go to
/opt/network-probe/data/service.log. - 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 (no sudo as root; macOS: network-monitor-update)
pct exec <ctid> -- /usr/local/bin/network-monitor-update # hub in a Proxmox LXC, from the node
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
/healthzto report the new commit
If any step fails, they put the previous commit back. Other forms:
--checkshows what an update would bring in.--rollbackreturns 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.pypicks the app byROLE.- Docker:
compose.ymlruns the hub andcompose.probe.ymlruns a probe (host networking), both from the same image. - Native:
native/setup.shcreates.venvand a systemd unit or launchd daemon that runsnative/run.sh.
- Docker:
-
Probe loop (
app/probe/server.py). Each cycle, the probe:- 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 - runs the throughput download, one peer at a time
- posts the results and its ARP neighbors to
/api/probe/report. On Linux the gateway and neighbors come from/proc/net; on macOS fromrouteandarp.
The hub's reply is the probe's configuration: its peers and targets. The probe caches that reply in
/data. While reports get through, the probe writes nothing else to disk. While the hub can't be reached, it keeps a local outage log in its data folder: each failed report, and the results it couldn't send (up to 20,000 measurements, hours of data), so a restart doesn't lose them. Once the hub answers, the probe uploads the results and the log, then deletes both.When a probe goes quiet, the hub lists it as "Not reporting". When it reports again, the hub checks its outage log. The parts of the silence the log covers become "Hub unreachable" incidents. The rest is dropped, because the probe was off or restarting rather than cut off.
- runs its checks in parallel: ICMP through unprivileged sockets (
-
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/querylogwithsearchandolder_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_datavolume. - Native: in
/opt/network-monitor/data/.
- Docker: in the
- Probes keep only their last config, in
network-probe_data(Docker) or/opt/network-probe/data/(native).