Shell實現(xiàn)識別物理cpu個數(shù)、核心數(shù)
如何識別物理cpu個數(shù),幾個核,是超線程還是多核心
判斷依據(jù):
1.具有相同core id的cpu是同一個core的超線程。
2.具有相同physical id的cpu是同一顆cpu封裝的線程或者cores。
英文版:
1.Physical id and core id are not necessarily consecutive but they are unique. Any cpu with the same core id are hyperthreads in the same core.
2.Any cpu with the same physical id are threads or cores in the same physical socket.
實例:
LunarPages的CPU信息:
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 6006.73
processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 5999.40
processor : 2
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
cache size : 2048 KB
physical id : 3
siblings : 2
core id : 3
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 5999.08
processor : 3
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
cache size : 2048 KB
physical id : 3
siblings : 2
core id : 3
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 5999.55
顯示4個邏輯CPU,通過physical id ,前面兩個邏輯cpu的相同,后面兩個的相同,所以有兩個物理CPU。前面兩個的 core id相同,后面的兩個core ID相同,說明這兩個CPU都是單核。也就是說兩個單核cpu,啟用了超線程技術。
通過intel的cpu的參數(shù)可以初步判斷 使用的是兩個 Xeon奔騰4CPU ,有點差。。。。
如何獲得CPU的詳細信息:
linux命令:cat /proc/cpuinfo
用命令判斷幾個物理CPU,幾個核等:
邏輯CPU個數(shù):
# cat /proc/cpuinfo | grep “processor” | wc -l
物理CPU個數(shù):
# cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l
每個物理CPU中Core的個數(shù):
# cat /proc/cpuinfo | grep “cpu cores” | wc -l
是否為超線程?
如果有兩個邏輯CPU具有相同的”core id”,那么超線程是打開的。
每個物理CPU中邏輯CPU(可能是core, threads或both)的個數(shù):
# cat /proc/cpuinfo | grep “siblings”
其他特征:
目前intel新的多核心cpu都會在后面顯示具體的型號數(shù)字,例如:
model name : Intel(R) Xeon(R) CPU X3230 @ 2.66GHz
說明是 Xeon 3230的cpu,而不顯示型號的具體數(shù)字的,大部分都是奔騰的CPU
很多主機商都騙人,用奔騰的cpu,卻說是多核心的CPU。
探針看到的數(shù)據(jù):
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
沒有具體的型號,緩存1M,一般都是奔騰系列的cpu,或者是intel假雙核的cpu,具體要根據(jù)上面說的去判斷。新的多核心cpu都能看到具體的型號。
另外多核心的xeon的CPU,一般主頻都不高,達到2.8和3.0的只有很少的幾個高端CPU型號,一般主機商不會用這么好的
相關文章
通過shell腳本對mysql的增刪改查及my.cnf的配置
這篇文章主要介紹了通過shell腳本對mysql的增刪改查及my.cnf的配置,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-07-07Linux中SELinux、Shell簡介、touch命令的應用小結
SELinux(Security-Enhanced Linux)是美國國家安全局(NSA)對于強制訪問控制的實現(xiàn),是Linux歷史上最杰出的新安全子系統(tǒng),這篇文章主要介紹了Linux中SELinux、Shell簡介、touch命令的應用知識總結,需要的朋友可以參考下2023-02-02解決VirtualBox中Ubuntu 14.04屏幕分辨率不能設置的問題
下面小編就為大家?guī)硪黄鉀QVirtualBox中Ubuntu 14.04屏幕分辨率不能設置的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05普通用戶啟動supervisor報HTTP錯誤(strace)解決分析
這篇文章主要為大家介紹了普通用戶啟動supervisor報HTTP錯誤strace的問題解決分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-07-07Shell腳本實現(xiàn)監(jiān)控iptables運行狀態(tài)
這篇文章主要介紹了Shell腳本實現(xiàn)監(jiān)控iptables運行狀態(tài),本文直接給出實現(xiàn)代碼,需要的朋友可以參考下2014-12-12