↓Skip to main content

P2PMon documentation

Quickstart #

  1. Download a binary for your platform from the P2PMon page and confirm its fingerprint with p2pmon fingerprint.
  2. Obtain a license (a demo or paid license) and save it as p2pmon.lic next to the binary. Alternatively, pass the token with -license or P2PMON_LICENSE.
  3. Start the seeder first — it is the admission point new hosts dial to receive their network name.
  4. 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 .lic file owner-readable only. p2pmon fingerprint prints shareable lic / bin / demo key fingerprints used to confirm issuer and fleet match.

Ports #

PortServiceExposure
5580Web dashboard (opt-in)loopback only
5581Get / blob retrieval (opt-in)loopback only
5582Put / blob upload (default on)loopback only
5583Name resolution (seeder)network
5584P2P syncnetwork

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 #

SettingDefaultPurpose
-license / P2PMON_LICENSE.lic next to binary (plus /etc and parent-dir fallbacks)license token or file
-web-server / P2PMON_WEB_SERVERoffdashboard on 5580
-get-server / P2PMON_GET_SERVERoffretrieval backend on 5581 (p2pmon -get needs it)
-put-server / P2PMON_PUT_SERVERonupload 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_EXTERNALoffdisable built-in collection; -put is the sole writer
-minimal / P2PMON_MINIMALoffmemory-saving mode for small devices (no peer blobs, no dashboard, no syslog)
-syslog / P2PMON_SYSLOGdisabledsyslog destination (host:port, tcp://…, udp://…, /dev/log)
-syslog-level / P2PMON_SYSLOG_LEVELwarn,critseverities forwarded (ok,warn,crit,name; name = seeder joins only)
P2PMON_SYSLOG_INTERVAL60forwarding interval, seconds; change/onchange/watch/on-change for on-change-only; 0/false/off/no/disabled disables all syslog
P2PMON_SYSLOG_FACILITY / P2PMON_SYSLOG_TAGlocal0 / p2pmonsyslog facility and program name
P2PMON_SCRIPTS<binary dir>/scriptsuser check scripts directory
P2PMON_SCRIPTS_TIMEOUT15shared script deadline, seconds
P2PMON_SCRIPTS_POOL1concurrent script shells (0 disables pooling, max 32)
P2PMON_WSL_DISTROdefault distroWSL distro for shell scripts on Windows
P2PMON_SYNC_TARGET60target sync interval, seconds
P2PMON_NETGATEondrop inbound sync from unknown hosts once joined (0 disables)
P2PMON_REREG_INTERVAL60re-register via seeder interval, seconds (0 disables)
P2PMON_RTT_WARN_MS / P2PMON_RTT_CRIT_MS10 / 50latency thresholds, ms
P2PMON_RTT_HARD_MS1000flap threshold, ms
P2PMON_RTT_TTL / P2PMON_RTT_FAIL_TTL600 / 120peer retention / failure expiry, seconds
P2PMON_RTT_SYNTHonfill unmeasured reverse edges in the latency map (0 disables)
P2PMON_DICTonshared zstd dictionary (0 forces plain encoding)
-dict-force-rebuild / P2PMON_DICT_REBUILDoffseeder-only one-shot dictionary retrain
P2PMON_RM_SKEW600auto-heal margin for removed hosts, seconds
P2PMON_MEM_MAX_PCT5restart -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 with p2pmon -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 -minimal appended (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); set 0 to disable. A runtime flag change alone cannot shed memory already held, which is why a restart is used instead.

Troubleshooting #

  • Fingerprint mismatch (p2pmon fingerprint differs 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 -minimal unprompted: the memory watchdog tripped; RSS is compared against P2PMON_MEM_MAX_PCT of system RAM. Either raise the percent or set 0 to disable the watchdog.