Linux检查和收集硬件信息的常用命令总结

                   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 

Linux检查和收集硬件信息的常用命令总结

三.lsblk    # 用于列出块设备的信息

[root@node105 ~]# lsblk 

Linux检查和收集硬件信息的常用命令总结

四.lsscsi   # 用于列出SCSI的设备信息

[root@node105 ~]# lsscsi 

Linux检查和收集硬件信息的常用命令总结

五.fdisk    #看硬盘和分区的详细信息

[root@node105 ~]# fdisk -l

Linux检查和收集硬件信息的常用命令总结

六.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 ~]#