fix: cpu info
This commit is contained in:
@@ -159,9 +159,18 @@ func cpuInfo() CPUInfo {
|
||||
c := CPUInfo{Model: cpuModel(string(data)), LogicalCPUs: runtime.NumCPU()}
|
||||
c.MinMHz, c.MaxMHz, c.CurrentMHz = cpuFreqMHz("/sys/devices/system/cpu")
|
||||
// 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.
|
||||
if c.CurrentMHz == 0 {
|
||||
c.CurrentMHz = cpuinfoMaxMHz(string(data))
|
||||
// kernels; fall back to /proc/cpuinfo "cpu MHz" — VMs have a fixed clock,
|
||||
// so min == max == cur is the honest answer.
|
||||
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
|
||||
}
|
||||
|
||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user