gopsutil icon indicating copy to clipboard operation
gopsutil copied to clipboard

interface speed for windows, linux, darwin and freebsd

Open a-pichler opened this issue 2 years ago • 2 comments

Implemented interface speed for windows, linux, darwin, and freebsd as discussed here #465

Windows is self-explanatory since the speed data was already in mibIfRow2

Linux reads the speed directly out of the /sys/class/net files for each interface

Darwin and Freebsd call ifconfig and parse the output (since the other data is also obtained by calling netstat and parsing it i figured that would be the best way)

a-pichler avatar May 24 '23 15:05 a-pichler

Thank you for your contribution and updating PR.

However, when I run on my FreeBSD 12.4, ifconfig returns this value

vtnet1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=6c07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        ether fo:ba:12:34:56
        media: Ethernet 10Gbase-T <full-duplex>
        status: active

Ethernet 10Gbase-T is not match the regex, therefore, the test is failed.

Could you update the PR?

  1. Could you survey any other way to get interface speed other than ifconfig ?
  2. Update regex to match Ethernet 10Gbase-T.
  3. return error if nothing match.

I will check your PR on Windows later. Thank you for your patience.

shirou avatar Jun 18 '23 13:06 shirou

Any update on this?

Hipska avatar Jan 30 '24 09:01 Hipska