mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-03 18:43:38 +01:00
A host agent's disk can show a temperature only its Unraid inventory reports: a SMART row whose smartctl probe returned none takes its Unraid row's reading, and a disk only the inventory lists is built from that row alone. The Physical Disks Temp cell, the Running Hot verdict and Patrol judge that reading against the alert disk temperature policy, but CheckHost read only the SMART row's own field, so a disk could read as at its alert threshold while no alert fired. unifiedresources.HostDiskTemperatureReadings now lists the reading each of a host's disks shows, built with the registry's own adapters: one per SMART row, then one per Unraid row whose disk key no SMART row carries (the history writer's rule). CheckHost judges those. SMART rows keep their alert resource IDs, an inventory-only disk uses its block device token, and per-type thresholds follow the disk type the disk shows. Only a reading collected now fires or resolves, so spun-down disks hold their alerts. When conflicting serials put two disks on one device, its alert judges the reading that stands highest against its own type's threshold. An inventory-only disk the agent's --disk-exclude patterns match raises nothing, and an alert it raised before the exclusion resolves on the next report, as the documented exclusion from monitoring already suppresses linked Proxmox health and wear alerts. Absence cleanup still runs only on a non-empty SMART list. Unraid's own disk temperature notifications do not make this redundant: Pulse already alerts on the smartctl readings and array state of the same hosts, which Unraid also notifies on.
73 lines
2.3 KiB
Go
73 lines
2.3 KiB
Go
package alerts
|
|
|
|
import "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
|
|
|
|
// clearHostDiskTemperatureResources resolves the disk temperature alerts
|
|
// raised under the given resource IDs and drops their pending threshold runs.
|
|
// CheckHost calls it for disks its host still lists but the agent's
|
|
// --disk-exclude patterns took out of monitoring, so no reading will resolve
|
|
// them.
|
|
func (m *Manager) clearHostDiskTemperatureResources(resourceIDs map[string]struct{}) {
|
|
if len(resourceIDs) == 0 {
|
|
return
|
|
}
|
|
|
|
m.mu.Lock()
|
|
defer m.mu.Unlock()
|
|
|
|
var storageKeys []string
|
|
for storageKey, alert := range m.activeAlerts {
|
|
if alert == nil {
|
|
continue
|
|
}
|
|
if _, ok := resourceIDs[alert.ResourceID]; ok {
|
|
storageKeys = append(storageKeys, storageKey)
|
|
}
|
|
}
|
|
for resourceID := range resourceIDs {
|
|
m.core.DropPendingForResource(resourceID)
|
|
}
|
|
for _, storageKey := range storageKeys {
|
|
m.clearAlertNoLock(storageKey)
|
|
}
|
|
}
|
|
|
|
// judgedHostDiskTemperature is a disk temperature reading with the threshold
|
|
// its disk type resolves to under the host's policy.
|
|
type judgedHostDiskTemperature struct {
|
|
reading unifiedresources.HostDiskTemperatureReading
|
|
threshold *HysteresisThreshold
|
|
}
|
|
|
|
// standing ranks the reading against its own threshold: 2 at or above the
|
|
// trigger, 1 inside the recovery band, where an open alert holds, 0 below it,
|
|
// and -1 when the threshold is off. margin is how far the reading sits above
|
|
// the trigger.
|
|
func (j judgedHostDiskTemperature) standing() (rank int, margin float64) {
|
|
threshold := j.threshold
|
|
if threshold == nil || threshold.Trigger <= 0 {
|
|
return -1, 0
|
|
}
|
|
temperature := float64(j.reading.Temperature)
|
|
margin = temperature - threshold.Trigger
|
|
switch {
|
|
case temperature >= threshold.Trigger:
|
|
return 2, margin
|
|
case threshold.Clear > 0 && threshold.Clear < threshold.Trigger && temperature > threshold.Clear:
|
|
return 1, margin
|
|
default:
|
|
return 0, margin
|
|
}
|
|
}
|
|
|
|
// outranks reports whether j should be judged instead of other for their
|
|
// shared alert. A tie keeps the reading listed first.
|
|
func (j judgedHostDiskTemperature) outranks(other judgedHostDiskTemperature) bool {
|
|
rank, margin := j.standing()
|
|
otherRank, otherMargin := other.standing()
|
|
if rank != otherRank {
|
|
return rank > otherRank
|
|
}
|
|
return margin > otherMargin
|
|
}
|