Linux 看到太多lsof无法识别协议

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7911840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 06:52:57  来源:igfitidea点击:

Seeing too many lsof can't identify protocol

javalinuxfilelsof

提问by Johnny


I have a Java process/app. When I run /usr/sbin/lsof -p on that java process, I see a lot of "can't identify protocol". Also, interestingly, File descriptors(FDs) are increasing at a very steady rate. And those FDs that are being created are having description as "can't identify protocol".


我有一个 Java 进程/应用程序。当我在该 java 进程上运行 /usr/sbin/lsof -p 时,我看到很多“无法识别协议”。此外,有趣的是,文件描述符(FD)正在以非常稳定的速度增长。正在创建的那些 FD 被描述为“无法识别协议”。

So, is there any way to instrument/profile the java process so as to nail down who is creating that many FDs. Any detailed explanation on any tool would be really really helpful.

那么,有没有什么方法可以检测/分析 java 进程,以便确定谁在创建那么多 FD。关于任何工具的任何详细解释都会非常有帮助。

A quick google search tells me strace is one way but IIUC, that will show linux system calls coming out of the java process. I am more interested in which part of my java code is behaving badly than what system calls are being generated.

一个快速的谷歌搜索告诉我,strace 是一种方式,但 IIUC 将显示来自 java 进程的 linux 系统调用。与生成的系统调用相比,我对 Java 代码的哪一部分表现不佳更感兴趣。

Again, any ideas/suggestions would be simply great!

同样,任何想法/建议都会很棒!

回答by laher

When lsof prints "Can't identify protocol", this usually relates to sockets (it should also say 'sock' in the relevant output lines).

当 lsof 打印“无法识别协议”时,这通常与套接字有关(它还应该在相关输出行中显示“sock”)。

So, somewhere in your code you are probably connecting sockets and not closing them properly (perhaps you need a finally block).

因此,在您的代码中的某个地方,您可能正在连接套接字但没有正确关闭它们(也许您需要一个 finally 块)。

I suggest you step through your code with a debugger (easiest to use your IDE, potentially with a remote debugger, if necesssary), while running lsof side-by-side. You should eventually be able to see which thread / line of code is creating these File Descriptors.

我建议您在并排运行 lsof 的同时,使用调试器(最容易使用您的 IDE,可能使用远程调试器,如果需要)逐步调试您的代码。您最终应该能够看到哪个线程/代码行正在创建这些文件描述符。

See point 10.2.2 of this FAQfor more details about the Lsof output.

有关Lsof 输出的更多详细信息,请参阅此 FAQ 的第 10.2.2 点。

回答by Micha? Niklas

Maybe you observe bug in JVM 1.6 with leak of connections when you use SSL and hostname: http://bugs.sun.com/view_bug.do?bug_id=6745052

当您使用 SSL 和主机名时,您可能会发现 JVM 1.6 中存在连接泄漏的错误:http: //bugs.sun.com/view_bug.do?bug_id=6745052

回答by Marek

Lsof prints can't identify protocolfor half-open TCP/IP connections: https://idea.popcount.org/2012-12-09-lsof-cant-identify-protocol/

lsof 打印can't identify protocol半开 TCP/IP 连接:https: //idea.popcount.org/2012-12-09-lsof-cant-identify-protocol/