mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-22 01:17:48 +02:00
alerts: defer system info unmarshalling for systemd alerts
This commit is contained in:
@@ -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", ¤tInfo); 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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user