refactor load average handling (#982)

- Transitioned from individual load average fields (LoadAvg1, LoadAvg5,
LoadAvg15) to a single array (LoadAvg)
- Ensure load is displayed when all zero values.
This commit is contained in:
henrygd
2025-07-25 18:07:11 -04:00
parent 6953edf59e
commit 91679b5cc0
10 changed files with 116 additions and 69 deletions

View File

@@ -47,9 +47,7 @@ type SystemAlertStats struct {
NetSent float64 `json:"ns"`
NetRecv float64 `json:"nr"`
Temperatures map[string]float32 `json:"t"`
LoadAvg1 float64 `json:"l1"`
LoadAvg5 float64 `json:"l5"`
LoadAvg15 float64 `json:"l15"`
LoadAvg [3]float64 `json:"la"`
}
type SystemAlertData struct {

View File

@@ -55,13 +55,13 @@ func (am *AlertManager) HandleSystemAlerts(systemRecord *core.Record, data *syst
val = data.Info.DashboardTemp
unit = "°C"
case "LoadAvg1":
val = data.Info.LoadAvg1
val = data.Info.LoadAvg[0]
unit = ""
case "LoadAvg5":
val = data.Info.LoadAvg5
val = data.Info.LoadAvg[1]
unit = ""
case "LoadAvg15":
val = data.Info.LoadAvg15
val = data.Info.LoadAvg[2]
unit = ""
}
@@ -200,11 +200,11 @@ func (am *AlertManager) HandleSystemAlerts(systemRecord *core.Record, data *syst
alert.mapSums[key] += temp
}
case "LoadAvg1":
alert.val += stats.LoadAvg1
alert.val += stats.LoadAvg[0]
case "LoadAvg5":
alert.val += stats.LoadAvg5
alert.val += stats.LoadAvg[1]
case "LoadAvg15":
alert.val += stats.LoadAvg15
alert.val += stats.LoadAvg[2]
default:
continue
}