当前位置首页 > CentOS知识

CentOS7.6查看CPU信息

阅读次数:244 次  来源:admin  发布时间:
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位
上一篇:fedora中使用mariadb数据库建库和建表--mariadb数据库服务无法启动?
下一篇:CentOS7中使用yum安装Nginx的方法