@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user