Linux中如何擷取CPU資訊

來源:互聯網
上載者:User

我們可以在 /proc/cpuinfo 中擷取需要資訊

1.當前 CPU 的型號

[root@ localhost  ~]# cat /proc/cpuinfo |grep "model name" |uniq

model name      : AMD Opteron(tm) Processor 6140

2.當前 CPU 運行模式

[root@localhost tmp]# getconf LONG_BIT

32

說明當前 CPU 運行在32位環境下

3.當前 CPU 是否支援 64位環境

[root@ localhost  ~]# cat /proc/cpuinfo |grep "lm" |uniq

flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid amd_dcm pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt nodeid_msr npt lbrv svm_lock nrip_save pausefilter

lm指long mode, 支援lm則是64bit 這邊有輸出, 說明是支援 64 位元的 可以將 命令最後的 uniq 替換成 wc -l 來看支援64位的 core 數量

4.物理CPU的個數

physical id 相同的是同一個物理CPU

[root@ localhost  ~]# cat /proc/cpuinfo |grep "physical id" |sort |uniq

physical id     : 0

physical id     : 1

本例中,這台主機有兩個物理 CPU

5.每個物理CPU中的core個數

[root@ localhost  ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq

cpu cores       : 8

每一個物理 CPU 中有 8 個 core 該台主機一共有 16 個 core

查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.