Physical id #相同表示為同一個物理CPU
Processor #邏輯CPU
Cpu cores #CPU核數,內核個數
Core id #內核id號
Siblings #每個物理CPU里面的邏輯CPU個數
- 查看CPU型號
[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 8 Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz [root@localhost ~]#
- 查看物理CPU個數
[root@localhost ~]# cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l 8 [root@localhost ~]#
- 查看邏輯CPU個數
[root@localhost ~]# cat /proc/cpuinfo | grep "processor" | wc -l 8 [root@localhost ~]#
- 查看CPU內核數
[root@localhost ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq cpu cores : 1 [root@localhost ~]#
- 查看單個物理CPU封裝的邏輯CPU數量
[root@localhost ~]# cat /proc/cpuinfo | grep "siblings" | uniq siblings : 1 [root@localhost ~]#
- 計算是否開啟超線程
邏輯CPU > 物理CPU x CPU核數 #開啟超線程
邏輯CPU = 物理CPU x CPU核數 #沒有開啟超線程或不支持超線程
- 查看是否超線程
[root@localhost ~]# cat /proc/cpuinfo | grep -e "cpu cores" -e "siblings" | sort | uniq cpu cores : 1 siblings : 1 [root@localhost ~]#
說明:如果cpu cores數量和siblings數量一致,則沒有啟用超線程,否則超線程被啟用。
- 腳本
[root@localhost sh]# vi cpu.sh #!/bin/bash cpuname=$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c) physical=$(cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l) processor=$(cat /proc/cpuinfo | grep "processor" | wc -l) cpucores=$(cat /proc/cpuinfo | grep "cpu cores" | uniq) siblings=$(cat /proc/cpuinfo | grep "siblings" | uniq) echo "* * * * * CPU Information * * * * *" echo "(CPU型號)cpu name : $cpuname" echo "(物理CPU個數)physical id is : $physical" echo "(邏輯CPU個數)processor is : $processor" echo "(CPU內核數)cpu cores is : $cpucores" echo "(單個物理CPU的邏輯CPU數)siblings is : $siblings" [root@localhost sh]#
- 腳本運行效果
[root@localhost sh]# sh cpu.sh * * * * * CPU Information * * * * * (CPU型號)cpu name : 8 Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz (物理CPU個數)physical id is : 8 (邏輯CPU個數)processor is : 8 (CPU內核數)cpu cores is : cpu cores : 1 (單個物理CPU的邏輯CPU數)siblings is : siblings : 1 [root@localhost sh]#
- 查看系統是多少位
[root@localhost sh]# uname -a Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux [root@localhost sh]#
說明:i386 i686為32位;x86_64為64位