LabwereldHomeInstallationConnectorsWorld modelDownloadNederlands

World model (schema 1)

Nederlands

The contract between the collector and the frontends. A frontend only needs to know this; which source the data comes from is a detail of the collector.

Transport

  • GET /api/world: the current world as JSON.
  • GET /api/events: Server-Sent Events. On connecting, a world event (with sequence number seq) arrives immediately. After that, after every round of a connector (Plex relay immediately, alarms and UniFi 10 s, Zabbix and Proxmox 30 s), a patch plus zero or more events. At most once every 2 minutes a full world follows again. Every 15 s a keepalive comment. sources contains the status per connector.
  • A patch has seq, base (the seq it applies to), generated_at, set (changed parts, such as problems or network), nodes (changed or new nodes) and removed (vanished node ids). If base does not match your own version, fetch /api/world again. The shared client (web/shared/labwereld.js) already does this; styles simply receive a world.
  • A patch also contains ops: only the changed fields, so a node with one new measurement is not sent in full. Each operation is [path, value] (set a field) or [path] (remove a field). A path is a list of keys from the world root; a number is a position in a list, and ["nodes", id, …] selects a node by id (not by position). Example: [["nodes", "web1", "metrics", "cpu_pct"], 12.5], [["sources", "zabbix", "last_success"], 1790154930]. Order of application: set, then ops, then nodes, then removed. The collector still sends a part or node in full (set or nodes) when that is smaller, or when a list changes length (the whole list is then sent as the value). The world itself does not change (schema 1). A client that does not know ops misses intermediate changes until the next full world (at most 2 minutes); reloading fetches the new shared client.
  • GET /api/healthz: is the collector itself alive? 200 as long as there is a world and the main loop has published something recently, even when a source fails; 503 when nothing has been published for longer than 3× the largest connector interval (at least 180 s): the collector is stuck. The response is JSON with ok, version, alive, sources_ok (all sources OK?), last_publish_s (seconds since the last publication), stale_after_s (the threshold) and, for information, sources (status per source). With ?strict=1 the response is 200 only if all sources work as well. The Docker HEALTHCHECK and the deployment check use the plain variant.
  • GET /api/stats: numbers about the collector itself only: duration per connector round and per composition (last, average, maximum), size of the world and of what is sent to browsers, cpu time and memory. No contents.
  • GET /api/connectors: status per connector (see connectors.html); /status/ shows this as a page.

Tip for frontends: animate continuously based on the latest world (interpolate between two rounds), and start one-off effects on events.

world

{
  "schema": 1,
  "generated_at": 1790154900,            // unix time of the snapshot
  "sources": { "zabbix": { "ok": true, "last_success": 1790154900, "error": null } },
  "sites":   [ Site ],
  "links":   [ Link ],
  "nodes":   [ Node ],
  "problems":[ Problem ],
  "backups": [ Backup ],
  "media":   { "plex": Media },
  "documents": { "paperless": Documents },
  "network": Network | null,
  "tasks":   [ Task ],
  "place":   Place | null
}

When a round fails, the previous contents stay and sources.<source>.ok becomes false; show a disturbance or noise, for example. Some sources tolerate a few failed rounds (UniFi: three): as long as the previous contents are still valid, ok stays true, with the last error in error and the number of consecutive failed rounds in failures.

Site

FieldMeaning
id, namee.g. home / Home, office / Office
node_count, up, downnode counts at this site
alert_levelhighest Zabbix severity (0–5) of nodes at this site
wan{rx_bps, tx_bps, gateway, source} or null: the site's internet connection (OPNsense, or UniFi for the UniFi network)
FieldMeaning
id, name, kinde.g. home-office, wireguard
a, bsite ids at both ends
stateup, down, unknown
state_reasonthe evidence, e.g. a recent handshake or traffic
rx_bps, tx_bpsbits/s, or null if not measured

Node

FieldMeaning
id, namestable id and display name
sitesite id (or null for an unknown auto-discovered host)
kindhypervisor, vm, ct, server, nas, appliance, device
rolefree label for choosing a sprite: cloud, firewall, backup, media, nas, dns, monitoring, mail, lab, dev, …
parent, vmidhypervisor node and Proxmox ID for guests
stateup, down, unknown
state_reasonwhy, e.g. "agent reachable", "traffic on hypervisor interface" (Dutch; the frontends translate the common ones)
activityidle (<5% cpu), normal (<50%), busy (<85%), overloaded, or null; with 3 percentage points of hysteresis around each threshold
alert_levelhighest severity of open Zabbix problems: 0 none, 2 warning, 3 average, 4 high, 5 disaster
flagscpu_high, mem_high, disk_full, hot, traffic_spike
net_sourceagent, hypervisor (Zabbix via tap/veth), proxmox or null
metricssee below; every field can be null
auto_discovereddiscovered by a source, not described in the topology (hide with [discovery] ignore)
childrencontainers on this node (empty if there are none or the source does not know), see below

metrics: cpu_pct, mem_pct, load1, cpu_count, uptime_s, disk_root_pct, disk_max_pct, disk_temp_max_c, net_in_bps, net_out_bps, containers_running.

children (containers): id (<node>/<name>), name, image (without registry, e.g. linuxserver/plex), state (running, exited, paused, restarting, dead, unknown), health (healthy, unhealthy, starting, or null without a health check), restarts, cpu_pct, mem_bytes (only when running), started_at. No environment variables, commands or volumes. Sources: the Docker connector, or the Zabbix template Docker by Zabbix agent 2.

Agreed thresholds (so all styles react the same): cpu_high ≥ 85%, mem_high ≥ 90%, disk_full ≥ 85% on any file system, hot ≥ 50 °C.

Problem

id, name, severity (0–5), severity_name, since, acknowledged, nodes (node ids).

Backup

FieldMeaning
id, system, labele.g. pbs:store/home/vm/101, pbs or borg; for the open backup status <source>:<id> and the given tool (such as restic)
source_nodenode being backed up (or null if unknown)
target_nodebackup server node
last_success, age_s, max_age_stimes in seconds
oktrue within the norm, false too old or with an error, null unknown
errorerror message of the last attempt, or null

Media

media.<service> (the name from [media.<service>], e.g. plex or jellyfin): node (node id the service runs on, or null), system (plex, jellyfin, … or null if unknown; added later, so may be missing), ok, count and sessions with per session key (Plex ratingKey or Jellyfin item id), type (movie, episode, track, …), title, show, state (playing, paused, buffering), progress (0–1), transcode and optionally art: {w, h, px} with px as base64 RGB (48×27 by default). No users, devices or addresses. Sources: the Plex relay, Tautulli, Jellyfin or the Zabbix items from [media.<service>] (see connectors.md). Several services may live on the same node; frontends add them up.

Documents

documents.<service> (the name from [documents.<service>], e.g. paperless): a document flow from scanner via Paperless-ngx to an optional copy elsewhere. Empty ({}) without [documents.*]. Added in 0.3.0 without raising the schema number.

FieldMeaning
systempaperless
nodenode id where the archive lives, or null
oktrue if the Paperless API was read this round, null without a Paperless source
totalnumber of documents, or null
queued, processingtasks waiting or being processed; null without rights on tasks
failedfailed processing not yet dismissed in Paperless, or null
last_added_attime of the newest document
recentthe 10 newest documents: id, added_at
failuresfailed processing: id (task id), at
copycopy elsewhere, or null: target (node id or null), label, state (ok, failed, unknown), ok, state_reason, last_run, last_success, copied_last, copied_total

Never titles, file names, content, correspondents or tags: those name people. Sources: the Paperless API and the Zabbix items from [documents.<service>.copy] (see connectors.md).

Network

The UniFi network of one site, or null without a UniFi source:

FieldMeaning
sitesite id the network belongs to
clientstotal, wired, wireless, other (counts only)
wanrx_bps (download) and tx_bps (upload) of the gateway
devicesper device id, name, model, kind (gateway, switch, ap), state, clients, cpu_pct, mem_pct, uptime_s, tx_bps, rx_bps

Task

Running and recent (24 hours) Proxmox tasks, newest first: id (UPID), type (vzdump, qmigrate, qmsnapshot, qmstart, …), site, hypervisor (node id), node (node id of the guest, or null), vmid, status (running, ok, warning, error), started_at, ended_at. No user names.

Place

Where the homelab is, for day and night in the styles; null if not set. tz (IANA time zone, e.g. Europe/Amsterdam), lat and lon (degrees; lat can be null for an unknown zone) and source (tijdzone = time zone, tijdzone (benadering) = approximation, or coördinaten = coordinates). Comes from the collector's TZ or LABWERELD_LAT/LABWERELD_LON. Added in 0.1.0 without raising the schema number: frontends that do not know it are not affected.

History

GET /api/history?node=<id> returns t plus series cpu_pct, mem_pct, net_in_bps and net_out_bps; node=_wan returns rx_bps/tx_bps of the network. 240 points (~2 hours). With LABWERELD_DATA_DIR (/data in the container) the history is saved every 5 minutes and on shutdown, and read back after a restart; points older than 3 hours are then dropped.

Events

Every event has a type (also the SSE event name) and ts.

TypeExtra fieldsIdea for a visual effect
node.state_changednode, old, new, reasonlights out, character knocked out / back up
node.activity_changednode, old, newwalking ↔ running, fan spins faster
node.flag_raised / node.flag_clearednode, flagsmoke, sweat drops, full cupboards
node.appeared / node.vanishednodea new character lands / leaves
link.state_changedlink, old, newtunnel collapses / is repaired
problem.started / problem.resolvedproblemflashing light, an Emergency Meeting at severity 5
backup.completedbackup, system, source_node, target_nodecargo ship from source to vault
backup.overdue / backup.recoveredbackup, source_nodedusty vault, cobwebs
traffic.spikenode, bps, baseline_bpspacket storm in the corridor
source.lost / source.restoredsource, errorstatic, "connection lost"
media.started / media.stoppedservice, node, sessioncinema opens / closes
clients.joined / clients.leftsite, count, wireless, wiredvisitor shuttles land / leave
task.started / task.finishedtask, nodeloading dock: backup is loaded / cargo ship departs
container.state_changednode, container, old, new, healthdesk empty / occupied again, or sick
container.restartednode, container, restartsanother coffee stain
document.queuedservice, node, countthe scanner pulls in a sheet
document.addedservice, node, count, documents (ids)sheets fly from the scanner to the archive
document.failedservice, node, counta crumpled sheet
document.copiedservice, node, target, label, countsheets fly from the archive to the copy
document.copy_failed / document.copy_recoveredservice, node, target, label (and reason)newspaper headline

A traffic spike is at least 4× the node's own moving average and ≥ 2 Mbit/s, with at most one spike per node per 5 minutes.

EUPL-1.2 · made with Claude · questions: labwereld@wiehie.nl