您的位置:首页 > 编程语言 > Java开发

java jolokia配置

2015-09-29 14:54 477 查看
[tomcat@wx01 ~]$ java -jar jolokia-jvm-1.3.1-agent.jar

11504 jolokia-jvm-1.3.1-agent.jar

11340 org.apache.catalina.startup.Bootstrap start

运行上面的命令会显示当前该机器上正在运行的MBean server的所有程序的PID。

我们上面的HelloAgent也在其中。这里假设HelloAgent的PID是11340

$>java -jar jolokia-jvm-1.3.1-agent.jar --agentContext /j4p start 11340


[tomcat@wx01 ~]$ java -jar jolokia-jvm-1.3.1-agent.jar –agentContext /j4p start 11340

Started Jolokia for PID 11340

http://127.0.0.1:8778/j4p/

http://120.55.118.32:8778/j4p/

[tomcat@wx01 ~]$ perl t1.pl

Memory Used: 311295648

[tomcat@wx01 ~]$ jmap -J-d64 -heap 11340 | grep used

used = 266156128 (253.82626342773438MB)

24.787721037864685% used

used = 0 (0.0MB)

0.0% used

used = 0 (0.0MB)

0.0% used

used = 45139520 (43.04840087890625MB)

1.5762871065143262% used

JVM Agent

Another variant is Jolokia’s JVM agent which does not need any special container environment. The only

dependency is on Oracle’s JDK 6 or later as runtime, since it contains a lightweight HTTP Server used for

exporting the Jolokia protocol. This agent is the most generic one which can instrument any Java application

using a JDK6. It is suitable for situations where the other agents don’t fit. Also, it can be used for

dynamically attaching an agent to a running Java process.

For using this agent, the following argument to the Java application to instrument has to be given:

-javaagent:/path/to/jolokia-jvm--agent.jar

By default, the agent will listen on port 8778, but this can be configured as well as other aspects like

authentication:

Provide options on the commandline as key-value pairs:

-javaagent:agent.jar=port=7777,host=localhost

Via a properties file

-javaagent:agent.jar=config=/path/to/config.properties

Via packaging a jolokia-agent.properties top level in the agent.jar

Options are used in the given precedence, the former overwriting the later values.

For attaching the agent dynamically to a running Java process, the following command can be used to get a quick

help

java -jar /path/to/jolokia-jvm--agent.jar –help

For more details and usage examples please refer to the reference manual.

另外一个变体是Jolokia’s JVM agent,不需要任何特殊的容器环境。只依赖于Oracle的JDK 6或者后面的版本作为

runtime,因为它包含一个轻的HTTP服务器。

服务器用于传输 Jolokia protocol,这个agent是最通用的一个可以任何的Java 应用使用JDK6,

它适用于其他的代理不适合的, 它用于动态的连接到一个Java 程序。

对于使用这个代理, 下面的参数对于Java应用来:

-javaagent:/path/to/jolokia-jvm--agent.jar

默认,agent会侦听8778端口,但是这个可以被配置如下:

提供命令行选项键值:

-javaagent:agent.jar=port=7777,host=localhost

通过一个属性文件

-javaagent:agent.jar=config=/path/to/config.properties
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: