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:
commit
54a765510a
63 changed files with 6464 additions and 0 deletions
32
app/static/js/fmt.js
Normal file
32
app/static/js/fmt.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Formatting for times, durations and measurements.
|
||||
export const dash = '—';
|
||||
|
||||
export function ago(ts) {
|
||||
if (!ts) return dash;
|
||||
const s = Date.now() / 1000 - ts;
|
||||
if (s < 45) return 'just now';
|
||||
if (s < 3600) return `${Math.round(s / 60)} min ago`;
|
||||
if (s < 86400) return `${Math.round(s / 3600)} h ago`;
|
||||
return `${Math.round(s / 86400)} d ago`;
|
||||
}
|
||||
|
||||
export const clock = (ts) => new Date(ts * 1000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
||||
export const hm = (ts) => new Date(ts * 1000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
export const when = (ts) => (ts ? new Date(ts * 1000).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) : dash);
|
||||
export const day = (ts) => new Date(ts * 1000).toLocaleDateString([], { month: 'short', day: 'numeric' });
|
||||
|
||||
export function dur(s) {
|
||||
if (s == null) return dash;
|
||||
if (s < 60) return `${Math.round(s)} s`;
|
||||
if (s < 3600) return `${Math.round(s / 60)} min`;
|
||||
if (s < 86400) return `${(s / 3600).toFixed(1)} h`;
|
||||
return `${(s / 86400).toFixed(1)} d`;
|
||||
}
|
||||
|
||||
export const ms = (v) => (v == null ? dash : v < 10 ? `${v.toFixed(1)} ms` : `${Math.round(v).toLocaleString()} ms`);
|
||||
export const pct = (v, digits = 0) => (v == null ? dash : `${(v * 100).toFixed(digits)}%`);
|
||||
export const num = (n) => (n == null ? dash : Number(n).toLocaleString());
|
||||
export const mbps = (v) => (v == null ? dash : `${v < 10 ? v.toFixed(1) : Math.round(v)} Mbps`);
|
||||
|
||||
/** A time label fitting the span: clock for short ranges, date + hour for long ones. */
|
||||
export const axisTime = (span) => (ts) => (span > 2 * 86400 ? `${day(ts)} ${hm(ts)}` : hm(ts));
|
||||
Loading…
Add table
Add a link
Reference in a new issue