Files
Pulse/internal/unifiedresources/host_disk_usage.go
pulse-triage[bot] 6e35e3252b Keep unavailable agent filesystems from resolving disk alerts
Apply existing canonical disk observation admission to filesystem alert evaluation. Hold incidents across unavailable rows or empty reports, interrupt timed evidence and retain linked-node ownership only for held alerts. Keep measured-zero recovery, policy changes and authoritative removal.

Contract-Neutral: Shares existing disk metric admission and unavailable-observation rules without API, schema, collection or canonical projection changes.
Change-source: pulse-maintainer
2026-10-24 21:40:10 +01:00

31 lines
1.0 KiB
Go

package unifiedresources
import "github.com/rcourtman/pulse-go-rewrite/internal/models"
// HostDiskUsagePercent uses the same first-filesystem admission as the
// canonical host metric. Missing or unavailable inventory is not measured zero.
func HostDiskUsagePercent(disks []models.Disk) (float64, bool) {
if len(disks) == 0 {
return 0, false
}
return DiskUsagePercent(disks[0])
}
// DiskUsagePercent applies canonical observation admission to one filesystem.
// A listed filesystem can still have an unavailable or contradictory reading.
func DiskUsagePercent(disk models.Disk) (float64, bool) {
if !hasObservedDiskUsage(disk) {
return 0, false
}
return disk.Usage, true
}
// DiskUsagePercent preserves canonical metric presence, including provider
// readings without agent filesystem inventory. Reporting freshness is separate.
func (v HostView) DiskUsagePercent() (float64, bool) {
if v.r == nil || v.r.Metrics == nil || v.r.Metrics.Disk == nil {
return 0, false
}
return v.r.Metrics.Disk.Percent, true
}