1. 程式人生 > 其它 >檢視Linux伺服器硬體資訊

檢視Linux伺服器硬體資訊

一、檢視CPU資訊

CPU資訊常常包括檢視CPU型號資訊,物理CPU個數,每個物理CPU中core的個數(即核數),邏輯CPU個數資訊。預設Linux伺服器中,這些資訊都儲存在/proc/cpuinfo檔案中,通過cat命令結合grep命令我們可以很容易查詢出來。

1、檢視CPU型號資訊

[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

32 Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz

這其中的32是邏輯CPU的個數,Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz是CPU型號資訊及頻率。

2、檢視物理CPU個數

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

2

上面命令執行後,結果為2,這就是物理CPU個數。

3、每個物理CPU中核數

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

cpu cores : 8

可以從結果中看出,每個cpu核數是8。

4、檢視邏輯CPU的個數

[root@localhost ~]# cat /proc/cpuinfo| grep "processor"| wc -l

32

5、整體檢視CPU相關資訊

lscpu

輸出結果:

[root@localhost ~]# lscpu

Architecture: x86_64 #cpu架構

CPU op-mode(s): 32-bit, 64-bit

Byte Order: Little Endian

CPU(s): 32 #邏輯CPU核數

On-line CPU(s) list: 0-31

Thread(s) per core: 2 #每核超執行緒數

Core(s) per socket: 8 #每個cpu核數

Socket(s): 2 #物理cpu個數

NUMA node(s): 2

Vendor ID: GenuineIntel #cpu產商 intel

CPU family: 6

Model: 62

Model name: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz

Stepping: 4

CPU MHz: 1200.000 #cpu主頻

BogoMIPS: 5187.29

Virtualization: VT-x #支援cpu虛擬化技術

L1d cache: 32K

L1i cache: 32K

L2 cache: 256K

L3 cache: 20480K

NUMA node0 CPU(s): 0-7,16-23

NUMA node1 CPU(s): 8-15,24-31

結合上面的資訊,我們需要了解的CPU的物理數,CPU核數,物理核數,超執行緒數概念關係如下:

CPU總核數(16) = 物理CPU個數(2) * 每顆物理CPU的核數(8)

CPU總邏輯數(32) = 物理CPU個數(2) * 每顆物理CPU的核數(8) * 超執行緒數(2)

二、檢視記憶體資訊

在Linux系統中檢視linux記憶體的大小時,我們最長用到的命令就是free命令。free命令可以檢視當前記憶體大小及使用情況,但如果要檢視更多關於記憶體的物理資訊,例如記憶體條數,記憶體插槽數,記憶體速率等資訊,我們就需要dmidecode命令。

dmidecode命令工具用於獲取伺服器的硬體資訊,不用到機房開啟機箱檢視裝置型號,使用該命令來查詢硬體詳細資訊。

1、檢視記憶體使用情況

[root@localhost ~]# free -h

total used free shared buffers cached

Mem: 62G 60G 2.7G 1.2M 483M 56G

-/+ buffers/cache: 3.1G 59G

Swap: 31G 0B 31G

-h以人類可讀的方式顯示,即後邊會自動帶上單位。

2、查詢記憶體(RAM)資訊 通過以下命令,可以查詢機器最大支援的記憶體總量**

[root@localhost ~]# dmidecode -t 16

dmidecode 2.12

SMBIOS 2.7 present.

Handle 0x002B, DMI type 16, 23 bytes

Physical Memory Array

Location: System Board Or Motherboard

Use: System Memory

Error Correction Type: Multi-bit ECC

Maximum Capacity: 768 GB

Error Information Handle: Not Provided

Number Of Devices: 12

這裡可以檢視到當前伺服器允許擴容的最大記憶體,從輸出結果可以看出,該機器理論上支援的最大記憶體為768G。

3、檢視可用記憶體大小

首先我們可以通過cat命令檢視/proc/meminfo檔案內容獲取記憶體大小資訊。

[root@localhost ~]# grep MemTotal /proc/meminfo

MemTotal: 65890032 kB

4、檢視記憶體大小、記憶體數、記憶體插槽數

[root@localhost ~]# dmidecode|grep -P -A5 "Memory Device" |grep Size

Size: 16384 MB

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: 16384 MB

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: 16384 MB

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: 16384 MB

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

Size: No Module Installed

從上面的結果可以看出,插槽總數為24,記憶體數量為4,總大小為4 x 16384 MB = 65536 MB ,65536 MB /1024 = 64G。

5、檢視記憶體速率

[root@localhost ~]# dmidecode|grep -A16 "Memory Device"|grep 'Speed' | grep -v "Unknown"

Speed: 1600 MHz

Speed: 1600 MHz

Speed: 1600 MHz

Speed: 1600 MHz

從上面的結果我們們可以看出,所有記憶體的速率都是1600 MHz。

三、檢視硬碟資訊

檢視掛接的分割槽狀態

1、檢視掛接的分割槽狀態

[root@localhost ~]# fdisk -l |grep Disk

Disk /dev/sda: 1197.8 GB, 1197759004672 bytes

Disk identifier: 0x0005efcd

2、檢視硬碟和分割槽分佈

[root@localhost ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 1.1T 0 disk

├─sda1 8:1 0 500M 0 part /boot

├─sda2 8:2 0 31.3G 0 part [SWAP]

└─sda3 8:3 0 1.1T 0 part /

sr0 11:0 1 1024M 0 rom

3、檢視硬碟和分割槽的詳細資訊

[root@localhost ~]# fdisk -l

Disk /dev/sda: 1197.8 GB, 1197759004672 bytes

255 heads, 63 sectors/track, 145619 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0005efcd

Device Boot Start End Blocks Id System

/dev/sda1 * 1 64 512000 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 64 4144 32768000 82 Linux swap / Solaris

/dev/sda3 4144 145620 1136405504 83 Linux

4、檢視掛接的分割槽狀態

[root@localhost ~]# mount | column -t

/dev/sda3 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

none on /sys/kernel/config type configfs (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

nfsd on /proc/fs/nfsd type nfsd (rw)

5、檢視硬碟使用情況

[root@localhost ~]# df -hT

Filesystem Type Size Used Avail Use% Mounted on

/dev/sda3 ext4 1.1T 355G 658G 36% /

tmpfs tmpfs 32G 68K 32G 1% /dev/shm

/dev/sda1 ext4 477M 40M 412M 9% /boot

四、檢視網絡卡資訊

1、檢視網絡卡硬體資訊

[root@localhost ~]# lspci | grep -i 'eth'

02:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)

02:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)

07:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)

07:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)

檢視系統的所有網路介面

ifconfig -a

ip link show

檢視某個網路介面的詳細資訊,例如eth0的詳細引數和指標

[root@localhost ~]# ethtool eth0

Settings for eth0:

Supported ports: [ TP ]

Supported link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

1000baseT/Full

Supported pause frame use: Symmetric

Supports auto-negotiation: Yes

Advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

1000baseT/Full

Advertised pause frame use: Symmetric

Advertised auto-negotiation: Yes

Speed: 1000Mb/s

Duplex: Full

Port: Twisted Pair

PHYAD: 1

Transceiver: internal

Auto-negotiation: on

MDI-X: off (auto)

Supports Wake-on: pumbg

Wake-on: g

Current message level: 0x00000007 (7)

drv probe link

Link detected: yes

六、其它硬體資訊

dmidecode命令不僅僅可以檢視記憶體等資訊,另外這個命令強大到幾乎可以查任何硬體資訊 包括裝置型號、bios 、cpu、主機板 、處理器、記憶體、快取詳細資訊等等都例舉出來。

1、檢視伺服器型號、序列號

[root@localhost ~]# dmidecode|grep "System Information" -A9|egrep "Manufacturer|Product|Serial"

Manufacturer: FUJITSU

Product Name: PRIMERGY RX200 S8

Serial Number: MANS012234

2、檢視主機板型號

[root@localhost ~]# dmidecode |grep -A16 "System Information$"

System Information

Manufacturer: FUJITSU

Product Name: PRIMERGY RX200 S8

Version: GS01

Serial Number: MANS012234

UUID: 2B5C344E-4406-E411-9EFE-70E284092502

Wake-up Type: Power Switch

SKU Number: S26361-K1455-Vxxx

Family: SERVER

Handle 0x0002, DMI type 2, 15 bytes

Base Board Information

Manufacturer: FUJITSU

Product Name: D3302-A1

Version: S26361-D3302-A100 GS02

Serial Number: 5556W06001G4280004BJ0D1

Asset Tag:

3、檢視BIOS資訊

[root@localhost ~]# dmidecode -t bios

dmidecode 2.12

SMBIOS 2.7 present.

Handle 0x0000, DMI type 0, 24 bytes

BIOS Information

Vendor: FUJITSU // American Megatrends Inc.

Version: V4.6.5.4 R1.8.0 for D3302-A1x

Release Date: 06/23/2014

Address: 0xF0000

Runtime Size: 64 kB

ROM Size: 13248 kB

Characteristics:

PCI is supported

BIOS is upgradeable

BIOS shadowing is allowed

Boot from CD is supported

Selectable boot is supported

EDD is supported

Print screen service is supported (int 5h)

Serial services are supported (int 14h)

Printer services are supported (int 17h)

ACPI is supported

USB legacy is supported

BIOS boot specification is supported

Targeted content distribution is supported

UEFI is supported

BIOS Revision: 1.8

Handle 0x0114, DMI type 13, 22 bytes

BIOS Language Information

Language Description Format: Abbreviated

Installable Languages: 1

enUS

Currently Installed Language: enUS
————————————————
原文連結:https://blog.csdn.net/weixin_28729843/article/details/111930354