JVM 统计信息监控 — jstat

jstat是用于监视虚拟机各种运行状态信息的命令行工具,它可以显示本地或者远程虚拟机进程中中的类装载,内存,垃圾收集,JIT编辑等运行数据。我们使用jstat -help 可以查看jstat的具体用法,如下所示:

Usage: jstat -help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Definitions:
  <option>      An option reported by the -options option
  <vmid>        Virtual Machine Identifier. A vmid takes the following form:
                     <lvmid>[@<hostname>[:<port>]]
                Where <lvmid> is the local vm identifier for the target
                Java virtual machine, typically a process id; <hostname> is
                the name of the host running the target Java virtual machine;
                and <port> is the port number for the rmiregistry on the
                target host. See the jvmstat documentation for a more complete
                description of the Virtual Machine Identifier.
  <lines>       Number of samples between header lines.
  <interval>    Sampling interval. The following forms are allowed:
                    <n>["ms"|"s"]
                Where <n> is an integer and the suffix specifies the units as 
                milliseconds("ms") or seconds("s"). The default units are "ms".
  <count>       Number of samples to take before terminating.
  -J<flag>      Pass <flag> directly to the runtime system.

详细用法中jstat -help 可以查看该命令的使用详情,而jstat -options则用于查看JVM的各种信息。jstat的命令格式为:

jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]。

其中参数vmid为进程id,当查看的为远程虚拟机的时候的时候为 [protocol:][//]vmid@ip:port/servername。参数interval和count代表查询时间间隔和查询次数。如果省略这两个参数,说明只查询一次。参数option代表用户希望查询的虚拟机信息,主要分为类装载,垃圾收集,运行期编译情况。如下为option的详细描述:

-class 监视类装载,卸载数量,总空间以及类装载所耗费的时间。
 监视3071进程的类装载类信息,每隔两秒输出一次,共输出两次
 jstat -class 3071 2000 2 
 Loaded  Bytes  Unloaded  Bytes     Time   
 13037 27557.3      320   773.4      14.62
 13037 27557.3      320   773.4      14.62
 
 Loaded 已加载数量 Bytes 所占字节数 Unloaded 未加载数量 Time 加载耗时
-gc 监视java堆状况,包括Eden区,两个surivivor区,老年代,永久代等容量,已使用空间,GC时间合计等信息。
jstat -gc 3071 2000 1
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT   
1216.0 1216.0  0.0   749.8  72960.0  18768.3   150040.0   89445.2   155972.0 93480.1    331    4.178  151    80.582   84.760
-gccapacity 监视内容与-gc基本相同,但输出主要关注Java堆各个区域使用到的最大、最小空间。
jstat -gccapacity  3071 2000 1
NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC      PGCMN    PGCMX     PGC       PC     YGC    FGC 
2176.0 349504.0  75392.0 1216.0 1216.0  72960.0     4416.0   699072.0   150040.0   150040.0  21248.0 196608.0 155972.0 155972.0    331   151
-gcutil 监视内容与-gc基本相同,但输出主要关注已使用空间占总空间的百分比
jstat -gcutil  3071 2000 1
 S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
  0.00  61.66  29.10  59.61  59.93    331    4.178   151   80.582   84.760
-gccause 与-gcutil一致,但会额外输出上次GC产生的原因
jstat -gccause  3071 2000 1
S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT    LGCC                 GCC                 
0.00   0.00  11.97  59.63  59.93    331    4.178   152   81.235   85.413 System.gc()          No GC 
-gcnew 监视新生代GC状况
jstat -gcnew  3071 2000 1
S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
1216.0 1216.0    0.0    0.0  1  15  608.0  72960.0   9844.6    331    4.178
-gcnewcapacity 监视内容与-gcnew基本相同,输出主要关注用到的最大、最小空间
jstat -gcnewcapacity  3071 2000 1
NGCMN      NGCMX       NGC      S0CMX     S0C     S1CMX     S1C       ECMX        EC      YGC   FGC 
2176.0   349504.0    75392.0   1216.0   5824.0   5824.0   1216.0   337856.0    72960.0   331   152
-gcold 监视老年代GC状况
jstat -gcold  3071 2000 1
 PC       PU        OC          OU       YGC    FGC    FGCT     GCT   
155972.0  93480.1    150040.0     89464.1    331   152   81.235   85.413
-gcoldcapacity 监视内容与-gcold基本相同,输出主要关注用到的最大、最小空间
jstat -gcoldcapacity  3071 2000 1
OGCMN       OGCMX        OGC         OC       YGC   FGC    FGCT     GCT   
4416.0    699072.0    150040.0    150040.0   331   152   81.235   85.413
-gcpermcapacity 输出永久代主要关注用到的最大、最小空间
jstat -gcpermcapacity  3071 2000 1
PGCMN      PGCMX       PGC         PC      YGC   FGC    FGCT     GCT   
21248.0   196608.0   155972.0   155972.0   331   152   81.235   85.413
-compiler 输出JIT编译器编译过的方法、耗时的等信息
jstat -compiler  3071 2000 1
Compiled Failed Invalid   Time   FailedType FailedMethod
 1463      1       0    28.84          1    com/sun/enterprise/admin/meta/MBeanMetaHelper mergeWithConfigBean
-printcompilation 输出已经被JIT编译的方法
jstat -printcompilation   3071 2000 1
Compiled  Size  Type Method
1463      573    1   java/util/logging/Logger findResourceBundle

至于标题头的意思,不想做太多解释,因为实在太对了,重点是掌握英文缩写,比如:OC中的 O代表Old,C代表Capacity,合起来表示当前老年代容量大小。其他的具体的意思可以查看官方文档:jstat。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值