jstat 유틸

  • jstat 유틸을 이용하면 JVM상태를 상세하게 모니터링 할 수 있다.

사용방법

  • jstat 사용법
jstat [일반옵션|출력옵션 vmid[간격[수행횟수]]]
jstat [ generalOption | outputOptions vmid [interval[s|ms] [count]] ]
  • 아래와 같이 사용하면 된다.
    • gcutil 옵션으로 5초 간격으로 JVM 상태 조회하는 예제이다.
    • 11459는 리눅스에서 JAVA 프로세스 아이디이다.
    • 윈도우에서도 동일하게 프로세스 아이디를 조회하여 사용하면 된다.
oracleclub@localhost~]$ jstat -gcutil 11459 5s


  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT  
  0.00  63.38  14.21  29.96  99.94    115    9.854     0    0.000    9.854
  0.00  63.38  28.20  29.96  99.70    115    9.854     0    0.000    9.854
  0.00  63.38  29.39  29.96  99.70    115    9.854     0    0.000    9.854
  0.00  63.38  29.80  29.96  99.70    115    9.854     0    0.000    9.854
  0.00  63.38  32.29  29.96  99.70    115    9.854     0    0.000    9.854
  • gcutil 옵션의 값 설명
    • S0 : Survivor 0 영역
    • S1 : Survivor 1 영역
    • E : Eden 영역, Young Area (Miner GC)
    • O : Old 영역, (Mager GC)
    • P : Permanent Area
    • YGC : Young GC Count
    • YGCT : Young GC Time Total
    • FGC : Full GC Count
    • FGCT : Full GC Time Total
    • GCT : Young GC + Full GC

jstats 옵션 조회

  • 아래와 같이 -options 으로 조회 할 수 있다.
oracleclub@localhost~]$ jstat -options
  
-class : 클래스 로딩 통계정보
-compiler
-gc
-gccapacity
-gccause
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcpermcapacity
-gcutil
-printcompilation
  • 아래는 gccapacity 옵션의 예이다.
oracleclub@localhost~]$ jstat -gccapacity  11459 5s

 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC      PGCMN    PGCMX     PGC       PC     YGC    FGC
349504.0 349504.0 349504.0 3712.0 3648.0 342144.0   699072.0   699072.0   699072.0   699072.0  16384.0 262144.0  40448.0  40448.0    116     0
349504.0 349504.0 349504.0 3712.0 3648.0 342144.0   699072.0   699072.0   699072.0   699072.0  16384.0 262144.0  40448.0  40448.0    116     0
349504.0 349504.0 349504.0 3712.0 3648.0 342144.0   699072.0   699072.0   699072.0   699072.0  16384.0 262144.0  40448.0  40448.0    116     0
349504.0 349504.0 349504.0 3712.0 3648.0 342144.0   699072.0   699072.0   699072.0   699072.0  16384.0 262144.0  40448.0  40448.0    116     0
349504.0 349504.0 349504.0 3712.0 3648.0 342144.0   699072.0   699072.0   699072.0   699072.0  16384.0 262144.0  40448.0  40448.0    116     0
349504.0 349504.0 349504.0 3712.0 3648.0 342144.0   699072.0   699072.0   699072.0   699072.0  16384.0 262144.0  40448.0  40448.0    116     0

문서정보







1. ps -ef | grep java로 pid알아내기

2. 아래와같이 확인

 jstat -gcutil -h20 -t 7251 3000 3000

      -> gcutil : gcutil 에 대해서 수행

      -> -h20 : 20라인마다 header 찍음

      -> -t : time stamp 프린트(JVM 이 스타트 된 이후의 시간)

      -> 7251 : 프로세스 id

      -> 3000 : interval (ms 단위)

      -> 3000 : count

[출처] jstat로 jvm모니터링하기|작성자 GoGo


출처 -  http://blog.naver.com/oshnew?Redirect=Log&logNo=10101015818 











. jstat 수행 방법
   - 우선 모니터링 하고자 하는 프로세스의 ID 를 확인합니다.
      확인하는 방법은 ps -ef | grep java 로 확인을 해도 되고, 프롬프트 상태에서 jps 라고 입력한 뒤 엔터를 치면 해당 JVM에서 수행된 프로세스의 ID를 보여줍니다.
      (jps 사용시에는 PATH에 해당 JDK가 설정되어 있어야 합니다.
 
 

  - 두번째로 jstat 명령을 수행 합니다.

      jstat -gcutil -h20 -t 7251 3000 3000

      -> gcutil : gcutil 에 대해서 수행

      -> -h20 : 20라인마다 header 찍음

      -> -t : time stamp 프린트(JVM 이 스타트 된 이후의 시간)

      -> 7251 : 프로세스 id

      -> 3000 : interval (ms 단위)

      -> 3000 : count
 
 - 수행 결과
 
2. 각각의 항목 설명

  - S0 Survivor 영역 0 의 사용율 (현재의 용량에 대한 퍼센티지)

  - S1 Survivor 영역 1 의 사용율 (현재의 용량에 대한 퍼센티지)

  - Eden 영역의 사용율 (현재의 용량에 대한 퍼센티지)

  - Old 영역의 사용율 (현재의 용량에 대한 퍼센티지)

  - Permanent 영역의 사용율 (현재의 용량에 대한 퍼센티지)

  - YGC Young 세대의 GC 이벤트수

  - YGCT Young 세대의 가베지 콜렉션 시간

  - FGC 풀 GC 이벤트수

  - FGCT 풀 가베지 콜렉션 시간

  - GCT : 가베지 콜렉션총시간
 
3. 샘플

  >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

 

    이 예의 출력은, Young 세대의 콜렉션이 3 번째와 4 번째의 샘플간에 행해진 것을 나타내고 있습니다.

    콜렉션에는 0.001 초 걸리고 있어 오브젝트가 Eden 영역 (E)으로부터 Old 영역 (O)에 승격했기 때문에,

    Old 영역의 사용율은 9.49% 에서 9.51% 에 증가하고 있습니다.

    Survivor 영역은, 콜렉션전은 12.44% 가 사용되고 있었습니다만, 콜렉션 후는 7.74% 밖에 사용되고 있지 않습니다.

 

실시간으로 메모리 사용을 좀 확인해야 하는 상황에서는 위와 같이 jstat 로 간단하게 모니터링을 수행하면

현재의 JVM 메모리 사용 상황을 확인이 가능할 것 같습니다.

 

가장 정확한 건 GC 로그를 별도의 파일로 출력하게 해서 분석하는 것이지만, 이럴 경우에는 실시간으로 확인이 힘들기 때문에

위와 같이 사용하는 것도 괜찮은 방법 중의 하나일 것 같습니다.

물론 JVM 에 계속 request 를 보내기 때문에 부하가 있을 듯 하지만, 지금 생각으로는 크게 영향은 미치지 않을 듯 하네요..

영향이 고려되면 interval을 좀 조정하든지 하면 될 듯 합니다.

출처 -  http://blog.naver.com/solvage?Redirect=Log&logNo=10038025715 





[root@CentOS ~]# jstat
invalid argument count
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.

여기서  vmid는 Virtual Machine Identifier 이다.

그래서 Virtual Machine Identifier 부분을 0으로 설정

[root@CentOS5 ~]# jstat -gcutil 0 5s
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
  0.00  58.05  73.05   0.00   2.80      1    0.006     0    0.000    0.006
  0.00  58.05  73.05   0.00   2.88      1    0.006     0    0.000    0.006
  0.00  58.05  75.01   0.00   2.88      1    0.006     0    0.000    0.006
  0.00  58.05  75.01   0.00   2.88      1    0.006     0    0.000    0.006
  0.00  58.05  76.97   0.00   2.88      1    0.006     0    0.000    0.006
  0.00  58.05  76.97   0.00   2.88      1    0.006     0    0.000    0.006

 





Java Platform, Standard Edition Tools Reference
Contents    Previous    Next


jstat

Monitors Java Virtual Machine (JVM) statistics. This command is experimental and unsupported.

Synopsis

jstat [ generalOption | outputOptions vmid [ interval[s|ms] [ count ] ]

generalOption

A single general command-line option -help or -options. See General Options.

outputOptions

One or more output options that consist of a single statOption, plus any of the -t-h, and -J options. See Output Options.

vmid

Virtual machine identifier, which is a string that indicates the target JVM. The general syntax is the following:

[protocol:][//]lvmid[@hostname[:port]/servername]

The syntax of the vmid string corresponds to the syntax of a URI. The vmid string can vary from a simple integer that represents a local JVM to a more complex construction that specifies a communications protocol, port number, and other implementation-specific values. See Virtual Machine Identifier.

interval [s|ms]

Sampling interval in the specified units, seconds (s) or milliseconds (ms). Default units are milliseconds. Must be a positive integer. When specified, the jstat command produces its output at each interval.

count

Number of samples to display. The default value is infinity which causes the jstat command to display statistics until the target JVM terminates or the jstat command is terminated. This value must be a positive integer.

Virtual Machine Identifier

The syntax of the vmid string corresponds to the syntax of a URI:

[protocol:][//]lvmid[@hostname[:port]/servername]
protocol

The communications protocol. If the protocol value is omitted and a host name is not specified, then the default protocol is a platform-specific optimized local protocol. If the protocol value is omitted and a host name 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 the lvmid on Solaris, Linux, and OS X platforms with the ps command, and on Windows with the Windows Task Manager.

hostname

A hostname or IP address that indicates the target host. If the hostname value is omitted, then the target host is the local host.

port

The default port for communicating with the remote server. If the hostname value is omitted or the protocol value specifies an optimized, local protocol, then the port value is ignored. Otherwise, treatment of the port parameter is implementation-specific. For the default rmi protocol, the port value indicates the port number for the rmiregistry on the remote host. If the port value is omitted and the protocol value indicates rmi, then the default rmiregistry port (1099) is used.

servername

The treatment of the servername 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 the jstat command to display simple usage and version information. Output options determine the content and format of the statistical output.

All options and their functionality are subject to change or removal in future releases.

Output Options

If you do not specify a general option, then you can specify output options. Output options determine the content and format of the jstat command'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 that 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 consistent among the different options. In general, if two options provide a column with the same name, then the data source for the two columns is 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 the target JVM started. 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, the jstat command displays its output.

Note: Do not to write scripts to parse the jstat command's output because the format might change in future releases. If you write scripts that parse jstat command output, then expect to modify them for future releases of this tool.

-statOption

Determines the statistics information the jstat command displays. The following lists the available options. Use the -options general option to display the list of options for a particular platform installation. See Stat Options and Output.

class: Displays statistics about the behavior of the class loader.

compiler: Displays statistics about the behavior of the Java HotSpot VM Just-in-Time compiler.

gc: Displays statistics about the behavior of the garbage collected heap.

gccapacity: Displays statistics about the capacities of the generations and their corresponding spaces.

gccause: Displays a summary about garbage collection statistics (same as -gcutil), with the cause of the last and current (when applicable) garbage collection events.

gcnew: Displays statistics of the behavior of the new generation.

gcnewcapacity: Displays statistics about the sizes of the new generations and its corresponding spaces.

gcold: Displays statistics about the behavior of the old generation and metaspace statistics.

gcoldcapacity: Displays statistics about the sizes of the old generation.

gcmetacapacity: Displays statistics about the sizes of the metaspace.

gcutil: Displays a summary about garbage collection statistics.

printcompilation: Displays Java HotSpot VM compilation method statistics.

-h n

Displays a column header every n samples (output rows), where n is a positive integer. Default value is 0, which displays the column header the first row of data.

-t

Displays a timestamp column as the first column of output. The time stamp is the time since the start time of the target JVM.

-JjavaOption

Passes javaOption to the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. For a complete list of options, see java(1).

Stat Options and Output

The following information summarizes the columns that the jstat command outputs for each statOption.

-class option

Class loader statistics.

Loaded: Number of classes loaded.

Bytes: Number of kBs loaded.

Unloaded: Number of classes unloaded.

Bytes: Number of Kbytes unloaded.

Time: Time spent performing class loading and unloading operations.

-compiler option

Java HotSpot VM Just-in-Time compiler statistics.

Compiled: Number of compilation tasks performed.

Failed: Number of compilations tasks 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 of the last failed compilation.

-gc option

Garbage-collected heap statistics.

S0C: Current survivor space 0 capacity (kB).

S1C: Current survivor space 1 capacity (kB).

S0U: Survivor space 0 utilization (kB).

S1U: Survivor space 1 utilization (kB).

EC: Current eden space capacity (kB).

EU: Eden space utilization (kB).

OC: Current old space capacity (kB).

OU: Old space utilization (kB).

MC: Metaspace capacity (kB).

MU: Metacspace utilization (kB).

CCSC: Compressed class space capacity (kB).

CCSU: Compressed class space used (kB).

YGC: Number of young generation garbage collection events.

YGCT: Young generation garbage collection time.

FGC: Number of full GC events.

FGCT: Full garbage collection time.

GCT: Total garbage collection time.

-gccapacity option

Memory pool generation and space capacities.

NGCMN: Minimum new generation capacity (kB).

NGCMX: Maximum new generation capacity (kB).

NGC: Current new generation capacity (kB).

S0C: Current survivor space 0 capacity (kB).

S1C: Current survivor space 1 capacity (kB).

EC: Current eden space capacity (kB).

OGCMN: Minimum old generation capacity (kB).

OGCMX: Maximum old generation capacity (kB).

OGC: Current old generation capacity (kB).

OC: Current old space capacity (kB).

MCMN: Minimum metaspace capacity (kB).

MCMX: Maximum metaspace capacity (kB).

MC: Metaspace capacity (kB).

CCSMN: Compressed class space minimum capacity (kB).

CCSMX: Compressed class space maximum capacity (kB).

CCSC: Compressed class space capacity (kB).

YGC: Number of young generation GC events.

FGC: Number of full GC events.

-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 (when applicable) the current garbage collection event. In addition to the columns listed for -gcutil, this option adds the following columns.

LGCC: Cause of last garbage collection

GCC: Cause of current garbage collection

-gcnew option

New generation statistics.

S0C: Current survivor space 0 capacity (kB).

S1C: Current survivor space 1 capacity (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: Current eden space capacity (kB).

EU: Eden space utilization (kB).

YGC: Number of young generation GC events.

YGCT: Young generation garbage collection time.

-gcnewcapacity option

New generation space size statistics.

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 option

Old generation and metaspace behavior statistics.

MC: Metaspace capacity (kB).

MU: Metaspace utilization (kB).

CCSC: Compressed class space capacity (kB).

CCSU: Compressed class space used (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 option

Old generation size 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.

-gcmetacapacity option

Metaspace size statistics.

MCMN: Minimum metaspace capacity (kB).

MCMX: Maximum metaspace capacity (kB).

MC: Metaspace capacity (kB).

CCSMN: Compressed class space minimum capacity (kB).

CCSMX: Compressed class space maximum 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 option

Summary of garbage collection statistics.

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.

M: Metaspace utilization as a percentage of the space's current capacity.

CCS: Compressed class space utilization as a percentage.

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 option

Java HotSpot VM compiler method statistics.

Compiled: Number of compilation tasks performed by the most recently compiled method.

Size: Number of bytes of byte code 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 slash (/) instead of dot (.) as a name space separator. Method name is the method within the specified class. The format for these two fields is consistent with the HotSpot -XX:+PrintCompilation option.

Examples

This section presents some examples of monitoring a local JVM with an lvmid of 21891.

The gcutil Option

This example attaches to lvmid 21891 and takes 7 samples at 250 millisecond intervals and displays the output as specified by the -gcutil option.

The output of this example shows that a young generation collection occurred between the third and fourth sample. The collection took 0.078 seconds and promoted objects from the eden space (E) to the old space (O), resulting in an increase of old space utilization from 66.80% to 68.19%. Before the collection, the survivor space was 97.02% utilized, but after this collection it is 91.03% utilized.

jstat -gcutil 21891 250 7
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
  0.00  97.02  70.31  66.80  95.52  89.14      7    0.300     0    0.000    0.300
  0.00  97.02  86.23  66.80  95.52  89.14      7    0.300     0    0.000    0.300
  0.00  97.02  96.53  66.80  95.52  89.14      7    0.300     0    0.000    0.300
 91.03   0.00   1.98  68.19  95.89  91.24      8    0.378     0    0.000    0.378
 91.03   0.00  15.82  68.19  95.89  91.24      8    0.378     0    0.000    0.378
 91.03   0.00  17.80  68.19  95.89  91.24      8    0.378     0    0.000    0.378
 91.03   0.00  17.80  68.19  95.89  91.24      8    0.378     0    0.000    0.378

Repeat the Column Header String

This example attaches to lvmid 21891 and takes samples at 250 millisecond intervals and displays the output as specified by -gcnew option. In addition, it uses the -h3 option to output the column header after every 3 lines of data.

In addition to showing the repeating header string, this example shows that between the second and third samples, a young GC occurred. Its duration was 0.001 seconds. The collection found enough active data that the survivor space 0 utilization (S0U) 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 fifth and sixth samples. This collection found very few survivors and returned the tenuring threshold to 31.

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

Include 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.

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 or promotion demands. The old generation capacity (OGC) has grown from 11,696 kB to 13,820 kB after the eighty-first full garbage collection (FGC). The maximum capacity of the generation (and space) is 60,544 kB (OGCMX), so it still has room to expand.

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



source - https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html





Java Platform, Standard Edition Tools Reference
Contents    Previous    Next


jstatd

Monitors Java Virtual Machines (JVMs) and enables remote monitoring tools to attach to JVMs. This command is experimental and unsupported.

Options

-nr

Does not attempt to create an internal RMI registry within the jstatd process when an existing RMI registry is not found.

-p port

The port number where the RMI registry is expected to be found, or when not found, created if the -nr option is not specified.

-n rminame

Name to which the remote RMI object is bound in the RMI registry. The default name is JStatRemoteHost. If multiple jstatd servers are started on the same host, then the name of the exported RMI object for each server can be made unique by specifying this option. However, doing so requires that the unique server name be included in the monitoring client's hostid and vmid strings.

-Joption

Passes option to the JVM, where option is one of the options described on the reference page for the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. See java(1).

Security

The jstatd server can only monitor JVMs for which it has the appropriate native access permissions. Therefore, the jstatd process must be running with the same user credentials as the target JVMs. Some user credentials, such as the root user in Solaris, Linux, and OS X operating systems, have permission to access the instrumentation exported by any JVM on the system. A jstatd process running with such credentials can monitor any JVM on the system, but introduces additional security concerns.

The jstatd server does not provide any authentication of remote clients. Therefore, running a jstatd server process exposes the instrumentation export by all JVMs for which the jstatd process has access permissions to any user on the network. This exposure might be undesirable in your environment, and therefore, local security policies should be considered before you start the jstatd process, particularly in production environments or on networks that are not secure.

The jstatd server installs an instance of RMISecurityPolicy when no other security manager is installed, and therefore, requires a security policy file to be specified. The policy file must conform to Default Policy Implementation and Policy File Syntax at
http://docs.oracle.com/javase/8/docs/technotes/guides/security/PolicyFiles.html

The following policy file allows the jstatd server to run without any security exceptions. This policy is less liberal than granting all permissions to all code bases, but is more liberal than a policy that grants the minimal permissions to run the jstatd server.

grant codebase "file:${java.home}/../lib/tools.jar" {   
    permission java.security.AllPermission;
};

To use this policy setting, copy the text into a file called jstatd.all.policy and run the jstatd server as follows:

jstatd -J-Djava.security.policy=jstatd.all.policy

For sites with more restrictive security practices, it is possible to use a custom policy file to limit access to specific trusted hosts or networks, though such techniques are subject to IP address spoofing attacks. If your security concerns cannot be addressed with a customized policy file, then the safest action is to not run the jstatd server and use the jstat and jps tools locally.

Examples

The following are examples of the jstatd command. The jstatd scripts automatically start the server in the background



source - https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstatd.html





'Development > Java' 카테고리의 다른 글

ClassLoader 문제 분석  (0) 2012.02.02
BTrace  (0) 2012.02.02
java.lang.OutOfMemoryError: PermGen space  (0) 2012.02.02
스윙(Swing)  (0) 2012.01.30
JCA(Java EE Connector Architecture)  (0) 2012.01.27
Posted by linuxism
,