Linux系统下如何查看CPU个数
查看逻辑CPU个数:
#cat /proc/cpuinfo |grep "processor"|sort -u|wc -l
24
查看物理CPU个数:
#grep "physical id" /proc/cpuinfo|sort -u|wc -l
2
#grep "physical id" /proc/cpuinfo|sort -u
physical id : 0
physical id : 1
查看每个物理CPU内核个数:
#grep "cpu cores" /proc/cpuinfo|uniq
cpu cores : 6
每个物理CPU上逻辑CPU个数:
#grep "siblings" /proc/cpuinfo|uniq
siblings : 12
判断是否开启了抄超线程:
如果多个逻辑CPU的"physical id"和"core id"均相同,说明开启了超线程
或者换句话说
逻辑CPU个数 > 物理CPU个数 * CPU内核数 开启了超线程
逻辑CPU个数 = 物理CPU个数 * CPU内核数 没有开启超线程
#!/bin/bash physicalNumber=0 coreNumber=0 logicalNumber=0 HTNumber=0 logicalNumber=$(grep "processor" /proc/cpuinfo|sort -u|wc -l) physicalNumber=$(grep "physical id" /proc/cpuinfo|sort -u|wc -l) coreNumber=$(grep "cpu cores" /proc/cpuinfo|uniq|awk -F':' '{print $2}'|xargs) HTNumber=$((logicalNumber / (physicalNumber * coreNumber))) echo "****** CPU Information ******" echo "Logical CPU Number : ${logicalNumber}" echo "Physical CPU Number : ${physicalNumber}" echo "CPU Core Number : ${coreNumber}" echo "HT Number : ${HTNumber}" echo "*****************************"
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20