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:
Rohit Jnagal 2015-05-27 22:24:23 -07:00
commit 0553f6cd16

View File

@ -62,7 +62,12 @@ func getClockSpeed(procInfo []byte) (uint64, error) {
// Fall back to /proc/cpuinfo
matches := CpuClockSpeedMHz.FindSubmatch(procInfo)
if len(matches) != 2 {
return 0, fmt.Errorf("could not detect clock speed from output: %q", string(procInfo))
//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 {