Skip to content

feat(notify): alert when Btrfs or ZFS usage reaches a configurable threshold - #1133

Merged
Starosdev merged 2 commits into
developfrom
feat/1132-usage-threshold-notifications
Nov 5, 2026
Merged

Starosdev merged 2 commits into
developfrom
feat/1132-usage-threshold-notifications

Conversation

@Starosdev

Copy link
Copy Markdown
Owner

Summary

Adds one setting, metrics.filesystem_usage_threshold_percent (0 disables, 1 to 100), and a usage alert for Btrfs filesystems and ZFS pools on top of the per-upload notification path from #1127 and #1131. This is the optional item from #1110.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or infrastructure change

Related Issues

Closes #1132

Changes Made

  • models/settings.go: FilesystemUsageThresholdPercent under metrics; MaxFilesystemUsageThresholdPercent = 100. Zero is the disabled sentinel, so no default is needed and existing installs are unchanged.
  • handler/save_settings.go: rejects values outside 0..100 with a 400.
  • notify/btrfs.go, notify/zfs.go: new least-severe failure types BtrfsUsageHigh and ZFSUsageHigh. BtrfsUsagePercent mirrors the dashboard formula (statfs_used / (statfs_used + statfs_available), falling back to used / device_size); ZFS uses capacity_percent. Shared usageCrossed fires at or above the threshold when newly crossed, first seen, or repeating. Both messages now carry a Usage line.
  • handler/state_notify.go: settings load on every unsilenced upload (the threshold lives there) instead of after a repeat-only pre-check. Muted and archived rows still return before the load. failureTypes takes the threshold.
  • Frontend: filesystem_usage_threshold_percent in app.config.ts; number input with validation in the dashboard settings dialog under the temperature settings; Save disabled while invalid via the new notificationSettingsInvalid getter.
  • Docs: Btrfs and ZFS monitoring notification sections, openapi.yaml settings schema.

Testing

  • I have tested this locally
  • I have added/updated tests that prove my fix/feature works
  • All existing tests pass

go test ./webapp/backend/pkg/web/handler/ ./webapp/backend/pkg/models/ -count=1 ok; go test ./webapp/backend/pkg/notify/ -run 'Btrfs|ZFS' ok.

  • notify: 7 new Btrfs and 5 new ZFS usage cases in the failure-type tables (cross, at threshold, stays above with and without repeat, first upload, below, disabled), plus TestBtrfsUsagePercent. Full notify package still has the macOS-only TestScriptStreamsOutputAndPreservesEnvironment failure noted in feat(btrfs): notify on degraded filesystems, device errors and scrub errors #1127; unrelated.
  • handler: TestSaveSettingsFilesystemUsageThresholdValidation (0, 1, 100 accepted; -1, 101 rejected). Healthy-upload tests now return settings and assert GetNotifyUrls is never called.
  • Frontend: one new spec case for the threshold validation getter. Not run locally (no node_modules here); relies on the Test Frontend CI job.
  • go build ./webapp/backend/..., go vet and gofmt -l clean on the touched packages.

Review: not required (lands on develop; reaches users through the promotion PR and release).

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code where necessary (particularly complex areas)
  • I have updated the documentation if needed
  • My changes generate no new warnings
  • No console.log, debug statements, or commented-out code

Screenshots (if applicable)

N/A

Additional Notes

Cost: one extra LoadSettings (a setting_entries table read) per Btrfs or ZFS upload, so once per collector interval per filesystem or pool.

Starosdev and others added 2 commits November 5, 2026 03:09
…reshold

One new setting, metrics.filesystem_usage_threshold_percent (0 disables,
1 to 100), exposed in the dashboard notification settings and validated by
POST /api/settings. The Btrfs and ZFS upload paths gain a fourth, least
severe failure type (BtrfsUsageHigh, ZFSUsageHigh) that fires when usage
reaches the threshold since the previous upload, on first sight, or on
every upload while above it with repeat notifications on.

Btrfs usage is computed as the dashboard does it: statfs used over used
plus available when the collector sent statfs figures, raw used over
device size otherwise. ZFS uses the collector's capacity_percent.

notifyStateChange now loads settings on every unsilenced upload instead
of after a repeat-only pre-check, because the threshold lives in settings.
Usage is included in both notification bodies.

Closes #1132

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XyPthdH33ZeTJLDutdTt24
… a restart

SaveSettings only updates setting_entries rows that already exist, so the
new threshold lived in memory until the next restart and then reverted to
disabled. A migration now seeds the row at 0, and a sqlite round-trip test
saves 80, reloads from a fresh config, and checks it is still 80.

Also adds the ZFS "usage at threshold" table case the Btrfs table had.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XyPthdH33ZeTJLDutdTt24
@Starosdev
Starosdev merged commit 6e79118 into develop Nov 5, 2026
29 checks passed
Starosdev pushed a commit that referenced this pull request Nov 5, 2026
## [1.80.0](v1.79.3...v1.80.0) (2026-11-05)

### Features

* **btrfs:** notify on degraded filesystems, device errors and scrub errors ([#1127](#1127)) ([36e1e23](36e1e23)), closes [#1110](#1110)
* manual release trigger ([44f3e44](44f3e44))
* **notify:** alert when Btrfs or ZFS usage reaches a configurable threshold ([#1133](#1133)) ([6e79118](6e79118)), closes [#1127](#1127) [#1132](#1132) [#1127](#1127)
* **zfs:** notify on unhealthy pools, error totals and scrub errors ([#1131](#1131)) ([9c6544c](9c6544c)), closes [#1127](#1127) [#1130](#1130) [#1127](#1127)

### Bug Fixes

* **database:** inline validated ids in Btrfs and ZFS history queries for InfluxDB OSS ([#1111](#1111)) ([#1124](#1124)) ([b0a1c69](b0a1c69)), closes [#157](#157) [#155](#155) [#157](#157) [#157](#157)
* **mdadm:** honor repeat notifications and retry failed degraded alerts ([#1128](#1128)) ([62f9cef](62f9cef)), closes [#1109](#1109)
* **notify:** notify on manufacturer SMART failures at every notify level ([#1126](#1126)) ([5cb3622](5cb3622))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant