檢視系統cpu相關資訊
阿新 • • 發佈:2021-02-06
技術標籤:系統
Linux系統下檢視:
檢視cpu的型號資訊:
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
檢視物理cpu個數:
grep "physical id" /proc/cpuinfo | sort | uniq | wc -l
檢視每個物理cpu的核心數:
grep 'cpu cores' /proc/cpuinfo | uniq | awk -F':' '{print $2}'
檢視cpu的執行緒數:
grep 'processor' /proc/cpuinfo | sort | wc -l
例:
# 檢視cpu的型號資訊
[ [email protected]*** ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
Intel(R) Xeon(R) Gold 6230 CPU @ 2.10GHz
# 有2個物理cpu
[[email protected]*** ~]# grep "physical id" /proc/cpuinfo | sort | uniq | wc -l
2
# 每個物理cpu有20個核心
[[email protected]*** ~]# grep 'cpu cores' /proc/cpuinfo | uniq | awk -F':' '{print $2}'
20
# cpu的匯流排程數
[ [email protected]*** ~]# grep 'processor' /proc/cpuinfo | sort | wc -l
80
由上面的資訊可以得出該伺服器的cpu資訊如下:
cpu型: Intel® Xeon® Gold 6230 CPU @ 2.10GHz
物理cpu個數:2
每個cpu核心數:20
cpu匯流排程數:80
共有2個cpu,每個cpu20個核心,每個核心2個執行緒,共80執行緒。
同時也可以使用dmidecode 檢視cpu資訊
[[email protected]*** ~]# dmidecode -h
Usage: dmidecode [ OPTIONS]
Options are:
-d, --dev-mem FILE Read memory from device FILE (default: /dev/mem)
-h, --help Display this help text and exit
-q, --quiet Less verbose output
-s, --string KEYWORD Only display the value of the given DMI string
-t, --type TYPE Only display the entries of given type
-u, --dump Do not decode the entries
--dump-bin FILE Dump the DMI data to a binary file
--from-dump FILE Read the DMI data from a binary file
--no-sysfs Do not attempt to read DMI data from sysfs files
-V, --version Display the version and exit
# 使用-t引數獲取支援的欄位
[[email protected]*** ~]# dmidecode -t
dmidecode: option requires an argument -- 't'
Type number or keyword expected
Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot
例:
想獲取cpu的核心數:
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.
# SMBIOS implementations newer than version 3.0 are not
# fully supported by this version of dmidecode.
....
Core Count: 20
Core Enabled: 20
Thread Count: 40
...
Core Count: 20
Core Enabled: 20
Thread Count: 40
檢視記憶體資訊:
[[email protected]*** ~]# dmidecode -t memory
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.
# SMBIOS implementations newer than version 3.0 are not
# fully supported by this version of dmidecode.
Handle 0x1000, DMI type 16, 23 bytes
Physical Memory Array
...
Handle 0x1100, DMI type 17, 84 bytes
...
Windows系統下檢視:
開啟工作管理員---->效能
這臺windows機器有1個物理cpu,2個核心,每個核心2個執行緒,總計4個執行緒。
對於cpu來說,執行緒數總是大於或等於核心數的,一個核心最少對應一個執行緒,但通過超線技術,一個核心可以對應兩個執行緒,也就是可以同時執行兩個執行緒。
CPU執行緒數概念僅針對Intel的cpu才有用,因為是通過Intel超執行緒技術實現。而AMD的cpu,只有核心數的概念,沒有執行緒數的概念。