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

Adding network usage information #740

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

haixuanTao
Copy link
Contributor

@haixuanTao haixuanTao commented May 20, 2022

This PR implements the fetching of network information for linux process using the proc/{pid}/net/dev/information and summing up all bytes transmitted and received.

Knowing that this is not implemented for all OSes, this PR is not intended to be merged and only serves as a reference for those who need network information. More info: #135

@GuillaumeGomez
Copy link
Owner

Thanks for this! I think my issue was with windows, on macOS and FreeBSD, it's possible. I'll try to find time to implement the rest based on your starter.

@haixuanTao haixuanTao marked this pull request as draft May 20, 2022 20:05
@haixuanTao
Copy link
Contributor Author

Ok, so, proc/{pid}/net/dev does not actually show the process network usage but the process point of view of the network. Most of the time it will only reflects /proc/net/dev, and will not monitor the actual consumption of the process usage.

I'm going to fetch another way to have the network usage, but it seems to be hard.

https://www.reddit.com/r/linux/comments/3tbhkf/does_reading_of_procpidnetdev_really_show_the/

@haixuanTao
Copy link
Contributor Author

haixuanTao commented May 24, 2022

I feel like the proper way to implement this is the: https://github.com/kaegi/netinfo way. That is:

  • reading /proc/net/tcp
  • and convert inode to pid

To do this, sysinfo can make its own parsing logic or rely on netinfo.

@haixuanTao
Copy link
Contributor Author

So the netinfo crate does not seems to be actively maintained and has some outdated dependencies, so this should probably be reimplemented from scratch in sysinfo, with the added benefit to be able to probably reuse component between OS.

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

Successfully merging this pull request may close these issues.

None yet

2 participants