`

A simple usecase of jconsole

阅读更多
1: What is jconsole?
The jconsole command launches a graphical console tool that enables you to monitor and manage Java applications and virtual machines on a local or remote machine.

2: What it can do?
The jconsole can:
1) Viewing summary information
2) Monitoring Memory Consumption
3) Monitoring Thread Use
4) Monitoring Class Loading
5) Monitoring and Managing MBeans
6) Viewing VM Information

3: How to use it?
refer to 4: demo

4: Jconsole config files location
You can set the ssl/remote port/access right in below jconsole config folder,
%JAVA_HOME%\jre\lib\management\
After you setup the config in the management.properties file you can specified the config file location in the java application start parameter,such as:
-Dcom.sun.management.config.file=%java_home%\jre\lib\management\management.properties -jar C:\oc4j_101330_seed\j2ee\home\oc4j.jar

5: Demo
Here use Java2DDemo again to demonstrate the usage:
a) start the Java2DDemo with -Dcom.sun.management.jmxremote options
C:\>java -Dcom.sun.management.jmxremote -jar "C:\Program Files\Java\jdk1.5.0_06\demo\jfc\Java2D\Java2Demo.jar

b) use jps to find the PID of the Java2DDemo java application, you can find the PID by window task manager.

C:\>jps
1440 Program
492 Jps


c) start jconsole

C:\>jconsole 1440

Now the jconsole UI displayed.


d) Test for monitor the local application server
Here choose the OC4J to do the test.
For WindowsXP platform, pls change your TMP path to another place, here i changed it to c:\TEMP
Start the oc4j with -Dcom.sun.management.jmxremote option. it's better to start it separately, will get error when start it in eclipse servers console.
the error messgae is:
Exception in thread "main" java.lang.Exception: Could not open
PerfMemory
find the PID of it.
C:\>jps
5332 oc4j.jar
2032 Jps


e) Start remote monitor
without authentications because just used for test env
com.sun.management.jmxremote.port=9999
com.sun.management.jmxremote.ssl=false
com.sun.management.jmxremote.authenticate=false

--> Start jconsole --> set the right hostname/port/username/password (if any) to connect.

6: Problems
a) When use jconsole meet: Exception in thread "main" java.lang.Exception: Could not open PerfMemory
the solution is:
set the tmp variable to c:\tmp for the process calling the application as well as the process calling the monitoring tool.
quote from http://forums.sun.com/thread.jspa?threadID=730397
This is usually due to a permissions problem. There's two known causes.
The first happens when the tools (jstat and jps) are run by a different
user id than the application. The second, which is probably more likely
here, is cause by a bug the JVM when it encounters inherited DACLS in
the default temporary directory. inherited DACLS are usually set up by
the IT organization on users home directories, though they can also
occur on other system directories. We do not yet have a fix for this bug
but there is a work around.

The workaround is to set the TMP environment variable (either globally
or for all processes started by a specific user or for just the target
process and the tools) to point to a directory that doesn't get
inherited DACLS. Usually something like c:\tmp will work. Trying setting
TMP=c:\tmp (after making the directory, of course) for both the
application(s) you want to monitor and the command window where you run
the jstat and jps tools and see if that fixes the problem. If it doesn't
fix the problem, I'll need to see the output of the following commands
(using the original TMP setting and then again with TMP=c:\tmp)

cacls %TMP%
cacls %TMP%\hsperfdata_*

Another workaround is to point TMP to a FAT32 file system and then set
-XX:+PerfBypassFileSystemCheck on the target applications' command lines
and -J-XX:+PerfBypassFileSystemCheck on the jstat and jps command lines.
This works because FAT32 doesn't support DACLS, so the JVM doesn't
attempt to create them; however, the the PerfBypassFileSystemCheck is
needed because the JVM won't enable the monitoring capaibilties when TMP
is set to device that doesn't support DACLs.

There's more information about setting TMP globally and on a per-user
basis in the jvmstat faq:

http://java.sun.com/performance/jvmstat/faq.html

See item #4.

Brian


b) meet below error when use jconsole:
Unable to attach to 4800: Could not map vmid to user name

the cause can be found in http://java.sun.com/performance/jvmstat/faq.html#15

but i could not understand and don't know how to use the workaround it provides. My solution here is to start the OC4J separately instead of start it in eclipse servers. It works.

7: Reference
[1]http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html
[2]http://java.sun.com/j2se/1.5.0/docs/guide/management/faq.html
[3]http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html
[4]
  • 大小: 29.6 KB
分享到:
评论

相关推荐

    jconsole-1.8.0.zip

    《JConsole:Java监视与管理控制台详解》 在Java开发和运维过程中,监控和管理应用程序的性能至关重要。JConsole是Java开发工具包(JDK)自带的一个强大的、基于Java的图形用户界面(GUI)工具,它允许我们监控Java...

    jconsole.jar下载

    《深入理解Java监控工具jconsole.jar》 在Java开发与运维过程中,监控应用程序的性能和资源使用情况至关重要。Java提供了一款强大的可视化监控工具——jconsole.jar,它可以帮助开发者和系统管理员实时查看和分析...

    jconsole.1.8.0jar

    《深入解析jconsole.1.8.0.jar及其在Java应用监控中的作用》 在Java开发和运维领域,工具的高效使用是提升工作效率的关键。jconsole作为Java平台提供的一款强大的性能监视工具,对于理解应用程序的运行状态至关重要...

    jconsole-1.8.0.jar

    java开发常用组件,jconsole-1.8.0.jar jconsole-1.8.0.jar

    jconsole.jar

    jconsole.jar

    jconsole源码

    《深入解析JConsole源码与JMX技术》 JConsole是Java平台提供的一个强大的管理工具,主要用于监控和管理Java应用程序,尤其是对Java Management Extensions (JMX)的支持,使其成为开发者和系统管理员的强大助手。...

    Jconsole&JMX监控

    ### JConsole & JMX 监控详解 #### 一、JConsole简介 JConsole是一款随Sun JDK 1.5发布而来的Java监控和管理工具,它支持Java Management Extensions (JMX)规范,允许用户通过图形界面监控Java虚拟机(JVM)的运行...

    xmanage远程打开jconsole

    《使用xmanage远程开启Jconsole的详细步骤及原理解析》 在日常的Java应用程序管理中,Jconsole是一款非常实用的监控工具,它可以帮助我们实时监控Java应用的性能、内存使用情况以及线程状态等。然而,有时候在配置...

    JConsole远程监控Tomcat

    ### JConsole远程监控Tomcat服务知识点详解 #### 一、JConsole简介与功能 - **JConsole**: JConsole是一款基于Java Management Extensions (JMX) 的图形用户界面工具,旨在帮助开发者和运维人员监控正在运行的Java...

    Jconsole监控Java应用

    Jconsole监控Java应用 Jconsole是JDK自带的监控工具,可以对Java应用程序进行监控。本文将介绍通过Jconsole工具对Java应用程序进行监控,包括环境准备、操作步骤和监控内容等。 环境准备 要使用Jconsole对Java...

    visual VM配置JConsole plugin JTop.jar

    JTop.jar是JConsole的一个插件,用于增强JConsole的功能,特别是针对Java进程的实时性能监控。 JTop.jar的配置和使用步骤如下: 1. **下载与获取**:首先,你需要获取到JTop.jar文件,这通常可以从开源社区或者...

    wind版本jdk8以及jconsole工具.zip

    **JDK8与JConsole工具详解** JDK(Java Development Kit)是Java开发者的必备工具,其中包含了编译器、调试器、性能分析工具等一系列用于Java应用程序开发和部署的组件。JDK8作为Java的一个重要版本,引入了许多新...

    jconsole配置

    Jconsole是一款强大的Java应用程序监控工具,它包含在JDK的bin目录中,可用于实时监控本地或远程JVM的性能和资源消耗。通过提供丰富的图表和可视化界面,Jconsole可以帮助开发者和系统管理员深入了解Java应用程序的...

    JConsole(观察分析Java程序的运行)

    ### JConsole:观察与分析Java程序的运行 #### 一、JConsole简介 JConsole是自Java 5开始集成在JDK中的一个强大的性能监视和故障排除工具。它能够帮助开发者和运维人员监控Java应用程序的运行状态,并进行性能分析...

    jconsole使用手册

    jconsole使用手册 jconsole是Java Development Kit(JDK)5.0中自带的一个性能监控工具,用于监控Java运行状态、线程数、进程数、对象、JVM内存信息、时间等性能信息。该工具可以帮助开发者和管理员实时监控Java...

    JConsole Source Code(jdk1.6)

    JConsole是Java开发工具集(Java Development Kit, JDK)中的一个强大的监控工具,主要用于监视Java应用程序的性能和资源使用情况。在JDK 1.6版本中,JConsole提供了丰富的图形用户界面,允许开发者和系统管理员实时...

    JConsole_远程监控Tomcat_ricky

    ### JConsole 远程监控 Tomcat 服务 #### 1. 概述 JConsole 是一个集成在 Java 开发工具包 (JDK) 中的图形用户界面 (GUI) 工具,它允许用户通过 Java 管理扩展 (JMX) 对正在运行的 Java 虚拟机 (JVM) 进行监控。...

    JConsole使用手册

    **JConsole使用手册** 在Java开发和运维过程中,性能监控是一项至关重要的任务。JConsole是Java官方提供的一款强大的性能监视工具,它可以帮助我们实时监控Java应用程序的运行状态,包括内存使用、线程状态、类加载...

    jconsole 配置和JVM内存检测工具介绍

    jvm检测工具,jconsole工具介绍,其他同类工具介绍

Global site tag (gtag.js) - Google Analytics