Jconsole is a JMX-compliant monitoring tool. It uses
the extensive JMX instrumentation of the Java virtual machine to provide
information on performance and resource consumption of applications running on
the Java platform.
- Starting jconsole
- The jconsole interface
- Viewing summary information
- Monitoring Memory Consumption
- Monitoring Thread Use
- Monitoring Class Loading
- Monitoring and Managing MBeans
- Viewing VM Information
- Frequently Asked Questions
Starting jconsole
The
jconsole
executable is in JDK_HOME
/bin
, where JDK_HOME
is the directory where the JDK is installed. If this
directory is on your system path, you can start the tool by simply typing jconsole
in
a command (shell) prompt. Otherwise, you have to type the full path to the
executable file.
Command Syntax
You can use jconsole to monitor both local applications
(those running on the same system as
jconsole
) and remote
applications (those running on other systems).
Note: Using
jconsole
to
monitor a local application is useful for development and prototyping, but is
not recommended for production environments, because jconsole
itself consumes significant system resources. Remote monitoring is recommended
to isolate the jconsole
application from the platform being monitored.
For a complete reference on
jconsole
command
syntax, see jconsole
- Java Monitoring and Management Console.
Local Monitoring
To monitor a local application, it must be running with the
same user ID as
jconsole
. The command syntax to start jconsole
for local
monitoring is:jconsole [processID]
where processID is the application's process ID
(PID). To determine an application's PID:
- On Unix or Linux systems, use the
ps
command to find the PID of java. - On Windows systems, use Task Manager to find the PID of java
or javaw.
You can also use the jps
command-line utility to determine PIDs.
For example, if you determined that the process ID of the Notepad
application is 2956, then you would start jconsole as follows:
jconsole 2956
Both
jconsole
and the application must by executed by the same user name. The
management and monitoring system uses the operating system's file permissions.
If you don't specify a process ID, jconsole will
automatically detect all local Java applications, and display a dialog box that
lets you select the one you want to monitor (see the next section).
For more information, see Local
JMX Monitoring and Management.
Remote Monitoring
To start
jconsole
for remote monitoring, use this
command syntax:jconsole [hostName:portNum]
where hostName is the name of the system running the
application and portNum is the port number you specified when you
enabled the JMX agent when you started the JVM. For more information, see Remote
JMX Monitoring and Management.
If you do not specify a host name/port number combination,
then jconsole will display a connection dialog box (see the next section)
enabling you to enter a host name and port number.
Connecting to a JMX Agent
If you start
jconsole
with arguments
specifying a JMX agent to which to connect, it will automatically start
monitoring the specified JVM. You can connect to a different host at any time
by choosing Connection | New Connection. and entering the necessary
information.
Otherwise, if you do not provide any arguments when you
start
jconsole
, the first thing you see is the connection dialog box. This
dialog box has three tabs:- Local
- Remote
- Advanced
Local Tab
The local tab lists any JVMs running on the local system
started with the same user ID as jconsole, along with their process ID and
class/argument information. Select the application you want to monitor,
then click Connect.
Remote Tab
To monitor a remote JVM, enter:
- Host name: name of the machine on which the JVM is running.
- Port number: the JMX agent port number you specified when you
started the JVM.
- User name and password: the user name and password to use
(required only if monitoring a JVM through a JMX agent that requires
password authentication).
For information on setting the port number of the JMX
agent, see Enabling
the JMX Management Agent. For information on user names and passwords, see Using
Password and Access Files.
To monitor the JVM running jconsole, simply click Connect,
using host localhost and the port zero (0).
Advanced Tab
The advanced tab enables you to connect to other JMX agents
(MBean servers) by specifying their JMX URL, and the user name and
password. The syntax of a JMX URL is described in the API documentation
for javax.management.remote.JMXServiceURL.
Note: If the JMX agent is
using in a connector which is not included in the Java platform, you need to
add the connector classes to the classpath when running
jconsole
as
follow:jconsole -J-Djava.class.path=JAVA_HOME/lib/jconsole.jar:JAVA_HOME/lib/tools.jar:connector-path
where
JAVA_HOME
is the directory
containing the JDK and connector-path is the directory or the jar file
containing the classes not included in JDK 5.0 to be used by jconsole for
connecting to a JMX agent.
The jconsole interface
The jconsole interface is composed of six tabs:
- Summary tab: displays summary information on the JVM and
monitored values.
- Memory tab: displays information on memory use.
- Threads tab: displays information on thread use.
- Classes tab: displays information on class loading
- MBeans tab: displays information on MBeans
- VM tab: displays information on the JVM
The following sections provide information on each tab.
Viewing Summary Information
The Summary tab displays some key monitoring information on
thread usage, memory consumption, and class loading, plus information on the
JVM and operating system.
Summary
- Uptime: how long the JVM has been
running
- Total compile time: the amount of time
spent in just-in-time (JIT) compilation.
- Process CPU time: the total amount
of CPU time consumed by the JVM
Threads
- Live threads: Current number of
live daemon threads plus non-daemon threads
- Peak: Highest number of live
threads since JVM started.
- Daemon threads: Current number of
live daemon threads
- Total started: Total number of
threads started since JVM started (including daemon, non-daemon, and
terminated).
Memory
- Current heap size: Number of Kbytes
currently occupied by the heap.
- Committed memory: Total amount of
memory allocated for use by the heap.
- Maximum heap size: Maximum number
of Kbytes occupied by the heap.
- Objects pending for finalization: Number of objects pending for finalization.
- Garbage collector information:
Information on GC, including the garbage collector names, number of
collections performed, and total time spent performing GC.
Classes
- Current classes loaded: Number of
classes currently loaded into memory.
- Total classes loaded: Total number
of classes loaded into memory since the JVM started, included those
subsequently unloaded.
- Total classes unloaded: Number of
classes unloaded from memory since the JVM started.
Operating System
- Total physical memory: Amount of
random-access memory (RAM) that the OS has.
- Free physical memory: Amount of free RAM the OS has.
- Committed virtual memory: Amount of virtual memory guaranteed to be available to the running process.
No comments:
Post a Comment