JPS和其他Java监控工具如何收集有关本地JVM的数据?
我遇到了一个与其他问题非常相似的问题( 即使 java 进程正在运行,jps 也不返回任何输出)。在我阅读该问题之前,我认为我的问题是 jstatd 未运行,但该问题的解决方案意味着 jps 使用某种临时文件。我还意识到可以在没有任何网络活动的情况下监视本地 JVM,我很好奇它是如何工作的。我并不是要求解决我的问题,我只是想知道 jps 和其他人如何在本地工作。令我惊讶的是,我从事Java开发这么多年,根本不知道。
I ran into a problem that is very similar to other SO question ( jps returns no output even when java processes are running ). Before I read that question I though that my problem is that jstatd is not running, but solution in that question implies that jps uses some sort of temporary files. I also realized that it is possible to monitor local JVMs without any network activity at all and I'm curious how does it work. I'm not asking for a solution to my problem, I just want to know how jps and others work locally. It surprises me that I don't know it at all after so many years spent in Java development.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在本地使用的情况下,MonitoredHost 的默认实现是 sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider,它使用 sun.jvmstat.perfdata.monitor.protocol.local.LocalVmManager。它的方法 activeVms() 正在完成真正的工作,它循环遍历用户临时目录中的文件,搜索具有已知文件名格式的文件,启动的 JVM 会在其中发布其监视数据。正如我怀疑的那样,根本没有 TCP。有趣的。
In case of local usage the default implementation of MonitoredHost is sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider which uses sun.jvmstat.perfdata.monitor.protocol.local.LocalVmManager. It's method activeVms(), wher the real work is being done, loops through files in user temp directories searching for files with known filename format where started JVMs publish their monitoring data. No TCP at all as I suspected. Interesting.