fix: respect disabled flag for storage device alerts

Storage devices with alerts disabled in the Thresholds tab were still
triggering alerts. Added proper checking of the disabled override flag
in CheckStorage() to match the behavior of guest alerts.
This commit is contained in:
Pulse Monitor
2025-08-22 08:30:39 +00:00
parent 1dcb102812
commit 2f645ebcfb
+18
View File
@@ -533,9 +533,27 @@ func (m *Manager) CheckStorage(storage models.Storage) {
m.mu.RUnlock()
return
}
// Check if there's an override for this storage device
override, hasOverride := m.config.Overrides[storage.ID]
threshold := m.config.StorageDefault
m.mu.RUnlock()
// If alerts are disabled for this storage device, clear any existing alerts and return
if hasOverride && override.Disabled {
m.mu.Lock()
alertID := fmt.Sprintf("%s-usage", storage.ID)
if _, exists := m.activeAlerts[alertID]; exists {
delete(m.activeAlerts, alertID)
log.Info().
Str("alertID", alertID).
Str("storage", storage.Name).
Msg("Cleared alert - storage has alerts disabled")
}
m.mu.Unlock()
return
}
m.checkMetric(storage.ID, storage.Name, storage.Node, storage.Instance, "Storage", "usage", storage.Usage, &threshold)
}