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

查询单个进程的网络连接信息,是否有更好的方法? #3

Open
hz-kelpie opened this issue Sep 14, 2021 · 0 comments
Open

Comments

@hz-kelpie
Copy link

从gopsutil那儿发现的这个项目
gopsutil 的做法是

  1. 从 /proc/{PID}/fd 提取inode
  2. 在 /proc/{PID}/net/(tcp| udp| unix)寻找inode

但是/proc/{PID}/net/tcp其实等同于/proc/net/tcp,也就是机器的所有tcp连接信息
如果在一些存在上万连接的机器上,每触发一个进程就需要遍历一次机器的全量连接信息,太消耗资源。

使用了你的项目确实快上不少,但是获取到的依旧是机器的全量连接

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

1 participant