-
peek-cli
- CLI binary (
main.rs,args.rs) andui/(overview, resources, network, files, kernel, tree). - Depends on
peek-corefor data andexport-enginefor JSON/MD/HTML/PDF output.
- CLI binary (
-
peek-core
- Orchestrator: owns
ProcessInfo,CollectOptions,collect(),collect_extended(), andsignal_impact(). - Delegates to helper crates:
proc-readerfor/proc/<PID>/*and sysfs parsing.kernel-explainerfor human-readable kernel state/scheduler/capabilities.resource-samplerfor CPU/disk/GPU sampling and ring buffer utilities.network-inspectorfor per-process TCP/UDP socket views.signal-enginefor impact analysis and systemd unit detection.
- Orchestrator: owns
-
proc-reader
- Parses
/proc/<PID>/status,stat,statm,fd/*,environ,cgroup, and related files into raw structs. - Intentionally does not depend on
peek-coretypes; it is low-level I/O only.
- Parses
-
kernel-explainer
- Converts raw kernel values into explanations:
- State chars → labels (Running, Zombie, Uninterruptible sleep, …).
- Scheduler policy/priority/nice → human descriptions.
- Capability bitmasks → lists of named capabilities.
- Namespaces, OOM scores, and other kernel metadata (extensible).
- Converts raw kernel values into explanations:
-
resource-sampler
- Samples CPU usage from
/proc/<PID>/stat+/proc/stat. - Reads disk I/O from
/proc/<PID>/io. - Collects GPU metrics via
nvidia-smior AMD sysfs. - Provides a generic
RingBuf<T>plusResourceSampleanddetect_fd_leak()utilities.
- Samples CPU usage from
-
network-inspector
- Reads
/proc/<PID>/fdto discover socket inodes. - Parses
/proc/net/tcp,tcp6,udp,udp6into TCP/UDP listening sockets and active connections for a given PID. - Parses
/proc/net/unixand correlates with fd inodes to list Unix domain sockets for a PID. - Provides a best-effort, time-bounded reverse DNS helper for CLI/TUI display.
- Reads
-
signal-engine
- Counts active TCP connections, child processes, and kernel file locks for a PID.
- Detects the owning systemd unit from
/proc/<PID>/cgroup. - Produces a
SignalImpactstruct with a human-readable recommendation and aprefer_gracefulflag.
-
export-engine
- Pure formatting crate; depends on
peek-corefor theProcessInfotype andProcessSnapshotwrapper. - Exposes:
to_json<T: Serialize>(&T)→ pretty JSON (used withProcessSnapshot).render_markdown(&ProcessSnapshot)→ Markdown report.render_html(&ProcessSnapshot)→ dark-themed standalone HTML.export_pdf(&ProcessSnapshot)→ renders HTML to PDF via wkhtmltopdf/weasyprint/Chromium.
- Pure formatting crate; depends on
-
peekd
-
Daemon responsible for history and alerts:
watcher— sampling loop that callspeek-core::collect()on watched PIDs and feeds history + alerts.ring_store— in-memory ring-buffer history keyed by PID, with optional JSONL history on disk under$XDG_STATE_HOME/peekdor~/.local/state/peekd(one<pid>.jsonlfile per process).alert— alert rules and evaluation engine, supporting both dynamic rules from the CLI and static rules loaded fromalerts.toml.socket— Unix domain socket server for the CLI (peekd_clientinpeek-cli).
-
IPC JSON messages (peekd ⇄ CLI):
- Socket path:
/run/peekd/peekd.sock. - All requests are single-line JSON objects with an
"action"field; responses are{"ok": bool, "data": ..}or{"ok": false, "message": ".."}. - Supported actions:
{"action":"watch","pid":123}→ start sampling PID (returns{"ok":true,"data":{"watching":123}}).{"action":"unwatch","pid":123}→ stop sampling PID and drop its history and rules.{"action":"list"}→ list watched PIDs:{"ok":true,"data":{"watching":[...]}}.{"action":"history","pid":123}→ returns an array of history samples for the PID; if not in memory, peekd first tries to load<pid>.jsonlfrom disk.{"action":"alert_add", ...}→ add an alert rule (schema matchesAlertAddRequestincrates/peekd/src/alert.rs); returns{"ok":true,"data":{"rule_id":"..."}}.{"action":"alert_list"}→ list rules:{"ok":true,"data":{"rules":[...]}}.{"action":"alert_remove","rule_id":"..."}"→ remove a rule by ID.{"action":"ping"}→ health check:{"ok":true,"data":{"pong":true,"version":"..","watching":N}}.
- Socket path:
-