Add persistent thresholds and seven-day metrics history

This commit is contained in:
maxim
2026-07-31 21:32:55 +03:00
parent ec20550c3b
commit 99dc3b76d0
12 changed files with 490 additions and 42 deletions

14
history_test.go Normal file
View File

@@ -0,0 +1,14 @@
package main
import "testing"
func TestHistoryPointFromMetrics(t *testing.T) {
metrics := dashboardMetrics{
CPU: CPUMetrics{Temperatures: []Temperature{{Celsius: 40}, {Celsius: 60}}},
Guests: GuestsMetrics{Guests: []GuestMetrics{{Status: "running", CPU: .5, MaxCPU: 4, MemoryBytes: 50, MaxMemory: 100}}},
}
point := historyPointFromMetrics(metrics)
if point.CPUTemperature != 50 || point.GuestsCPU != 50 || point.GuestsMemory != 50 {
t.Fatalf("неожиданная историческая точка: %+v", point)
}
}