2

VisualVM/VisualGC provides quite a lot of useful GC-related metrics in real-time, but I want a command-line tool that can connect to a remote application via jstatd and record in CSV or XML ideally exactly the same metrics as VisualGC provides. It shouldn't be a problem to write my own, but from the first look I cannot find what protocol visualvm/jstatd use.

As I understand VisualGC is not open source: https://stackoverflow.com/questions/11096466/where-is-the-source-code-repository-for-visualgc, but are there any alternative open source tools? Are there any clues how about the protocol used?

I managed to connect to jstatd via RMI (default port 1099, JStatRemoteHost is the rmi-name), can attach to a particular VM - but http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/jvmstat/monitor/remote/RemoteVm.java#RemoteVm is rather a very low-level interface with jstatd.

I've checked out the VisualVM source code from https://svn.java.net/svn/visualvm~svn/trunk and just started looking at the 5mb codebase, however it doesn't use neither RemoteHost nor RemoteVm RMI-classes.

Thanks.

4

1 回答 1

2

首先,我查看了 VisualVM (~5mb) 的源代码,创建了一个命令行工具,在 JvmstatModelFactory 上注册 JvmstatModelProvider,获取一个应用程序,创建 JvmJvmstatModel 并提取所有 MonitoredValues - 它通过 jstatd 连接到远程应用程序并打印更改的值格式 timeMillis,name,value 1369270235646,sun.gc.generation.2.space.0.capacity,16777216 1369270236666,sun.os.hrt.ticks,2511500491 1369270237581,sun.gc.generation.0.space.0.used, 641408 1369270237582,sun.os.hrt.ticks,2512502544

一小时后,我为我的任务https://code.google.com/p/hatter-source-code/wiki/hotstat找到了正确的命令行工具,它不使用 jstatd - 但很好,我仍然可以运行它通过ssh远程。

于 2013-05-23T00:52:26.763 回答