在Linux上查詢物理機信息-不用去拆機器了


最近需要因為公司需要,需要查詢公司物理機的信息,整個整理下來,總結了這么一篇文章,歡迎大家補充。

Linux 系統獲取物理機器的信息:

我們可以通過 lshw 或者 dmidecode 來獲取服務器對應的物理機信息。

我們這里還是推薦使用 dmidecode 來獲取。

安裝 dmidecode

yum install -y dmidecode

一、查看系統信息(包含機器型號)

1.1 查看機型和品牌

[root@djx ~]# dmidecode  --type system
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.
# SMBIOS implementations newer than version 3.1.1 are not
# fully supported by this version of dmidecode.

Handle 0x0100, DMI type 1, 27 bytes
System Information
	Manufacturer: Dell Inc.         # 機器品牌
	Product Name: PowerEdge R740    # 機器型號
	Version: Not Specified
	Serial Number: FW89BX2
	UUID: 4c4c4534-0057-3810-8019-c6c04f425832
	Wake-up Type: Power Switch
	SKU Number: SKU=NotProvided;ModelName=PowerEdge R740
	Family: PowerEdge
#直接獲取機型和品牌 dmidecode  --type system |grep -E 'Manufacturer|Product Name'  
#lshw|head  #可以獲取物理機機器型號和

二、查看CPU 信息

2.1 查看CPU 型號

也可以使用 cat /proc/cpuinfo |grep "model name"|head -1

[root@djx ~]# dmidecode --type processor   
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.
# SMBIOS implementations newer than version 3.1.1 are not
# fully supported by this version of dmidecode.

Handle 0x0400, DMI type 4, 48 bytes
Processor Information
	Socket Designation: CPU1
	Type: Central Processor
	Family: Xeon
	Manufacturer: Intel
	ID: 57 06 04 00 FF F5 EB BF
	Signature: Type 0, Family 6, Model 85, Stepping 7
	Flags:
		FPU (Floating-point unit on-chip)
		VME (Virtual mode extension)
		DE (Debugging extension)
		PSE (Page size extension)
		TSC (Time stamp counter)
		MSR (Model specific registers)
		PAE (Physical address extension)
		MCE (Machine check exception)
		CX8 (CMPXCHG8 instruction supported)
		APIC (On-chip APIC hardware supported)
		SEP (Fast system call)
		MTRR (Memory type range registers)
		PGE (Page global enable)
		MCA (Machine check architecture)
		CMOV (Conditional move instruction supported)
		PAT (Page attribute table)
		PSE-36 (36-bit page size extension)
		CLFSH (CLFLUSH instruction supported)
		DS (Debug store)
		ACPI (ACPI supported)
		MMX (MMX technology supported)
		FXSR (FXSAVE and FXSTOR instructions supported)
		SSE (Streaming SIMD extensions)
		SSE2 (Streaming SIMD extensions 2)
		SS (Self-snoop)
		HTT (Multi-threading)
		TM (Thermal monitor supported)
		PBE (Pending break enabled)
	Version: Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz  # CPU 型號
	Voltage: 1.8 V
	External Clock: 9600 MHz
	Max Speed: 4000 MHz
	Current Speed: 2100 MHz
	Status: Populated, Enabled
	Upgrade: Socket LGA2011
	L1 Cache Handle: 0x0700
	L2 Cache Handle: 0x0701
	L3 Cache Handle: 0x0702
	Serial Number: Not Specified
	Asset Tag: Not Specified
	Part Number: Not Specified
	Core Count: 8
	Core Enabled: 8
	Thread Count: 16
	Characteristics:
		64-bit capable
		Multi-Core
		Hardware Thread
		Execute Protection
		Enhanced Virtualization
		Power/Performance Control

Handle 0x0401, DMI type 4, 48 bytes
Processor Information
	Socket Designation: CPU2
	Type: Central Processor
	Family: Unknown
	Manufacturer: Not Specified
	ID: 00 00 00 00 00 00 00 00
	Version: Not Specified
	Voltage: Unknown
	External Clock: Unknown
	Max Speed: 4000 MHz
	Current Speed: Unknown
	Status: Unpopulated
	Upgrade: Socket LGA2011
	L1 Cache Handle: Not Provided
	L2 Cache Handle: Not Provided
	L3 Cache Handle: Not Provided
	Serial Number: Not Specified
	Asset Tag: Not Specified
	Part Number: Not Specified
	Characteristics: None
#  dmidecode --type processor  |grep 'Version'

2.2 查看CPU的物理數量

cat  /proc/cpuinfo |grep "physical id"|sort|uniq|wc -l

2.3 查看 CPU核心數量(非邏輯CPU)

grep "cpu cores" /proc/cpuinfo | uniq | awk -F ":" "{print $2}"

2.4 查看 CPU數量(邏輯)

cat  /proc/cpuinfo |grep 'processor'|wc -l

2.5 查看CPU的支持的最大內存

我這個沒有找到,可以從 cpu 型號進行查詢。 直接百度搜索該CPU信息,然后查看該 cpu 的參數。

三、查詢主板信息

3.1 查詢主板型號

[root@djx ~]#  dmidecode --type baseboard|head 
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.
# SMBIOS implementations newer than version 3.1.1 are not
# fully supported by this version of dmidecode.

Handle 0x0200, DMI type 2, 8 bytes
Base Board Information
	Manufacturer: Dell Inc.   # 主板品牌
	Product Name: 014X06   # 生產號

3.2 查看主板可以支持的最大內存

dmidecode |grep "Maximum Capacity"  / dmidecode --type memory |head 

四、查詢磁盤相關的東西

4.1 磁盤大小

 fdisk  -l

4.2 磁盤塊數

 fdisk  -l
 # 這個也不精確,建議直接去物理機上面看,我們下面提供戴爾服務器如何查詢的方法。

4.3 是否啟用raid

lspci   |grep  -i raid  
# 這個不精確 建議安裝特定的軟件(不同機器不一樣)進行查看

4.4 查看當前的 raid版本

要根據官方的文檔去安裝驅動進行查詢。

五、查詢內存條信息

5.1 當前內存單條大小

dmidecode --type memory |grep "Size"

當前多少根內存條

dmidecode --type memory |grep "Size"|grep 'MB'|wc -l

當前內存條型號

dmidecode --type memory |grep "Part Number"

可以擴展內存條數目

dmidecode --type memory |grep "Number Of Devices"
# 這個數據也是僅僅供參考,因為 部分服務器,單物理CPU 是可以插8根內存條,然后2個物理CPU是可以插12根內存條的,這個需要查看服務器的官方文檔。

可以擴展內存總大小

dmidecode |grep "Maximum Capacity" 
# 這個值也不是很准,跟內存條的類型與插入的內存條有關。 建議查詢官方文檔

六、 擴展

6.1 擴展信息

戴爾如何獲取服務碼:機器前面顯示屏的字符串(7位)/或者快速服務代碼。

惠普如何獲取服務碼: 機器上的SN 碼 。HP 查詢是否過保網站: https://support.hpe.com/hpsc/wc/public/home

戴爾監控物理設備一般使用的是 IDRAC (遠程)及 OMSASAE

內存條類型區分

內存條類型分為 LRDIMMRDIMMUDIMM,一般來說LRDIMM 的內存條容量更大些。同一個機型,我們建議使用相同類型的內存條。一般只只有顆CPU的話,只能支持一半的內存條數。如何查詢內存條的安裝方法以及服務器支持的最大內存。我們一般從官方文檔查詢, 一般位於官方文檔中的用戶手冊,技術規格-內存規格 ,安裝方法為 安裝文檔里面內存內容

6.2 戴爾服務器查詢是否使用了 raid

需要安裝 PERC官方文檔。 從戴爾支持站點下載Linux PERCCLI實用程序。選擇您的系統,然后按類別SAS RAID或通過使用關鍵字PERCCLI篩選驅動程序和下載

# 查看是否使用了raid,raid幾
perccli /c0/v0 show all
# 查看物理磁盤數
perccli /c0/eall/sall show


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM