CentOS 7.4查看CPU信息(含脚本)

CentOS 7.4查看CPU信息(含脚本)

2018年11月14日 10:51:27 DebugTheLife 阅读数 1779

 版权声明:©来自CSDN博客作者Debug The Life的原创作品,如需转载,请注明出处。 https://blog.csdn.net/zhaoxixc/article/details/84062639

Physical id 	#相同表示为同一个物理CPU
Processor 	#逻辑CPU
Cpu cores 	#CPU核数,内核个数
Core id 	#内核id号
Siblings 	#每个物理CPU里面的逻辑CPU个数
  • 1
  • 2
  • 3
  • 4
  • 5
  • 查看CPU型号
[root@testhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      4  Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz
[root@testhost ~]# 
  • 1
  • 2
  • 3
  • 查看物理CPU个数
[root@testhost ~]# cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l  
2
  • 1
  • 2
  • 查看逻辑CPU个数
[root@testhost ~]# cat /proc/cpuinfo | grep "processor" | wc -l  
4
  • 1
  • 2
  • 查看CPU内核数
[root@testhost ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq  
cpu cores       : 2
  • 1
  • 2
  • 查看单个物理CPU封装的逻辑CPU数量
[root@testhost ~]# cat /proc/cpuinfo | grep "siblings" | uniq  
siblings        : 2
  • 1
  • 2
  • 计算是否开启超线程

逻辑CPU > 物理CPU x CPU核数 #开启超线程
逻辑CPU = 物理CPU x CPU核数 #没有开启超线程或不支持超线程

  • 查看是否超线程
[root@testhost ~]# cat /proc/cpuinfo | grep -e "cpu cores"  -e "siblings" | sort | uniq
cpu cores       : 2
siblings        : 2
  • 1
  • 2
  • 3

说明:如果cpu cores数量和siblings数量一致,则没有启用超线程,否则超线程被启用。

  • 脚本
[root@testhost ~]# cat 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@testhost ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 脚本运行效果
[root@testhost ~]# sh cpu.sh 
* * * * * CPU Information * * * * *
(CPU型号)cpu name :       4  Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz
(物理CPU个数)physical id is : 2
(逻辑CPU个数)processor is : 4
(CPU内核数)cpu cores is : cpu cores   : 2
(单个物理CPU的逻辑CPU数)siblings is : siblings        : 2
[root@testhost ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 扩展
  1. 查看系统是多少位
[root@testhost ~]# uname -a
Linux testhost 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • 1
  • 2

说明:i386 i686为32位;x86_64为64位

  1. 查看CPU是32位还是64位
[root@testhost ~]# cat /proc/cpuinfo | grep lm
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm tsc_adjust arat
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm tsc_adjust arat
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm tsc_adjust arat
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm tsc_adjust arat
  • 1
  • 2
  • 3
  • 4
  • 5

说明:lm: “Long Mode,” which means the chip supports the AMD64 instruction set

转载于:https://my.oschina.net/u/3367404/blog/3067196

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值