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

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

2018年11月14日 10:51:27 DebugTheLife 閱讀數 1779api

 版權聲明:©來自CSDN博客做者Debug The Life的原創做品,如需轉載,請註明出處。 https://blog.csdn.net/zhaoxixc/article/details/84062639bash

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核數 #沒有開啓超線程或不支持超線程ui

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

說明:若是cpu cores數量和siblings數量一致,則沒有啓用超線程,不然超線程被啓用。spa

  • 腳本
[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位.net

  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線程

相關文章
相關標籤/搜索