linux 查看系統硬件信息

cat /proc/cpuinfo

判斷依據:
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.
 
echo "logical CPU number:"
#邏輯CPU個數
cat /proc/cpuinfo | grep "processor" | wc -l
 
echo "physical CPU number:"
#物理CPU個數:
cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l
 
echo "core number in a physical CPU:"
#每個物理CPU中Core的個數:
cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F: '{print $2}'
#查看core id的數量,即爲所有物理CPU上的core的個數
cat /proc/cpuinfo | grep "core id" | uniq |  wc -l
 
#是否爲超線程?
#如果有兩個邏輯CPU具有相同的”core id”,那麼超線程是打開的。或者siblings數目比cpu cores數目大。
#每個物理CPU中邏輯CPU(可能是core, threads或both)的個數:
cat /proc/cpuinfo | grep "siblings"
 
 
/proc/cpuinfo 文件包含系統上每個處理器的數據段落。/proc/cpuinfo 描述中有 6 個條目適用於多內核和超線程(HT)技術檢查:processor, vendor id, physical id, siblings, core id 和 cpu cores。
processor 條目包括這一邏輯處理器的唯一標識符。
physical id 條目包括每個物理封裝的唯一標識符。
core id 條目保存每個內核的唯一標識符。
siblings 條目列出了位於相同物理封裝中的邏輯處理器的數量。
cpu cores 條目包含位於相同物理封裝中的內核數量。
如果處理器爲英特爾處理器,則 vendor id 條目中的字符串是 GenuineIntel。
 
1.擁有相同 physical id 的所有邏輯處理器共享同一個物理插座。每個 physical id 代表一個唯一的物理封裝。
2.Siblings 表示位於這一物理封裝上的邏輯處理器的數量。它們可能支持也可能不支持超線程(HT)技術。
3.每個 core id 均代表一個唯一的處理器內核。所有帶有相同 core id 的邏輯處理器均位於同一個處理器內核上。
4.如果有一個以上邏輯處理器擁有相同的 core id 和 physical id,則說明系統支持超線程(HT)技術。
5.如果有兩個或兩個以上的邏輯處理器擁有相同的 physical id,但是 core id 不同,則說明這是一個多內核處理器。cpu cores 條目也可以表示是否支持多內核。
 
判斷CPU是否64位,檢查cpuinfo中的flags區段,看是否有lm標識。
Are the processors 64-bit?  
A 64-bit processor will have lm ("long mode") in the flags section of cpuinfo. A 32-bit processor will not.




cat /proc/meminfo   讀出的內核信息進行解釋,

下篇文章會簡單對讀出該信息的代碼進行簡單的分析。
 
MemTotal:       507480 kB
 
MemFree:         10800 kB
Buffers:         34728 kB
Cached:          98852 kB
SwapCached:        128 kB
Active:         304248 kB
Inactive:        46192 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       507480 kB
LowFree:         10800 kB
SwapTotal:      979956 kB
SwapFree:       941296 kB
Dirty:              32 kB
Writeback:           0 kB
AnonPages:      216756 kB
Mapped:          77560 kB
Slab:            22952 kB
SReclaimable:    15512 kB
SUnreclaim:       7440 kB
PageTables:       2640 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   1233696 kB
Committed_AS:   828508 kB
VmallocTotal:   516088 kB
VmallocUsed:      5032 kB
VmallocChunk:   510580 kB
 
相應選項中文意思想各位高手已經知道,如何翻譯有什麼錯誤,請務必指出:
    MemTotal: 所有可用RAM大小 (即物理內存減去一些預留位和內核的二進制代碼大小)
     MemFree: LowFree與HighFree的總和,被系統留着未使用的內存
     Buffers: 用來給文件做緩衝大小
      Cached: 被高速緩衝存儲器(cache memory)用的內存的大小(等於 diskcache minus SwapCache ).
  SwapCached:被高速緩衝存儲器(cache memory)用的交換空間的大小
             已經被交換出來的內存,但仍然被存放在swapfile中。用來在需要的時候很快的被替換而不需要再次打開I/O端口。
      Active: 在活躍使用中的緩衝或高速緩衝存儲器頁面文件的大小,除非非常必要否則不會被移作他用.
    Inactive: 在不經常使用中的緩衝或高速緩衝存儲器頁面文件的大小,可能被用於其他途徑.
   HighTotal:
    HighFree: 該區域不是直接映射到內核空間。內核必須使用不同的手法使用該段內存。
    LowTotal:
     LowFree: 低位可以達到高位內存一樣的作用,而且它還能夠被內核用來記錄一些自己的數據結構。Among many
              other things, it is where everything from the Slab is
              allocated.  Bad things happen when you're out of lowmem.
        
   SwapTotal: 交換空間的總大小
    SwapFree: 未被使用交換空間的大小
    Dirty: 等待被寫回到磁盤的內存大小。
    
   Writeback: 正在被寫回到磁盤的內存大小。
 
   AnonPages:未映射頁的內存大小
 
   Mapped: 設備和文件等映射的大小。
 
   Slab: 內核數據結構緩存的大小,可以減少申請和釋放內存帶來的消耗。
   SReclaimable:可收回Slab的大小
 
   SUnreclaim:不可收回Slab的大小(SUnreclaim+SReclaimable=Slab)
 
   PageTables:管理內存分頁頁面的索引表的大小。
 
   NFS_Unstable:不穩定頁表的大小
 
   Bounce:
 CommitLimit: Based on the overcommit ratio ('vm.overcommit_ratio'),
              this is the total amount of  memory currently available to
              be allocated on the system. This limit is only adhered to
              if strict overcommit accounting is enabled (mode 2 in
              'vm.overcommit_memory').
              The CommitLimit is calculated with the following formula:
              CommitLimit = ('vm.overcommit_ratio' * Physical RAM) + Swap
              For example, on a system with 1G of physical RAM and 7G
              of swap with a `vm.overcommit_ratio` of 30 it would
              yield a CommitLimit of 7.3G.
              For more details, see the memory overcommit documentation
              in vm/overcommit-accounting.
            
Committed_AS: The amount of memory presently allocated on the system.
              The committed memory is a sum of all of the memory which
              has been allocated by processes, even if it has not been
              "used" by them as of yet. A process which malloc()'s 1G
              of memory, but only touches 300M of it will only show up
              as using 300M of memory even if it has the address space
              allocated for the entire 1G. This 1G is memory which has
              been "committed" to by the VM and can be used at any time
              by the allocating application. With strict overcommit
              enabled on the system (mode 2 in 'vm.overcommit_memory'),
              allocations which would exceed the CommitLimit (detailed
              above) will not be permitted. This is useful if one needs
              to guarantee that processes will not fail due to lack of
              memory once that memory has been successfully allocated.
VmallocTotal: 可以vmalloc虛擬內存大小
VmallocUsed: 已經被使用的虛擬內存大小。
VmallocChunk: largest contigious block of vmalloc area which is free


三)查看硬盤分區信息

使用下面的命令,可以看到當前硬盤的分區信息,以及容量大小、已使用的空間和剩餘空間大小,還可以查看每個分區的掛載點:

#df -lh

(四)查看硬盤的型號信息

可以使用下面的命令顯示物理硬盤的個數以及對應的接口,還有硬盤的具體型號信息:

         #cat /proc/scsi/scsi

查看硬盤容量

         #fdisk -l

df -ah 還是顯示第一個硬盤的分區信息。

2,查看板卡信息:cat /proc/pci
3,查看USB設備:cat /proc/bus/usb/devices
4,查看PCI信息:lspci (相比cat /proc/pci更直觀)
5,查看內存信息:cat /proc/meminfo
6,查看鍵盤和鼠標:cat /proc/bus/input/devices
7,查看系統硬盤信息和使用情況:fdisk & disk – l& df
8,用硬件檢測程序kuduz探測新硬件:service kudzu start ( or restart)
9,查看各設備的中斷請求(IRQ):cat /proc/interrupts
10,查看啓動硬件檢測信息日誌:dmesg more /var/log/dmesguname -auptime 



參考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章