Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ubuntu 20.04] net_if_stats() returns incorrect interface speed for 100GbE network cards #2095

Closed
garrisoncarter opened this issue Apr 11, 2022 · 7 comments · Fixed by #2096

Comments

@garrisoncarter
Copy link
Contributor

Summary

  • OS: Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-100-generic x86_64)
  • Architecture: 64bit
  • Psutil version: 5.9.0
  • Python version: Python 3.8.10
  • Type: Core

Description

psutil.net_if_stats() will return an incorrect value for the interface speed value in linux when querying a 100GbE network card. In the below example, eth1 is a 100GbE network card

>>> import psutil
>>> psutil.net_if_stats()
{'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536), 'eth0': snicstats(isup=False, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=65535, mtu=1500), 'eth1': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=34464, mtu=1500)}
>>>

I also noticed that the return value when an interface is down (isup==False) will be 65535 instead of 0.

>>> import psutil
>>> psutil.net_if_stats()
{'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536), 'eth0': snicstats(isup=False, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=65535, mtu=1500), 'eth1': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=10000, mtu=1500)}
>>>

It seems this could possibly be related to the handling of uint16 values.

@garrisoncarter
Copy link
Contributor Author

I have a fix for this and I will open up a PR momentarily!

@swangful
Copy link

I am having this issue too, would love to see this merged please :D @giampaolo

@garrisoncarter
Copy link
Contributor Author

Confirmed this is still an issue with 5.9.1

Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.net_if_stats()
{'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536), 'eth0': snicstats(isup=False, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=65535, mtu=1500), 'eth1': snicstats(isup=False, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=65535, mtu=1500), 'eth2': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=34464, mtu=1500)}
>>>

@garrisoncarter
Copy link
Contributor Author

@giampaolo anyway we could get the full test suite ran on #2096 and possibly get it merged?

@Rex-Luther
Copy link

Hello @giampaolo and @garrisoncarter , I have also ran into this issue and would love if we could get this prioritized. Is there anything that I can do to help out here?

@giampaolo
Copy link
Owner

I've just merged the PR.

@garrisoncarter
Copy link
Contributor Author

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants