Linux檢查和收集硬件信息的常用命令總結
作者:尹正傑
版權聲明:原創作品,謝絕轉載!否則將追究法律責任。
Linux基礎真的很重要,基礎不牢,地動山搖。這句話我是聽老男孩創始人冉總說的一句話,起初我也不以為然。直到最近我kafka集群出現丟數據的情況,花了3天時間才查明白原因,是由於我磁盤IO到達瓶頸導致。而這個還是我通過運維同事部署的zabbix監控系統查出來的異常。當我登錄操作系統竟然一時間竟然想不起用啥命令去查看相應的信息,於是我花費半天的時間惡補了一些基礎,把常用的一些基礎命令總結一下。
一.lscpu # 用於查詢CPU信息
[root@node105 ~]# lscpu Architecture: x86_64 #CPU架構 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 20 #邏輯cpu顆數 On-line CPU(s) list: 0-19 Thread(s) per core: 1 #每個CPU插槽核數/每顆物理CPU核數 Core(s) per socket: 10 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel #CPU廠商ID CPU family: 6 Model: 79 Model name: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz Stepping: 1 CPU MHz: 2095.148 #CPU主頻 BogoMIPS: 4190.29 Hypervisor vendor: VMware Virtualization type: full #CPU支持的虛擬化技術 L1d cache: 32K #一級緩存。cpu的L1數據緩存 L1i cache: 32K #一級緩存,L1指令緩存 L2 cache: 256K #二級緩存 L3 cache: 20480K #三級緩存 NUMA node0 CPU(s): 0-9 NUMA node1 CPU(s): 10-19 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx hypervisor lahf_lm 3dnowprefetch epb cat_l3 cdp_l3 xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts [root@node105 ~]#
二. lshw # 用於顯示硬件信息表([root@node105 ~]# yum -y install lshw)
[root@node105 ~]# lshw | more

三.lsblk # 用於列出塊設備的信息
[root@node105 ~]# lsblk

四.lsscsi # 用於列出SCSI的設備信息
[root@node105 ~]# lsscsi

五.fdisk #看硬盤和分區的詳細信息
[root@node105 ~]# fdisk -l

六.ethtool #查看某個網絡接口的詳細信息,例如eth0的詳細參數和指標
[root@kafka116 ~]# ethtool enp7s0f0 #注意,這里的enp7s0f0是網卡的名稱 Settings for enp7s0f0: Supported ports: [ TP ] Supported link modes: 100baseT/Full 1000baseT/Full 10000baseT/Full #支持萬兆全雙工模式 Supported pause frame use: Symmetric Supports auto-negotiation: Yes #支持自適應模式,一般都支持 Supported FEC modes: Not reported Advertised link modes: 100baseT/Full 1000baseT/Full 10000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes #默認使用自適應模式 Advertised FEC modes: Not reported Speed: 10000Mb/s #現在網卡的速度是萬兆Mb/s, Duplex: Full #當前是全雙工模式 Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: Unknown Supports Wake-on: umbg Wake-on: g Current message level: 0x00000007 (7) drv probe link Link detected: yes #表示有網線連接,和路由是通的,這可以使用“ifconfig”或者“ip a”查看操作系統中網卡的是否是UP狀態。 [root@kafka116 ~]#
七.dmidecode #一種可讀的方式dump出機器的DMI(Desktop Management Interface)信息。這些信息包括了硬件以及BIOS,既可以得到當前的配置,也可以得到系統支持的最大配置,比如說支持的最大內存數等。
[root@kafka116 ~]# dmidecode -t bios #查看bios信息 # dmidecode 3.0 Getting SMBIOS data from sysfs. SMBIOS 3.0 present. Handle 0x0000, DMI type 0, 24 bytes BIOS Information Vendor: American Megatrends Inc. Version: 4.1.16 Release Date: 06/21/2018 Address: 0xF0000 Runtime Size: 64 kB ROM Size: 8192 kB Characteristics: PCI is supported BIOS is upgradeable BIOS shadowing is allowed Boot from CD is supported Selectable boot is supported BIOS ROM is socketed EDD is supported 5.25"/1.2 MB floppy services are supported (int 13h) 3.5"/720 kB floppy services are supported (int 13h) 3.5"/2.88 MB floppy services are supported (int 13h) 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: 5.6 Handle 0x0066, DMI type 13, 22 bytes BIOS Language Information Language Description Format: Long Installable Languages: 1 en|US|iso8859-1 Currently Installed Language: en|US|iso8859-1 [root@kafka116 ~]#
八.free #概要查看內存情況,他的數據來自“/etc/meminfo”中
[root@kafka116 ~]# free -h #該參數可以自動幫我們以合適的單位顯示數據的大小 total used free shared buff/cache available Mem: 31G 8.6G 232M 20M 22G 22G Swap: 15G 993M 14G [root@kafka116 ~]# [root@kafka116 ~]# [root@kafka116 ~]# [root@kafka116 ~]# free -m #該參數表示所有的數據都得以Mb為單位顯示 total used free shared buff/cache available Mem: 31867 8791 201 20 22875 22533 Swap: 16063 993 15070 [root@kafka116 ~]# [root@kafka116 ~]#
