使用 ethtool 监控接口和收发器

ethtool 命令使您能够查询或控制网络驱动程序和硬件设置,并将设备名称(例如 swp1)作为参数。当设备名称是唯一参数时,ethtool 会打印网络设备设置。有关详细信息,请参阅 man ethtool(8)

NVIDIA 建议使用 l1-show 命令来监控以太网数据;请参阅第 1 层故障排除

监控接口状态

要检查接口的状态,请运行 ethtool <interface> 命令

cumulus@switch:~$ ethtool swp1
Settings for swp1:
        Supported ports: [ FIBRE ]
        Supported link modes:   1000baseT/Full
                                10000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: No
        Advertised link modes:  1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Speed: 10000Mb/s
        Duplex: Full
        Port: FIBRE
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: off
        Current message level: 0x00000000 (0)

Link detected: yes

交换机硬件包括活动端口设置ethtool <interface> 的输出显示内核中的端口设置。switchd 进程使硬件和内核在重要的端口设置(速度、自动协商和链路检测)方面保持同步。但是,ethtool 中的某些字段(例如“支持的链路模式”和“通告的链路模式”)不会根据端口中的实际模块进行更新,并且可能会显示不正确或误导性的结果。

要查询接口统计信息,请运行 ethtool -S <interface> 命令

cumulus@switch:~$ ethtool -S swp1
NIC statistics:
     rx_queue_0_packets: 5
     rx_queue_0_bytes: 300
     rx_queue_0_drops: 0
     rx_queue_0_xdp_packets: 0
     rx_queue_0_xdp_tx: 0
     rx_queue_0_xdp_redirects: 0
     rx_queue_0_xdp_drops: 0
     rx_queue_0_kicks: 1
     tx_queue_0_packets: 144957
     tx_queue_0_bytes: 10546468
     tx_queue_0_xdp_tx: 0
     tx_queue_0_xdp_tx_drops: 0
     tx_queue_0_kicks: 144950

查看和清除接口计数器

接口计数器提供有关接口的信息。当您运行 cl-netstatifconfigcat /proc/net/dev 时,您可以查看此信息。您还可以运行 sudo cl-netstat -c 来保存或清除接口计数器。

cumulus@switch:~$ sudo cl-netstat
Kernel Interface table
Iface            MTU    RX_OK    RX_ERR    RX_DRP    RX_OVR    TX_OK    TX_ERR    TX_DRP    TX_OVR  Flg
-------------  -----  -------  --------  --------  --------  -------  --------  --------  --------  -----
lo             65536   185932         0         0         0   185932         0         0         0  LRU
eth0            1500   151883         0         0         0    13504         0         0         0  BMRU
swp1            9216        5         0         5         0   144986         0         0         0  BMsRU
swp2            9216        5         0         5         0   144988         0         0         0  BMsRU
swp3            9216        5         0         5         0   144944         0         0         0  BMsRU
swp49           9216   502662         0         5         0   502629         0         0         0  BMsRU
swp50           9216   507636         0         5         0   507666         0         0         0  BMsRU
swp51           9216   749122         0         5         0   794080         0         0         0  BMRU
swp52           9216   216057         0         5         0   212567         0         0         0  BMRU
bond1           9216        0         0         0         0   144942         0         0         0  BMmRU
bond2           9216        0         0         0         0   144944         0         0         0  BMmRU
bond3           9216        0         0         0         0   144944         0         0         0  BMmRU
br_default      9216     5072         0         0         0     5074         0         0         0  BMRU
mgmt           65575     3365         0         0         0        0         0       936         0  OmRU
peerlink        9216  1010288         0         0         0  1010295         0         0         0  BMmRU
peerlink.4094   9216   506672         0         0         0   506668         0         0         0  BMRU
vlan10          9216     1687         0         0         0     1687         0         0         0  BMRU
vlan10-v0       9216     1678         0         0         0     1677         0         0         0  BMRU
vlan20          9216     1688         0         0         0     1688         0         0         0  BMRU
vlan20-v0       9216     1678         0         0         0     1677         0         0         0  BMRU
vlan30          9216     1687         0         0         0     1689         0         0         0  BMRU
vlan30-v0       9216     1678         0         0         0     1678         0         0         0  BMRU
cumulus@switch:~$ sudo cl-netstat -c
Cleared counters

要查看 cl-netstat 命令选项,请运行 cl-netstat -h 命令。

某些服务(例如MLAGDHCP)可能会导致丢包计数器按预期递增,并且不会在交换机上引起问题。

监控交换机端口硬件信息

要查看特定端口中模块的硬件功能和测量信息,请使用 ethtool -m 命令。如果模块支持数字光监控(输出中 Optical diagnostics support 字段为Yes),则光功率级别和阈值也会显示在标准硬件详细信息下方。

在下面的示例输出中,您可以看到此模块是 JDSU 制造的 1000BASE-SX 短距离光模块,零件号为 PLRXPL-VI-S24-22。输出的后半部分显示了 Tx 功率级别(Laser output power)和 Rx 功率(Receiver signal average optical power)、温度、电压和报警阈值设置的当前读数。

cumulus@switch$ ethtool -m swp3
        Identifier                                : 0x03 (SFP)
        Extended identifier                       : 0x04 (GBIC/SFP defined by 2-wire interface ID)
        Connector                                 : 0x07 (LC)
        Transceiver codes                         : 0x00 0x00 0x00 0x01 0x20 0x40 0x0c 0x05
        Transceiver type                          : Ethernet: 1000BASE-SX
        Transceiver type                          : FC: intermediate distance (I)
        Transceiver type                          : FC: Shortwave laser w/o OFC (SN)
        Transceiver type                          : FC: Multimode, 62.5um (M6)
        Transceiver type                          : FC: Multimode, 50um (M5)
        Transceiver type                          : FC: 200 MBytes/sec
        Transceiver type                          : FC: 100 MBytes/sec
        Encoding                                  : 0x01 (8B/10B)
        BR, Nominal                               : 2100MBd
        Rate identifier                           : 0x00 (unspecified)
        Length (SMF,km)                           : 0km
        Length (SMF)                              : 0m
        Length (50um)                             : 300m
        Length (62.5um)                           : 150m
        Length (Copper)                           : 0m
        Length (OM3)                              : 0m
        Laser wavelength                          : 850nm
        Vendor name                               : JDSU
        Vendor OUI                                : 00:01:9c
        Vendor PN                                 : PLRXPL-VI-S24-22
        Vendor rev                                : 1
        Optical diagnostics support               : Yes
        Laser bias current                        : 21.348 mA
        Laser output power                        : 0.3186 mW / -4.97 dBm
        Receiver signal average optical power     : 0.3195 mW / -4.96 dBm
        Module temperature                        : 41.70 degrees C / 107.05 degrees F
        Module voltage                            : 3.2947 V
        Alarm/warning flags implemented           : Yes
        Laser bias current high alarm             : Off
        Laser bias current low alarm              : Off
        Laser bias current high warning           : Off
        Laser bias current low warning            : Off
        Laser output power high alarm             : Off
        Laser output power low alarm              : Off
        Laser output power high warning           : Off
        Laser output power low warning            : Off
        Module temperature high alarm             : Off
        Module temperature low alarm              : Off
        Module temperature high warning           : Off
        Module temperature low warning            : Off
        Module voltage high alarm                 : Off
        Module voltage low alarm                  : Off
        Module voltage high warning               : Off
        Module voltage low warning                : Off
        Laser rx power high alarm                 : Off
        Laser rx power low alarm                  : Off
        Laser rx power high warning               : Off
        Laser rx power low warning                : Off
        Laser bias current high alarm threshold   : 10.000 mA
        Laser bias current low alarm threshold    : 1.000 mA
        Laser bias current high warning threshold : 9.000 mA
         Laser bias current low warning threshold  : 2.000 mA
        Laser output power high alarm threshold   : 0.8000 mW / -0.97 dBm
        Laser output power low alarm threshold    : 0.1000 mW / -10.00 dBm
        Laser output power high warning threshold : 0.6000 mW / -2.22 dBm
        Laser output power low warning threshold  : 0.2000 mW / -6.99 dBm
        Module temperature high alarm threshold   : 90.00 degrees C / 194.00 degrees F
        Module temperature low alarm threshold    : -40.00 degrees C / -40.00 degrees F
        Module temperature high warning threshold : 85.00 degrees C / 185.00 degrees F
        Module temperature low warning threshold  : -40.00 degrees C / -40.00 degrees F
        Module voltage high alarm threshold       : 4.0000 V
        Module voltage low alarm threshold        : 0.0000 V
        Module voltage high warning threshold     : 3.6450 V
        Module voltage low warning threshold      : 2.9550 V
        Laser rx power high alarm threshold       : 1.6000 mW / 2.04 dBm
        Laser rx power low alarm threshold        : 0.0100 mW / -20.00 dBm
        Laser rx power high warning threshold     : 1.0000 mW / 0.00 dBm
        Laser rx power low warning threshold      : 0.0200 mW / -16.99 dBm