简体   繁体   English

如何完成这种仪器

[英]How can this instrumentation be done

I have different Java applications running on my system and want to instrument classes from one of these applications 我在我的系统上运行了不同的Java应用程序,并希望从这些应用程序中检测类

While trying to do this using dynamically loaded Java agent I found that we can attach it to a jvm instance which requires vm id of that jvm instance when I put a pid of an already running Java application by searching from windows task manager the agent jar does not attach to this process and a error is thrown. 在尝试使用动态加载的Java代理执行此操作时,我发现我们可以将它附加到jvm实例,当我通过从Windows任务管理器搜索代理jar时,我将已经运行的Java应用程序的pid放入该jvm实例时需要vm id不附加到此过程并抛出错误。

While doing it using ManagementFactory.getRuntimeMXBean() the process id() returned is that of the instance loading the agent.jar . 使用ManagementFactory.getRuntimeMXBean()执行此操作时,返回的进程id()是加载agent.jar的实例的进程。 kindly suggest how to access a vmid of a different jvm instance 请建议如何访问不同jvm实例的vmid

You can use scripts for executing the JPS command and extract the information regarding the VM instances being run. 您可以使用脚本执行JPS命令并提取有关正在运行的VM实例的信息。

Also the jps command uses MonitoredHost API which has activeVms() method. 此外,jps命令使用具有activeVms()方法的MonitoredHost API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM