P2PMon documentation
Table of Contents
Quickstart #
- Download a binary for your platform from the
P2PMon page and confirm its fingerprint
with
p2pmon fingerprint. - Obtain a license (a demo or paid
license) and save it as
p2pmon.licnext to the binary. Alternatively, pass the token with-licenseorP2PMON_LICENSE. - Start the seeder first — it is the admission point new hosts dial to receive their network name.
- Start each further host with the same license file. Within a minute the fleet view populates on every node.
The local dashboard is opt-in: -web-server (or P2PMON_WEB_SERVER=1)
serves it on localhost:5580.
Concepts #
- Seeder. The initial admission point and name authority. Its hostname, IP and MAC are bound into the license and enforced on the seeder host; members use the same license file without an IP/MAC check.
- Sync mesh. Every node dials random peers on a cadence targeting ~60s
fleet-wide coverage (
P2PMON_SYNC_TARGET). Reports are compressed with zstd, HMAC-signed with the license key, and replicated — a node holds the whole fleet’s status. - Trust model. Blobs and binaries are HMAC-SHA256 authenticated. Only holders of the fleet license can participate; demo and paid licenses use separate trust roots, so their fleets reject each other’s blobs. A separate key signs the distributed binaries, which are verified before execution.
- License lifecycle. The license file is watched (checked every 60s): a renewal takes effect
without a restart, a broken rewrite is rejected with the current license
kept, and expiry stops the daemon. Keep the
.licfile owner-readable only.p2pmon fingerprintprints shareablelic/bin/demokey fingerprints used to confirm issuer and fleet match.
Ports #
| Port | Service | Exposure |
|---|---|---|
| 5580 | Web dashboard (opt-in) | loopback only |
| 5581 | Get / blob retrieval (opt-in) | loopback only |
| 5582 | Put / blob upload (default on) | loopback only |
| 5583 | Name resolution (seeder) | network |
| 5584 | P2P sync | network |
Web, get and put are never network-exposed; only the name and sync ports accept remote connections, and sync callers outside the known roster are dropped once the node has joined.
Configuration reference #
| Setting | Default | Purpose |
|---|---|---|
-license / P2PMON_LICENSE | .lic next to binary (plus /etc and parent-dir fallbacks) | license token or file |
-web-server / P2PMON_WEB_SERVER | off | dashboard on 5580 |
-get-server / P2PMON_GET_SERVER | off | retrieval backend on 5581 (p2pmon -get needs it) |
-put-server / P2PMON_PUT_SERVER | on | upload backend on 5582; an explicit -put-server flag wins either way |
-get <regex> | — | dump blobs for hosts matching regex (needs license + local daemon) |
-put <file> | — | upload report file as this host’s status; numeric host TAB 0/1/2 TAB test TAB value (0=OK 1=WARN 2=CRIT) |
-external / P2PMON_EXTERNAL | off | disable built-in collection; -put is the sole writer |
-minimal / P2PMON_MINIMAL | off | memory-saving mode for small devices (no peer blobs, no dashboard, no syslog) |
-syslog / P2PMON_SYSLOG | disabled | syslog destination (host:port, tcp://…, udp://…, /dev/log) |
-syslog-level / P2PMON_SYSLOG_LEVEL | warn,crit | severities forwarded (ok,warn,crit,name; name = seeder joins only) |
P2PMON_SYSLOG_INTERVAL | 60 | forwarding interval, seconds; change/onchange/watch/on-change for on-change-only; 0/false/off/no/disabled disables all syslog |
P2PMON_SYSLOG_FACILITY / P2PMON_SYSLOG_TAG | local0 / p2pmon | syslog facility and program name |
P2PMON_SCRIPTS | <binary dir>/scripts | user check scripts directory |
P2PMON_SCRIPTS_TIMEOUT | 15 | shared script deadline, seconds |
P2PMON_SCRIPTS_POOL | 1 | concurrent script shells (0 disables pooling, max 32) |
P2PMON_WSL_DISTRO | default distro | WSL distro for shell scripts on Windows |
P2PMON_SYNC_TARGET | 60 | target sync interval, seconds |
P2PMON_NETGATE | on | drop inbound sync from unknown hosts once joined (0 disables) |
P2PMON_REREG_INTERVAL | 60 | re-register via seeder interval, seconds (0 disables) |
P2PMON_RTT_WARN_MS / P2PMON_RTT_CRIT_MS | 10 / 50 | latency thresholds, ms |
P2PMON_RTT_HARD_MS | 1000 | flap threshold, ms |
P2PMON_RTT_TTL / P2PMON_RTT_FAIL_TTL | 600 / 120 | peer retention / failure expiry, seconds |
P2PMON_RTT_SYNTH | on | fill unmeasured reverse edges in the latency map (0 disables) |
P2PMON_DICT | on | shared zstd dictionary (0 forces plain encoding) |
-dict-force-rebuild / P2PMON_DICT_REBUILD | off | seeder-only one-shot dictionary retrain |
P2PMON_RM_SKEW | 600 | auto-heal margin for removed hosts, seconds |
P2PMON_MEM_MAX_PCT | 5 | restart -minimal past this % of system RAM (0 disables) |
Full flag help is printed by p2pmon -h. -get/-put need a license and a running local daemon.
Dashboard #
Summary, Fleet, Hosts, Tests and Latency views are included; Warn/Crit
groups can be acknowledged (ACK…, replicated fleet-wide) and retired
hosts can be removed (auto-heal is triggered when a newer report arrives).
The RTT test rows and the Latency pixel map expose the measured
connect-time matrix between peers.
Custom scripts #
Numbered scripts placed in scripts/ are run every 60s and their findings
are folded into the fleet-wide report. Results are emitted with
"$P2PMON_BIN" status <host> ok|warn|crit <test> <comment>
(shell) or raw OK|WARN|CRIT<TAB><host><TAB><test><TAB><value> lines
(other languages). A single script can be trialled with
p2pmon test <script> without starting the daemon; it prints
BLOBHOST<TAB>HOST<TAB>STATUS<TAB>TEST<TAB>VALUE lines and exits
0=OK, 1=WARN, 2=CRIT, 3=harness failure.
Syslog forwarding #
When P2PMON_SYSLOG is set, the whole fleet’s warn/crit lines are forwarded
each interval for SIEM ingestion (or on change only with P2PMON_SYSLOG_INTERVAL=change). Any number of hosts may forward (each
forwards the whole fleet, so usually one is enabled). Seeder join events are
logged separately with the name level.
Minimal and external modes #
- Minimal (
-minimal): for routers and small devices. No peer blobs are stored and no dashboard is served; the node still reports and syncs out. - External (
-external): for fleets with their own monitoring. Built-in collection is disabled and reports are pushed withp2pmon -put <file>. - Memory watchdog (
P2PMON_MEM_MAX_PCT, default 5): when process RSS exceeds the given percent of system RAM for 3 consecutive 60s polls, the daemon is restarted with-minimalappended (same process on Unix, respawned on Windows). A node that is already minimal only logs; unreadable measurements never trigger a restart. On small hosts the default trips early (5% of 512 MiB is ~25 MiB); set0to disable. A runtime flag change alone cannot shed memory already held, which is why a restart is used instead.
Troubleshooting #
- Fingerprint mismatch (
p2pmon fingerprintdiffers between nodes): the binaries were built from different secrets — rebuild from one source. - Host shows
never reported: it has not yet synced in; check the seeder is reachable on 5583/5584 and the license file is present. - Peer refused after restart: re-registration is automatic; if a node stays unknown it re-announces through the seeder within a couple of minutes.
- Syslog silent: syslog is incompatible with minimal mode and a no-op on Windows; otherwise the destination and level have to be rechecked.
- Node restarted into
-minimalunprompted: the memory watchdog tripped; RSS is compared againstP2PMON_MEM_MAX_PCTof system RAM. Either raise the percent or set0to disable the watchdog.