Merge pull request #730 from bpradipt/ppc64_cpuinfo
Add support for parsing CPU speed from /proc/cpuinfo on Power (ppc64) systems
This commit is contained in:
commit
0553f6cd16
@ -61,9 +61,14 @@ func getClockSpeed(procInfo []byte) (uint64, error) {
|
||||
}
|
||||
// Fall back to /proc/cpuinfo
|
||||
matches := CpuClockSpeedMHz.FindSubmatch(procInfo)
|
||||
if len(matches) != 2 {
|
||||
//Check if we are running on Power systems which have a different format
|
||||
CpuClockSpeedMHz, _ = regexp.Compile("clock\\t*: +([0-9]+.[0-9]+)MHz")
|
||||
matches = CpuClockSpeedMHz.FindSubmatch(procInfo)
|
||||
if len(matches) != 2 {
|
||||
return 0, fmt.Errorf("could not detect clock speed from output: %q", string(procInfo))
|
||||
}
|
||||
}
|
||||
speed, err := strconv.ParseFloat(string(matches[1]), 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
Loading…
Reference in New Issue
Block a user