alerts: defer system info unmarshalling for systemd alerts

This commit is contained in:
henrygd
2026-09-01 21:49:45 -04:00
parent 097180e8d7
commit b1895247ba
3 changed files with 25 additions and 25 deletions

View File

@@ -39,14 +39,7 @@ func cpuStateAlertValue(name string, breakdown []float64) (float64, bool) {
func (am *AlertManager) HandleSystemAlerts(systemRecord *core.Record, data *system.CombinedData) error {
// Systemd alerts are binary state, not numeric thresholds, so they're handled
// separately. They read their own state from the database and don't use data.
// Read the confirmed empty state from the record being saved instead of data:
// dashboard polling can replace the system's in-memory payload concurrently.
var currentInfo system.Info
confirmedEmptySnapshot := false
if err := systemRecord.UnmarshalJSONField("info", &currentInfo); err == nil {
confirmedEmptySnapshot = len(currentInfo.Services) > 0 && currentInfo.Services[0] == 0
}
if err := am.HandleSystemdAlerts(systemRecord, confirmedEmptySnapshot); err != nil {
if err := am.HandleSystemdAlerts(systemRecord); err != nil {
am.hub.Logger().Error("Error handling systemd alerts", "err", err)
}