Skip to content

Throttle ZFS collector when no UI is connected #126

Description

@gnacho

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

  1. Add SubscriberCount() to internal/hub/hub.go.
  2. Pass a presence callback to NewZpoolCollector (or read it from the existing Hub).
  3. 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.
  4. 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).
  5. Add tests for the new interval logic.

Acceptance criteria

  • zpool status / zpool list commands are dramatically reduced when no UI client is connected.
  • Alerts still evaluate at least every minute without a UI.
  • Historical series still persist at least every 10 minutes.
  • Existing EASYZFS_ZPOOL_INTERVAL keeps working as the UI open interval.
  • New env vars documented in README.md / README.es.md.
  • Release and deploy v2.9.21.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions