Java 7 jstat – JVM Statistics Monitoring Tool【翻译】
原文地址:Java 7 jstat
本文内容
- 语法
- 参数
- 描述
- 虚拟机标识符
- 选项
- 一般选项
- 输出选项
- 示例
先发出来,然后慢慢翻译~
语法
jstat [ generalOption | outputOptions vmid [interval[s|ms] [count]] ]
参数
generalOption- A single general command-line option (-help or -options)
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.
描述
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.
虚拟机标识符
The syntax of the vmid 字符串的语法是一个 URI 语法,这意味着 jstat 也可以查看远程机器上的 java 进程:
[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.
选项
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.
一般选项
If you specify one of the general options, you cannot specify any other option or parameter.
- -help
- Display help message.
- -options
- Display list of statistics options. See the Output Options section below.
输出选项
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.
Option
Displays...Statistics on the behavior of the class loader.
Statistics of the behavior of the HotSpot Just-in-Time compiler.
Statistics of the behavior of the garbage collected heap.
Statistics of the capacities of the generations and their corresponding spaces.
Summary of garbage collection statistics (same as -gcutil), with the cause of the last and current (if applicable) garbage collection events.
Statistics of the behavior of the new generation.
Statistics of the sizes of the new generations and its corresponding spaces.
Statistics of the behavior of the old and permanent generations.
Statistics of the sizes of the old generation.
Statistics of the sizes of the permanent generation.
Summary of garbage collection statistics.
HotSpot compilation method statistics.
- -h n
- 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.
- -t
- Display a timestamp column as the first column of output. The timestamp is 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 java - the Java application launcher
统计选项和输出
The following tables summarize the columns that jstat outputs for each statOption.
-class 选项——类加载器统计。该统计结果列的含义如下所示:
- Loaded。Number of classes loaded.
- Bytes。Number of Kbytes loaded.
- Unloaded。Number of classes unloaded.
- Bytes。Number of Kbytes unloaded.
- Time。Time spent performing class load and unload operations.
如:
# jstat -class 29165
Loaded Bytes Unloaded Bytes Time
7617 14307.7 0 0.0 4.07
-compiler 选项——HotSpot Just-In-Time 编译器统计。该统计结果列的含义如下所示:
- Compiled。Number of compilation tasks performed.
- Failed。Number of compilation tasks that failed.
- Invalid。Number of compilation tasks that were invalidated.
- Time。Time spent performing compilation tasks.
- FailedType。Compile type of the last failed compilation.
- FailedMethod。Class name and method for the last failed compilation.
如:
# jstat -compiler 29165
Compiled Failed Invalid Time FailedType FailedMethod
8665 0 0 28.78 0
-gc 选项——垃圾收集器堆统计。该统计结果列的含义如下所示:
- S0C。当前 survivor space 0 的总容量
- S1C。当前 survivor space 1 的总容量
- S0U。Survivor space 0 已经使用的容量
- S1U。Survivor space 1 已经使用的容量
- EC。当前 eden 区的总容量
- EU。Eden 区已经使用的容量
- OC。当前 old 区的总容量
- OU。Old 区 已经使用的容量
- PC。当前 permanent 区空间的总容量
- PU。Permanent 区已经使用的容量
- YGC。发生年轻代垃圾回收的次数
- YGCT。发生年轻代垃圾回收的总时间(总耗时)
- FGC。发生完全垃圾回收(full GC)的次数
- FGCT。发生完全垃圾回收(Full garbage)的总时间(总耗时)
- GCT。垃圾回收的总时间(总耗时),包括YGC和FGC
表中,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。该统计结果列的含义如下所示:
- NGCMN。新生代(new generation )容量的最小值
- NGCMX。新生代容量的最大值
- NGC。当前 new generation 容量
- S0C。当前 survivor space 0 的容量
- S1C。当前 survivor space 1 的容量
- EC。当前 eden space 容量
- OGCMN。old generation 容量的最小值
- OGCMX。old generation 容量的最大值
- OGC。当前 old generation 容量
- OC。当前 old space 容量
- PGCMN。permanent generation 容量的最小值
- PGCMX。Permanent generation 容量的最大值
- PGC。当前 Permanent generation 的容量
- PC。当前 Permanent space 的容量
- YGC。发生年轻代GC(Young generation GC)的次数
- FGC。发生 Full GC 的次数
-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:
- LGCC。最后一次垃圾回收的原因。最常见的是“Allocation Failure”(分配内存失败),不失败也不会发生垃圾回收啦~
- GCC。当前垃圾回收的原因
-gcnew 选项——新生代(New Generation)统计。该统计结果列的含义如下所示:
- S0C。当前 survivor space 0 的容量(单位为 KB)
- S1C。当前 survivor space 1 的容量(单位为 KB)
- S0U。Survivor space 0 utilization(单位为 KB)
- S1U。Survivor space 1 utilization(单位为 KB)
- TT。Tenuring threshold.
- MTT。Maximum tenuring threshold.
- DSS。Desired survivor size(单位为 KB)
- EC。当前 eden space 的容量(单位为 KB)
- EU。Eden space utilization(单位为 KB)
- YGC。发生 young generation GC 的次数
- YGCT。发生 young generation GC 的总时间(总耗时)
-gcnewcapacity 选项——New Generation Space Size StatisticsDescription。该统计结果列的含义如下所示:
- NGCMN。Minimum new generation capacity (KB).
- NGCMX。Maximum new generation capacity (KB).
- NGC。Current new generation capacity (KB).
- S0CMX。Maximum survivor space 0 capacity (KB).
- S0C。Current survivor space 0 capacity (KB).
- S1CMX。Maximum survivor space 1 capacity (KB).
- S1C。Current survivor space 1 capacity (KB).
- ECMX。Maximum eden space capacity (KB).
- EC。Current eden space capacity (KB).
- YGC。Number of young generation GC events.
- FGC。Number of Full GC Events.
-gcold 选项——Old and Permanent Generation Statistics。该统计结果列的含义如下所示:
- PC。Current permanent space capacity (KB).
- PU。Permanent space utilization (KB).
- OC。Current old space capacity (KB).
- OU。old space utilization (KB).
- YGC。Number of young generation GC events.
- FGC。Number of full GC events.
- FGCT。Full garbage collection time.
- GCT。Total garbage collection time.
-gcoldcapacity 选项——Old Generation Statistics。该统计结果列的含义如下所示:
- OGCMN。Minimum old generation capacity (KB).
- OGCMX。Maximum old generation capacity (KB).
- OGC。Current old generation capacity (KB).
- OC。Current old space capacity (KB).
- YGC。Number of young generation GC events.
- FGC。Number of full GC events.
- FGCT。Full garbage collection time.
- GCT。Total garbage collection time.
-gcpermcapacity Option——Permanent Generation Statistics。该统计结果列的含义如下所示:
- PGCMN。Minimum permanent generation capacity (KB).
- PGCMX。Maximum permanent generation capacity (KB).
- PGC。Current permanent generation capacity (KB).
- PC。Current permanent space capacity (KB).
- YGC。Number of young generation GC events.
- FGC。Number of full GC events.
- FGCT。Full garbage collection time.
- GCT。Total garbage collection time.
-gcutil 选项——垃圾回收统计概要。该统计结果列的含义如下所示:
- S0。Survivor space 0 utilization as a percentage of the space's current capacity.
- S1。Survivor space 1 utilization as a percentage of the space's current capacity.
- E。Eden space utilization as a percentage of the space's current capacity.
- O。Old space utilization as a percentage of the space's current capacity.
- P。Permanent space utilization as a percentage of the space's current capacity.
- YGC。Number of young generation GC events.
- YGCT。Young generation garbage collection time.
- FGC。Number of full GC events.
- FGCT。Full garbage collection time.
- GCT。Total garbage collection time.
-printcompilation 选项——HotSpot Compiler Method Statistics。该统计结果列的含义如下所示:
- Compiled。Number of compilation tasks performed by the most recently compiled method.
- Size。Number of bytes of bytecode of the most recently compiled method.
- Type。Compilation type of the most recently compiled method.
- Method。Class name and method name identifying the most recently compiled method. Class name uses "/" instead of "." as namespace separator. Method name is the method within the given class. The format for these two fields is consistent with the HotSpot - XX:+PrintComplation option.
示例
This section presents some examples of monitoring a local JVM with a lvmid of 21891.
使用 gcutil 选项
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.
Repeating the column header string
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.
Including a time stamp for each sample
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.
Monitor instrumentation for a remote JVM
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).
参考资料
Java 7 jstat – JVM Statistics Monitoring Tool【翻译】的更多相关文章
- jstat(JVM Statistics Monitoring Tool)
功能 用于监视虚拟机各种运行状态信息的命令行工具.它可以显示本地或远程虚拟机进程中的类装载.内存.垃圾收集.JIT编译等运行数据,在没有GUI图形界面,只提供了纯文本控制台环境的服务器上,它将是运 ...
- jstat命令(Java Virtual Machine Statistics Monitoring Tool)
1.介绍 Jstat用于监控基于HotSpot的JVM,对其堆的使用情况进行实时的命令行的统计,使用jstat我们可以对指定的JVM做如下监控: - 类的加载及卸载情况 - 查看新生代.老生代及持久代 ...
- Java 7 jps - JVM Process Status Tool
本文内容 语法 参数 描述 选项 主机标识符 输出格式 示例 参考资料 先发出来,然后慢慢翻译~ 语法 jps [ options ] [ hostid ] 参数 options 命令行参数. hos ...
- java命令--jstat 工具使用
jstat(JVM Statistics Monitoring Tool)是用于监控虚拟机各种运行状态信息的命令行工具.他可以显示本地或远程虚拟机进程中的类装载.内存.垃圾收集.JIT编译等运行数据, ...
- 十一、jdk命令之Jstatd命令(Java Statistics Monitoring Daemon)远程的监控工具连接到本地的JVM执行命令
目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...
- 十一、jdk命令之Jstatd命令(Java Statistics Monitoring Daemon)
目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...
- java tools: jstat
JavaScript is not supported by your browser. JavaScript support is required for full functionality o ...
- Java的jstat命令使用详解
jstat命令简介 jstat(Java Virtual Machine Statistics Monitoring Tool)是JDK提供的一个可以监控Java虚拟机各种运行状态信息的命令行工具.它 ...
- Java后端进阶-JVM参数调优
package com.study.performance; import org.springframework.boot.SpringApplication; import org.springf ...
随机推荐
- 万万没想到,3D打印居然可以做这些逆天设计
3D打印一直被冠以“高科技”头衔,似乎离我们的日常生活还很遥远.其实不然,随着技术的创新,3D打印技术逐渐深入各个领域,工业生产.商业.医学.建筑.艺术等领域都能看到3D打印技术的影子.它将会改变我们 ...
- marquee标签属性详解(跑马灯文字效果)
请大家先看下面这段代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: ...
- 2007Hanoi双塔问题
题目描述 Description 给定A.B.C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的尺寸,每个尺寸都有两个相同的圆盘,注意这两个圆盘是不加区分的(下图为n=3的情形).现 ...
- noip2014-day1-t2
题目描述:无向连通图G 有n 个点,n - 1 条边.点从1 到n 依次编号,编号为 i 的点的权值为W i ,每条边的长度均为1 .图上两点( u , v ) 的距离定义为u 点到v 点的最短距离. ...
- 从一个Fragment跳转到另一个Fragment
我们知道Activity之间的跳转可以使用 startActivity(intent).但Fragment之间的跳转却不能使用该方法,那该怎么办呢? 直接上代码: 核心代码 @Override//核心 ...
- 『TCP/IP详解——卷一:协议』读书笔记——01
从今日起开始认真研读TCP/IP详解这本经典制作,一是巩固我薄弱的计算机网络知识,二来提高我的假期的时间利用率.将心得与思考记录下来,防止白看-哦耶 2013-08-14 18:47:06 第一章 概 ...
- Duang的成长——使用造字程序输入生僻字
使用造字程序输入生僻字 最近,一个字突然间火了起来,那就是——duang! (图片来自网络) 那么,问题来了!造字程序哪家强?(此处有掌声) 其实,微软早就考虑到各国文字的博大精深,在系统中集成了一个 ...
- php url rewrite
1.检测Apache是否支持mod_rewrite 通过php提供的phpinfo()函数查看环境配置,通过Ctrl+F查找到“Loaded Modules”,其中列出了所有apache2handle ...
- Android View 如何绘制
上文说道了Android如何测量,但是一个漂亮的控件我只知道您长到哪儿,这当然不行.只需要简单重写OnDraw方法,并在Canvas(画布)对象上调用那根五颜六色的画笔就能够画出这控件"性感 ...
- 【原创】Windows Server 文件夹权限小问题
服务器:Windows Server 2008 R2 Standard 做文件服务器 问题:在资源管理器里给账号设置了R/W权限,但是一直有问题,写失败. 解决:需要在server manager-r ...