CpuInfo - file /proc/cpuinfo
¶
This parser reads the content of the /proc/cpuinfo
file and parses it
into a dictionary of lists, keyed on the left hand column of the cpuinfo
output.
The object also provides properties for the standard information about the CPU and motherboard architecture.
Sample input:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 45
model name : Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz
stepping : 2
microcode : 1808
cpu MHz : 2900.000
cache size : 20480 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
flags : fpu vme de pse tsc msr pae mce
address sizes : 40 bits physical, 48 bits virtual
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 45
model name : Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz
stepping : 2
microcode : 1808
cpu MHz : 2900.000
cache size : 20480 KB
physical id : 2
siblings : 1
core id : 0
cpu cores : 1
apicid : 2
flags : fpu vme de pse tsc msr pae mce
address sizes : 40 bits physical, 48 bits virtual
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
Examples
>>> cpu_info.cpu_count
2
>>> sorted(cpu_info.apicid)
['0', '2']
>>> cpu_info.socket_count
2
>>> cpu_info.vendor
'GenuineIntel'
>>> "fpu" in cpu_info.flags
True
>>> cpu_info.model_name
'Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz'
>>> cpu_info.get_processor_by_index(0)['cpus']
'0'
>>> cpu_info.get_processor_by_index(0)['vendors']
'GenuineIntel'
-
class
insights.parsers.cpuinfo.
CpuInfo
(context)[source]¶ Bases:
insights.core.LegacyItemAccess
,insights.core.Parser
CpuInfo parser - able to be used as a dictionary through the LegacyItemAccess mixin class.
The following items are remapped into lists, with the element number corresponding to the CPU. For example, given the following input:
processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 45 model name : Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz stepping : 2 microcode : 1808 cpu MHz : 2900.000 cache size : 20480 KB physical id : 2 siblings : 1 core id : 0 cpu cores : 1 apicid : 2 address sizes : 40 bits physical, 48 bits virtual bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
The following keys would be lists of:
cpus - the processor line (e.g.
1
)sockets - the physical id line (e.g.
2
)vendors - the vendor_id line (e.g.
GenuineIntel
)models - the model name line (e.g.
Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz
)model_ids - the model line (e.g.
45
)families - the cpu family line (e.g.
6
)clockspeeds - the cpu MHz line (e.g.
2900.000
)cache_sizes - the cache size line (e.g.
20480 KB
)cpu_cores - the cpu cores line (e.g.
1
)apicid - the apicid line (e.g.
1
)stepping - the stepping line (e.g.
2
)address_sizes - the address sizes line (e.g.
40 bits physical, 48 bits virtual
)bugs - the bugs line (e.g.
cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
)
-
property
apicid
¶ Returns the apicid of the processor.
- Type
str
-
property
cache_size
¶ Returns the cache size of the first CPU.
- Type
str
-
property
core_total
¶ Returns the total number of cores for the server if available, else None.
- Type
str
-
property
cpu_count
¶ Returns the number of CPUs.
- Type
str
-
property
cpu_speed
¶ Returns the CPU speed of the first CPU.
- Type
str
-
property
flags
¶ Returns a list of feature flags for the first CPU.
- Type
list
-
get_processor_by_index
(index)[source]¶ Construct a dictionary of the information stored for the given CPU.
- Parameters
index (int) -- The CPU index to retrieve.
- Returns
A dictionary of the information for that CPU.
- Return type
dict
-
property
model_name
¶ Returns the model name of the first CPU.
- Type
str
-
property
model_number
¶ Returns the model ID of the first CPU.
- Type
str
-
property
socket_count
¶ Returns the number of sockets. This is distinct from the number of CPUs.
- Type
str
-
property
vendor
¶ Returns the vendor of the first CPU.
- Type
str