【开发总结】Linux下获取物理网卡带宽最大值

背景:

现阶段手头的一个自研的流式计算平台在完善监控体系,对机器资源负载、机器上任务资源消耗进行统计和上报,这里对Linux下获取网卡上限的方法进行梳理。

说明:这里的网卡最大带宽指的是物理网卡的带宽最大值
现阶段是使用系统提供的命令ethtool获取网卡最大值,具体命令如下:
ethtool eth1 | grep Speed

//1000M网卡机器中,ethtool命令的执行结果:
[root@WSC-155-91 ~]# ethtool eth1
Settings for eth1:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        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
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000007 (7)
        Link detected: yes
[root@WSC-155-91 ~]# ethtool eth1 | grep Speed
        Speed: 1000Mb/s

-------------------------------------------------------------------------------------

//10000M网卡机器中,ethtool命令的执行结果:
[root@WSC-32-134 ~]# ethtool eth1      
Settings for eth1:
        Supported ports: [ TP ]
        Supported link modes:   100baseT/Full 
                                1000baseT/Full 
                                10000baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  100baseT/Full 
                                1000baseT/Full 
                                10000baseT/Full 
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Speed: 10000Mb/s  // 网卡流速上限
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: umbg
        Wake-on: g
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
[root@WSC-32-134 ~]# ethtool eth1 | grep Speed
        Speed: 10000Mb/s

猜你喜欢

转载自blog.csdn.net/zd199218/article/details/72453105