mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 10:46:16 +01:00
add peak values for cpu and net
This commit is contained in:
@@ -153,6 +153,11 @@ func (rm *RecordManager) AverageSystemStats(records []*models.Record) system.Sta
|
||||
// use different counter for temps in case some records don't have them
|
||||
tempCount := float64(0)
|
||||
|
||||
// peak values
|
||||
peakCpu := float64(0)
|
||||
peakNs := float64(0)
|
||||
peakNr := float64(0)
|
||||
|
||||
var stats system.Stats
|
||||
for _, record := range records {
|
||||
record.UnmarshalJSONField("stats", &stats)
|
||||
@@ -171,6 +176,10 @@ func (rm *RecordManager) AverageSystemStats(records []*models.Record) system.Sta
|
||||
sum.DiskWritePs += stats.DiskWritePs
|
||||
sum.NetworkSent += stats.NetworkSent
|
||||
sum.NetworkRecv += stats.NetworkRecv
|
||||
// set peak values
|
||||
peakCpu = max(peakCpu, stats.PeakCpu, stats.Cpu)
|
||||
peakNs = max(peakNs, stats.PeakNetworkSent, stats.NetworkSent)
|
||||
peakNr = max(peakNr, stats.PeakNetworkRecv, stats.NetworkRecv)
|
||||
// add temps to sum
|
||||
if stats.Temperatures != nil {
|
||||
tempCount++
|
||||
@@ -196,21 +205,24 @@ func (rm *RecordManager) AverageSystemStats(records []*models.Record) system.Sta
|
||||
}
|
||||
|
||||
stats = system.Stats{
|
||||
Cpu: twoDecimals(sum.Cpu / count),
|
||||
Mem: twoDecimals(sum.Mem / count),
|
||||
MemUsed: twoDecimals(sum.MemUsed / count),
|
||||
MemPct: twoDecimals(sum.MemPct / count),
|
||||
MemBuffCache: twoDecimals(sum.MemBuffCache / count),
|
||||
MemZfsArc: twoDecimals(sum.MemZfsArc / count),
|
||||
Swap: twoDecimals(sum.Swap / count),
|
||||
SwapUsed: twoDecimals(sum.SwapUsed / count),
|
||||
DiskTotal: twoDecimals(sum.DiskTotal / count),
|
||||
DiskUsed: twoDecimals(sum.DiskUsed / count),
|
||||
DiskPct: twoDecimals(sum.DiskPct / count),
|
||||
DiskReadPs: twoDecimals(sum.DiskReadPs / count),
|
||||
DiskWritePs: twoDecimals(sum.DiskWritePs / count),
|
||||
NetworkSent: twoDecimals(sum.NetworkSent / count),
|
||||
NetworkRecv: twoDecimals(sum.NetworkRecv / count),
|
||||
Cpu: twoDecimals(sum.Cpu / count),
|
||||
PeakCpu: twoDecimals(peakCpu),
|
||||
Mem: twoDecimals(sum.Mem / count),
|
||||
MemUsed: twoDecimals(sum.MemUsed / count),
|
||||
MemPct: twoDecimals(sum.MemPct / count),
|
||||
MemBuffCache: twoDecimals(sum.MemBuffCache / count),
|
||||
MemZfsArc: twoDecimals(sum.MemZfsArc / count),
|
||||
Swap: twoDecimals(sum.Swap / count),
|
||||
SwapUsed: twoDecimals(sum.SwapUsed / count),
|
||||
DiskTotal: twoDecimals(sum.DiskTotal / count),
|
||||
DiskUsed: twoDecimals(sum.DiskUsed / count),
|
||||
DiskPct: twoDecimals(sum.DiskPct / count),
|
||||
DiskReadPs: twoDecimals(sum.DiskReadPs / count),
|
||||
DiskWritePs: twoDecimals(sum.DiskWritePs / count),
|
||||
NetworkSent: twoDecimals(sum.NetworkSent / count),
|
||||
PeakNetworkSent: twoDecimals(peakNs),
|
||||
NetworkRecv: twoDecimals(sum.NetworkRecv / count),
|
||||
PeakNetworkRecv: twoDecimals(peakNr),
|
||||
}
|
||||
|
||||
if len(sum.Temperatures) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user