先發出來,而後慢慢翻譯~html
jstat [ generalOption | outputOptions vmid [interval[s|ms] [count]] ]
generalOption
outputOptions
vmid
[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]
count
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.java
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.oracle
The syntax of the vmid 字符串的語法是一個 URI 語法,這意味着 jstat 也能夠查看遠程機器上的 java 進程:app
[protocol:][//]lvmid[@hostname][:port][/servername]
protocol
lvmid
hostname
port
servername
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.dom
NOTE: All options, and their functionality are subject to change or removal in future releases.ide
If you specify one of the general options, you cannot specify any other option or parameter.工具
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.ui
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.this
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.spa
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.
Option
Displays...
class
Statistics on the behavior of the class loader.
compiler
Statistics of the behavior of the HotSpot Just-in-Time compiler.
gc
Statistics of the behavior of the garbage collected heap.
gccapacity
Statistics of the capacities of the generations and their corresponding spaces.
gccause
Summary of garbage collection statistics (same as -gcutil), with the cause of the last and current (if applicable) garbage collection events.
gcnew
Statistics of the behavior of the new generation.
gcnewcapacity
Statistics of the sizes of the new generations and its corresponding spaces.
gcold
Statistics of the behavior of the old and permanent generations.
gcoldcapacity
Statistics of the sizes of the old generation.
gcpermcapacity
Statistics of the sizes of the permanent generation.
gcutil
Summary of garbage collection statistics.
printcompilation
HotSpot compilation method statistics.
The following tables summarize the columns that jstat outputs for each statOption.
如:
# jstat -class 29165
Loaded Bytes Unloaded Bytes Time
7617 14307.7 0 0.0 4.07
-compiler 選項——HotSpot Just-In-Time 編譯器統計。該統計結果列的含義以下所示:
如:
# jstat -compiler 29165
Compiled Failed Invalid Time FailedType FailedMethod
8665 0 0 28.78 0
-gc 選項——垃圾收集器堆統計。該統計結果列的含義以下所示:
表中,S 表示倖存區(survivor space),E 表示伊甸園區(eden space),O 表示老年區(old space),P 表示永久區(permanent space)。Java 7 的 JVM 將堆劃分爲新生代、老年代、永久代。其中,又將新生代劃分爲三個區:伊甸園區,倖存區0,倖存區1。「**代(generation)」是大的劃分,在「代」的基礎上進一步劃分「區(space)」。這麼劃分的緣由,徹底取決於垃圾回收機制。
-gccapacity 選項——Memory Pool Generation and Space Capacities。該統計結果列的含義以下所示:
-gccause 選項——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 選項——新生代(New Generation)統計。該統計結果列的含義以下所示:
-gcnewcapacity 選項——New Generation Space Size StatisticsDescription。該統計結果列的含義以下所示:
-gcold 選項——Old and Permanent Generation Statistics。該統計結果列的含義以下所示:
-gcoldcapacity 選項——Old Generation Statistics。該統計結果列的含義以下所示:
-gcpermcapacity Option——Permanent Generation Statistics。該統計結果列的含義以下所示:
-gcutil 選項——垃圾回收統計概要。該統計結果列的含義以下所示:
-printcompilation 選項——HotSpot Compiler Method Statistics。該統計結果列的含義以下所示:
This section presents some examples of monitoring a local JVM with a lvmid of 21891.
This example attaches to lvmid 21891 and takes 7 samples at 250 millisecond intervals and displays the output as specified by the -gcutil option.
jstat -gcutil 21891 250 7
S0 S1 E O P YGC YGCT FGC FGCT GCT
12.44 0.00 27.20 9.49 96.70 78 0.176 5 0.495 0.672
12.44 0.00 62.16 9.49 96.70 78 0.176 5 0.495 0.672
12.44 0.00 83.97 9.49 96.70 78 0.176 5 0.495 0.672
0.00 7.74 0.00 9.51 96.70 79 0.177 5 0.495 0.673
0.00 7.74 23.37 9.51 96.70 79 0.177 5 0.495 0.673
0.00 7.74 43.82 9.51 96.70 79 0.177 5 0.495 0.673
0.00 7.74 58.11 9.51 96.71 79 0.177 5 0.495 0.673
The output of this example shows that a young generation collection occurred between the 3rd and 4th sample. The collection took 0.001 seconds and promoted objects from the eden space (E) to the old space (O), resulting in an increase of old space utilization from 9.49% to 9.51%. Before the collection, the survivor space was 12.44% utilized, but after this collection it is only 7.74% utilized.
This example attaches to lvmid 21891 and takes samples at 250 millisecond intervals and displays the output as specified by -gcutil option. In addition, it uses the -h3 option to output the column header after every 3 lines of data.
jstat -gcnew -h3 21891 250
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 0.0 31.7 31 31 32.0 512.0 178.6 249 0.203
64.0 64.0 0.0 31.7 31 31 32.0 512.0 355.5 249 0.203
64.0 64.0 35.4 0.0 2 31 32.0 512.0 21.9 250 0.204
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 35.4 0.0 2 31 32.0 512.0 245.9 250 0.204
64.0 64.0 35.4 0.0 2 31 32.0 512.0 421.1 250 0.204
64.0 64.0 0.0 19.0 31 31 32.0 512.0 84.4 251 0.204
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 0.0 19.0 31 31 32.0 512.0 306.7 251 0.204
In addition to showing the repeating header string, this example shows that between the 2nd and 3rd samples, a young GC occurred. Its duration was 0.001 seconds. The collection found enough live data that the survivor space 0 utilization (S0U) would would have exceeded the desired survivor Size (DSS). As a result, objects were promoted to the old generation (not visible in this output), and the tenuring threshold (TT) was lowered from 31 to 2.
Another collection occurs between the 5th and 6th samples. This collection found very few survivors and returned the tenuring threshold to 31.
This example attaches to lvmid 21891 and takes 3 samples at 250 millisecond intervals. The -t option is used to generate a time stamp for each sample in the first column.
jstat -gcoldcapacity -t 21891 250 3
Timestamp OGCMN OGCMX OGC OC YGC FGC FGCT GCT
150.1 1408.0 60544.0 11696.0 11696.0 194 80 2.874 3.799
150.4 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863
150.7 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863
The Timestamp
column reports the elapsed time in seconds since the start of the target JVM. In addition, the -gcoldcapacity output shows the old generation capacity (OGC) and the old space capacity (OC) increasing as the heap expands to meet allocation and/or promotion demands. The old generation capacity (OGC) has grown to from 11696 KB to 13820 KB after the 81st Full GC (FGC). The maximum capacity of the generation (and space) is 60544 KB (OGCMX), so it still has room to expand.
This example attaches to lvmid 40496 on the system named remote.domain using the -gcutil option, with samples taken every second indefinitely.
jstat -gcutil 40496@remote.domain 1000
... output omitted
The lvmid is combined with the name of the remote host to construct a vmid of 40496@remote.domain. This vmid results in the use of the rmi protocol to communicate to the default jstatd server on the remote host. The jstatd server is located using the rmiregistry on remote.domain that is bound to the default rmiregistry port (port 1099).