为现有Java应用程序添加JMXMP侦听器 [英] Add JMXMP listener for an existing Java application
问题描述
我需要在不更改任何代码的情况下将JMXMP侦听器添加到现有的Java应用程序 中.传统的基于RMI的协议在目标环境中对防火墙限制不起作用.
I need to add a JMXMP listener to an existing Java application without changing any code. The classic RMI based protocol doesn't work in the target environment do to firewall restrictions.
换句话说:我想通过将jmx_remote-optional添加到类路径和一些类似于com.sun.management.jmxremote的env属性(用于RMI连接器)来访问该过程的JMX.
In other words: I would like to access the JMX of the process just by adding the jmx_remote-optional to the classpath and some env properties analog to com.sun.management.jmxremote for the RMI connector.
我在各种文档中都找不到任何东西-我设法在目标环境中使用Tomcat与JMXMP(添加了一个从配置读取端口的LifecycleEventListener)以及另一个程序,在其中我明确启动了侦听器. /p>
I couldn't find anything in the various docs out there - I managed to use JMXMP in the target env with Tomcat (adding a LifecycleEventListener that reads the port from the config) and another program where I explicitly started the listener.
推荐答案
看看我的github项目 JMXMPAgent 一个>. Docs有点轻,但是前提很简单.
Take a look at my github project JMXMPAgent. Docs are a little light, but the premise is simple.
- 克隆存储库
- 使用 mvn全新安装 进行构建
- 使用目标JVM的PID,所需的JMXMP侦听端口,绑定接口和目标MBeanServer默认域将代理安装到正在运行的JVM中,如以下示例所示.它假定一个PID和默认的JMX域.
- Clone the repo
- Build with mvn clean install
- Install the agent into a running JVM using the PID of the target JVM, the desired JMXMP listening port, binding interface and target MBeanServer default domain as in the following example. It assumes a PID and the default JMX domain.
java -jar target/helios-jmxmp-agent-1.0-SNAPSHOT.jar -install 11121 8334:127.0.0.1:DefaultDomain
java -jar target/helios-jmxmp-agent-1.0-SNAPSHOT.jar -install 11121 8334:127.0.0.1:DefaultDomain
这篇关于为现有Java应用程序添加JMXMP侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!