Skip to content

Adding network usage information - #740

Draft
haixuanTao wants to merge 3 commits into
GuillaumeGomez:mainfrom
haixuanTao:master
Draft

Adding network usage information#740
haixuanTao wants to merge 3 commits into
GuillaumeGomez:mainfrom
haixuanTao:master

Conversation

@haixuanTao

@haixuanTao haixuanTao commented May 20, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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

haixuanTao commented May 24, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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.

2 participants