fix: cpu info
build-and-release / release (push) Successful in 2m4s

This commit is contained in:
2026-06-22 18:54:50 +02:00
parent fff43a5ab6
commit 60b9fbc42c
2 changed files with 12 additions and 3 deletions
+12 -3
View File
@@ -159,9 +159,18 @@ func cpuInfo() CPUInfo {
c := CPUInfo{Model: cpuModel(string(data)), LogicalCPUs: runtime.NumCPU()} c := CPUInfo{Model: cpuModel(string(data)), LogicalCPUs: runtime.NumCPU()}
c.MinMHz, c.MaxMHz, c.CurrentMHz = cpuFreqMHz("/sys/devices/system/cpu") c.MinMHz, c.MaxMHz, c.CurrentMHz = cpuFreqMHz("/sys/devices/system/cpu")
// ponytail: cpufreq sysfs is absent on many VMs and stock Ubuntu server // ponytail: cpufreq sysfs is absent on many VMs and stock Ubuntu server
// kernels; fall back to /proc/cpuinfo "cpu MHz" so CurrentMHz isn't 0. // kernels; fall back to /proc/cpuinfo "cpu MHz" — VMs have a fixed clock,
if c.CurrentMHz == 0 { // so min == max == cur is the honest answer.
c.CurrentMHz = cpuinfoMaxMHz(string(data)) if mhz := cpuinfoMaxMHz(string(data)); mhz > 0 {
if c.CurrentMHz == 0 {
c.CurrentMHz = mhz
}
if c.MaxMHz == 0 {
c.MaxMHz = mhz
}
if c.MinMHz == 0 {
c.MinMHz = mhz
}
} }
return c return c
} }
BIN
View File
Binary file not shown.