Network monitor: hub, probes, Docker and native installers

Hub (FastAPI + no-build web UI):
- Network health: live probe/target matrix, status strips, incidents
- Probes: add (with install command), rename, remove, latency and throughput charts
- Clients merged from AdGuard, DHCP, query log and probe ARP tables; names,
  categories, suspicious flag, notes, per-client DNS requests
- Query log, domain detail (clients, related subdomains), blocked domains via
  the AdGuard Home /control API

Probe: tests peers (ping, HTTP, throughput), gateway, LAN and public DNS,
internet URLs and an optional VPS; buffers results while the hub is down.
Gateway and ARP from /proc/net on Linux, route/arp on macOS.

Install: install.sh (hub) and install-probe.sh (generated from it), each in
docker mode (compose; default on Linux hosts) or native mode (venv + systemd
or launchd; default on macOS and in LXC). Both modes deploy with an update
command that checks the new commit and rolls back on failure.

CLAUDE.md carries shared context for Claude Code sessions on each machine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 18:10:29 -08:00
commit 54a765510a
63 changed files with 6464 additions and 0 deletions

View file

@ -0,0 +1,42 @@
// Settings: what the hub is configured to do. Values live in the hub's .env.
import { el } from '../ui.js';
import { get } from '../api.js';
import { num } from '../fmt.js';
export async function mount(root) {
const intro = el('p.muted', {}, 'These come from the hub’s .env file.');
const page = el('div.page', {}, el('h1', {}, 'Settings'), intro);
root.append(page);
try {
const [i, dns] = await Promise.all([get('/api/info'), get('/api/dns/status')]);
intro.textContent = `These come from ${i.env_file} on the hub (${i.install_mode} install). Edit that file, then restart the hub to apply: ${i.install_mode === 'docker' ? 'docker restart network-monitor' : 'sudo systemctl restart network-monitor (macOS: sudo launchctl kickstart -k system/dev.neilbantoc.network-monitor)'}. Deploy new code with ${i.update_command}.`;
const row = (k, v, env) => [el('dt', {}, k), el('dd', {}, v, env ? el('span.muted.small.mono', {}, ` ${env}`) : null)];
const list = (xs) => (xs.length ? xs.join(', ') : 'none');
page.append(
el('h2', {}, 'AdGuard Home'),
el('dl.kv', {},
...row('Status', dns.ok ? el('span.chip.ok', {}, `Connected · ${dns.version}`) : el('span.chip.danger', {}, dns.configured ? 'Not reachable' : 'Not set up')),
...(dns.url ? row('Address', dns.url, 'ADGUARD_URL') : []),
...(dns.ok ? [] : row('Problem', dns.message))),
el('h2', {}, 'Probes'),
el('dl.kv', {},
...row('Report every', `${i.probe_interval} s`, 'PROBE_INTERVAL'),
...row('LAN DNS servers', list(i.lan_dns_servers), 'LAN_DNS_SERVERS'),
...row('Public DNS servers', list(i.dns_servers), 'DNS_SERVERS'),
...row('DNS test name', i.dns_query_name, 'DNS_QUERY_NAME'),
...row('Internet HTTP checks', list(i.wan_http_urls), 'WAN_HTTP_URLS'),
...row('VPS', i.vps_url || 'none', 'VPS_URL'),
...row('Throughput test', i.throughput_every ? `${num(i.throughput_bytes / 1e6)} MB from each peer every ${i.throughput_every} reports` : 'off', 'THROUGHPUT_EVERY, THROUGHPUT_BYTES')),
el('h2', {}, 'Thresholds and storage'),
el('dl.kv', {},
...row('Slow on the LAN', `over ${i.thresholds.lan_ms} ms`, 'SLOW_LAN_MS'),
...row('Slow to the internet', `over ${i.thresholds.wan_ms} ms`, 'SLOW_WAN_MS'),
...row('Slow DNS', `over ${i.thresholds.dns_ms} ms`, 'SLOW_DNS_MS'),
...row('Keep measurements', `${i.retention_days} days`, 'RETENTION_DAYS'),
...row('Password', i.password ? 'On' : 'Off: anyone on the network can open this page', 'UI_PASSWORD'),
...row('Version', i.version)),
);
} catch (err) {
page.append(el('div.callout.error', {}, err.message));
}
}