Copyright 2019 The Prometheus Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

package procfs

import (
	
	
	
	

	
)
CPUInfo returns information about current system CPUs. See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
func ( FS) () ([]CPUInfo, error) {
	,  := util.ReadFileNoStat(.proc.Path("cpuinfo"))
	if  != nil {
		return nil, 
	}
	return parseCPUInfo()
}
parseCPUInfo parses data from /proc/cpuinfo
func ( []byte) ([]CPUInfo, error) {
	 := []CPUInfo{}
	 := -1
	 := bufio.NewScanner(bytes.NewReader())
	for .Scan() {
		 := .Text()
		if strings.TrimSpace() == "" {
			continue
		}
		 := strings.SplitN(, ": ", 2)
		switch strings.TrimSpace([0]) {
		case "processor":
			 = append(, CPUInfo{}) // start of the next processor
			++
			,  := strconv.ParseUint([1], 0, 32)
			if  != nil {
				return nil, 
			}
			[].Processor = uint()
		case "vendor_id":
			[].VendorID = [1]
		case "cpu family":
			[].CPUFamily = [1]
		case "model":
			[].Model = [1]
		case "model name":
			[].ModelName = [1]
		case "stepping":
			[].Stepping = [1]
		case "microcode":
			[].Microcode = [1]
		case "cpu MHz":
			,  := strconv.ParseFloat([1], 64)
			if  != nil {
				return nil, 
			}
			[].CPUMHz = 
		case "cache size":
			[].CacheSize = [1]
		case "physical id":
			[].PhysicalID = [1]
		case "siblings":
			,  := strconv.ParseUint([1], 0, 32)
			if  != nil {
				return nil, 
			}
			[].Siblings = uint()
		case "core id":
			[].CoreID = [1]
		case "cpu cores":
			,  := strconv.ParseUint([1], 0, 32)
			if  != nil {
				return nil, 
			}
			[].CPUCores = uint()
		case "apicid":
			[].APICID = [1]
		case "initial apicid":
			[].InitialAPICID = [1]
		case "fpu":
			[].FPU = [1]
		case "fpu_exception":
			[].FPUException = [1]
		case "cpuid level":
			,  := strconv.ParseUint([1], 0, 32)
			if  != nil {
				return nil, 
			}
			[].CPUIDLevel = uint()
		case "wp":
			[].WP = [1]
		case "flags":
			[].Flags = strings.Fields([1])
		case "bugs":
			[].Bugs = strings.Fields([1])
		case "bogomips":
			,  := strconv.ParseFloat([1], 64)
			if  != nil {
				return nil, 
			}
			[].BogoMips = 
		case "clflush size":
			,  := strconv.ParseUint([1], 0, 32)
			if  != nil {
				return nil, 
			}
			[].CLFlushSize = uint()
		case "cache_alignment":
			,  := strconv.ParseUint([1], 0, 32)
			if  != nil {
				return nil, 
			}
			[].CacheAlignment = uint()
		case "address sizes":
			[].AddressSizes = [1]
		case "power management":
			[].PowerManagement = [1]
		}
	}
	return , nil