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

process.NetIOCounters is pointless on Linux #429

Closed
disq opened this issue Oct 3, 2017 · 6 comments
Closed

process.NetIOCounters is pointless on Linux #429

disq opened this issue Oct 3, 2017 · 6 comments

Comments

@disq
Copy link
Contributor

disq commented Oct 3, 2017

process.NetIOCounters reads data from the /proc/<pid>/net/dev file. The contents of this file is the same across all pids, and also equal to the contents of the /proc/net/dev file. So the results returned from this function is the same across all processes, and reflects the overall interface metrics.

@shirou shirou mentioned this issue Oct 4, 2017
9 tasks
@shirou
Copy link
Owner

shirou commented Oct 4, 2017

Thank you for your comment. and also psutil process class does not have net_io_counter, I will remove it at v3 since it broke current API. I have filed on #362.

@shirou shirou closed this as completed Oct 4, 2017
@shirou shirou mentioned this issue Sep 7, 2020
14 tasks
@AtakanColak
Copy link
Contributor

@shirou @Lomanic is it not possible to gather network usage by process in any way? I was looking for implementing this in windows but turns out even linux method is not giving process specific values...

@buglloc
Copy link

buglloc commented Dec 21, 2020

process.NetIOCounters isn't pointless on Linux. It's useful, for example, when we want to get network statistics for nested net ns which process was attached.
Maybe bring back process.NetIOCounters? :)

@AtakanColak
Copy link
Contributor

@buglloc could you elaborate please? Or perhaps provide links that do so?

@AtakanColak
Copy link
Contributor

@shirou @Lomanic Also why is the method still visible if it is removed? I know it doesn't work the way we want it to but was it reintroduced at some point? Link

@Lomanic
Copy link
Collaborator

Lomanic commented Dec 29, 2020

This is removed if you have v3 in the import path. https://pkg.go.dev/github.com/shirou/gopsutil/v3@v3.20.11/process#Process.NetIOCounters (notice how this link/version doesn't have the +incompatible suffix as it's now modules-compliant). We didn't change anything on the "v2" non-module aware packages as not to break existing users on v2.

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

No branches or pull requests

5 participants