Context
The periodic ZFS collector is the main source of sudo/journald log volume on nodes that run EasyZFS 24/7. We already reduced log volume in #124 by lowering the collector log level, but the collector still runs every EASYZFS_ZPOOL_INTERVAL (default 60 s) regardless of whether a user is looking at the UI.
The web UI connects to /api/events and keeps an SSE stream open while it is in use. The Hub already tracks active subscribers, so we can use that as a cheap presence signal.
Goal
- Run a cheap health/alert heartbeat every ~60 s even when the UI is closed, so background alerts (DEGRADED, scrub, capacity) still fire promptly.
- Run a full data collection only when the UI is connected or, at worst, every ~5 minutes, so datasets/snapshots/history/series are still refreshed but the node is quiet most of the time.
- Keep this configurable through environment variables with sensible defaults.
Proposed design
- Add SubscriberCount() to internal/hub/hub.go.
- Pass a presence callback to NewZpoolCollector (or read it from the existing Hub).
- Split collectOnce into:
- light collect (zpool list, zpool status --json per pool): evaluate alerts, publish state changes.
- full collect (datasets, snapshots, history, series): reuse existing logic.
- Dynamic schedule:
- UI connected: full collect every EASYZFS_ZPOOL_INTERVAL (default 10 s).
- UI disconnected: light collect every EASYZFS_ZPOOL_ALERT_INTERVAL (default 60 s), full collect every EASYZFS_ZPOOL_IDLE_INTERVAL (default 300 s).
- Add tests for the new interval logic.
Acceptance criteria
Related
Context
The periodic ZFS collector is the main source of sudo/journald log volume on nodes that run EasyZFS 24/7. We already reduced log volume in #124 by lowering the collector log level, but the collector still runs every EASYZFS_ZPOOL_INTERVAL (default 60 s) regardless of whether a user is looking at the UI.
The web UI connects to /api/events and keeps an SSE stream open while it is in use. The Hub already tracks active subscribers, so we can use that as a cheap presence signal.
Goal
Proposed design
Acceptance criteria
Related