jstat
Java Virtual Machine Statistics Monitoring Tool
Synopsis
jstat [
generalOption | outputOptionsvmid
[interval[s|ms] [count]] ]
add an example, a script, a trick and tips
examples
source
for i in {1..20160};do date >> ${JBOSS_HOME}/log/snap_jstat_${JBOSS_PID} && ${INSTALL_HOME}/jre/bin/jstat -gcutil ${JBOSS_PID} >> ${JBOSS_HOME}/log/snap_jstat_${JBOSS_PID}; sleep 30;done
description
The
jstat tool displays performance statistics for an
instrumented HotSpot Java virtual machine (JVM). The target
JVM is identified by its virtual machine identifier, or
vmid option described below.
NOTE:
This utility is unsupported and may not be available in
future versions of the JDK. It is not currently available on
Windows 98 and Windows ME. platforms.
VIRTUAL
MACHINE IDENTIFIER
The syntax of the vmid string largely corresponds to
the syntax of a URI:
[protocol:][//]lvmid[@hostname][:port][/servername]
protocol
The communications protocol. If
the protocol is omitted and a hostname is not
specified, the default protocol is a platform specific
optimized local protocol. If the protocol is omitted
and a hostname is specified, then the default
protocol is rmi.
lvmid
The local virtual machine
identifier for the target JVM. The lvmid is a
platform-specific value that uniquely identifies a JVM
on a system. The lvmid is the only required component
of a virtual machine identifier. The lvmid is
typically, but not necessarily, the operating system’s
process identifier for the target JVM process. You can use
the jps command to determine the lvmid. Also,
you can determine lvmid on Unix platforms with the
ps command, and on Windows with the Windows Task
Manager.
hostname
A hostname or IP address
indicating the target host. If hostname is omitted,
then the target host is the local host.
port
The default port for
communicating with the remote server. If the hostname
is omitted or the protocol specifies an optimized,
local protocol, then port is ignored. Otherwise,
treatment of the port parameter is implementation
specific. For the default rmi protocol, the
port indicates the port number for the rmiregistry on
the remote host. If port is omitted, and
protocol indicates rmi, then the default
rmiregistry port (1099) is used.
servername
The treatment of this parameter
depends on implementation. For the optimized local protocol,
this field is ignored. For the rmi protocol, it
represents the name of the RMI remote object on the remote
host.
options
The
jstat command supports two types of options, general
options and output options. General options cause
jstat to display simple usage and version
information. Output options determine the content and format
of the statistical output.
NOTE:
All options, and their functionality are subject to change
or removal in future releases.
GENERAL
OPTIONS
If you specify
one of the general options, you cannot specify any other
option or parameter.
-help
Display help message.
-version
Display version
information.
-options
Display list of statistics
options. See the Output Options section below.
OUTPUT
OPTIONS
If you do not
specify a general option, then you can specify output
options. Output options determine the content and format of
jstat’s output, and consist of a single
statOption, plus any of the other output options
(-h, -t, and -J). The
statOption must come first.
Output is
formatted as a table, with columns are separated by spaces.
A header row with titles describes the columns. Use
the -h option to set the frequency at which the
header is displayed. Column header names are generally
consistent between the different options. In general, if two
options provide a column with the same name, then the data
source for the two columns are the same.
Use the
-t option to display a time stamp column,
labeled Timestamp as the first column of output. The
Timestamp column contains the elapsed time, in
seconds, since startup of the target JVM. The resolution of
the time stamp is dependent on various factors and is
subject to variation due to delayed thread scheduling on
heavily loaded systems.
Use the
interval and count parameters to determine how
frequently and how many times, respectively, jstat
displays its output.
NOTE:
You are advised not to write scripts to parse
jstat’s output since the format may change in
future releases. If you choose to write scripts that parse
jstat output, expect to modify them for future
releases of this tool.
-statOption
Determines the statistics
information that jstat displays. The following table
lists the available options. Use the
-options general option to display the list of
options for a particular platform installation.
-hn
Display a column header every
n samples (output rows), where n is a positive
integer. Default value is 0, which displays the column
header above the first row of data.
-tn
Display a timestamp column as
the first column of output. The timestamp is the the time
since the start time of the target JVM.
-JjavaOption
Pass javaOption to the
java application launcher. For example,
-J-Xms48m sets the startup memory to 48
megabytes. For a complete list of options, see the following
documents:
*
java - the Java application launcher
(Solaris) @
http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html
*
java - the Java
application launcher (Linux) @
http://java.sun.com/javase/6/docs/technotes/tools/linux/java.html
*
java - the Java
application launcher (Windows)
STATOPTIONS
AND
OUTPUT
The following
tables summarize the columns that jstat outputs for
each statOption.
-class
Option
-compiler
Option
-gc
Option
-gccapacity
Option
-gccause
Option
This option
displays the same summary of garbage collection statistics
as the -gcutil option, but includes the causes
of the last garbage collection event and (if applicable) the
current garbage collection event. In addition to the columns
listed for -gcutil, this option adds the
following columns:
-gcnew
Option
-gcnewcapacity
Option
-gcold
Option
-gcoldcapacity
Option
-gcpermcapacity
Option
-gcutil
Option
-printcompilation
Option
parameters
generalOption
A single general command-line option (-help, -options, or
-version)
outputOptions
One or more output options, consisting of a single
statOption, plus any of the -t, -h, and -J options.
vmid
Virtual machine identifier, a string indicating the target Java
virtual machine (JVM). The general syntax is
[protocol:][//]lvmid[@hostname[:port]/servername]
The syntax of the vmid string largely corresponds to the syntax
of a URI. The vmid can vary from a simple integer
representing a local JVM to a more complex construction
specifying a communications protocol, port number, and other
implementation-specific values. See Virtual Machine Identifier
for details.
interval[s|ms]
Sampling interval in the specified units, seconds (s) or
milliseconds (ms). Default units are milliseconds. Must be
a positive integer. If specified, jstat will produce
its output at each interval.
count
Number of samples to display. Default value is infinity; that is,
jstat displays statistics until the target JVM terminates
or the jstat command is terminated. Must be a
positive integer.