Accessing Remote JVM Processes with 'jstat'

This section provides a tutorial example on how to use the 'jstat' command with a RMI URL 'rmi://pid@host:port' to access a JVM process on a remote machine.

In the previous section, I used the "jstat" tool to get garbage collection statistic against a JVM process on the local machine.

Now I want to use the "jstat" tool to get garbage collection statistic against a JVM process on a remote machine. Like the "jps" tool, the "jstat" tool also requires that the remote machine running the "jstatd" server with a RMI registry.

1. Make sure that the "jstatd" server is running on the remote machine:

C:\herong>\Progra~1\java\jdk1.8.0\bin\jstatd -p 1234 
   -J-Djava.security.policy=tools.policy

2. Make sure that the garbage collection program is running on the remote machine:

C:\herong>\Progra~1\java\jdk1.8.0\bin\java 
   -Xms24m -Xmx24m GarbageCollection

Free/total memory:
23725256   25034752
22710400   25034752
...

3. Run the "jps" tool to get a list of JVM process IDs on the remote machine:

C:\herong>\Progra~1\java\jdk1.8.0\bin\jps -l -m -v 
   rmi://localhost:1234

2924 PrimeNumberSeeker 10 200
2544 sun.tools.jstatd.Jstatd -p 1234 -Dapplication.home=C:\jdk -Xms8m 
   -Djava.security.policy=tools.policy
3028 sun.tools.jps.Jps -l -m -v rmi://localhost:1234 
   -Dapplication.home=C:\Program Files\java\jdk1.8.0 -Xms8m
3536 GarbageCollection -Xms24m -Xmx24m

4. I am ready to run the "jstat" tool to get some statistics data on the garbage collection program:

C:\herong>\Progra~1\java\jdk1.8.0\bin\jstat -gcutil -t 
   rmi://3536@localhost:1234 1s 30

 Time     S0    S1     E     O    P  YGC  YGCT FGC   FGCT    GCT
303.6   0.00 99.99 86.29 97.66 0.15 2025 3.589 402 13.500 17.089
304.6  99.99  0.00 35.16 77.66 0.15 2032 3.597 404 13.559 17.155
305.6 100.00  0.00 51.20 90.69 0.15 2039 3.610 405 13.592 17.202
...

Cool. The "jstat" tool works nicely to get statistics data from a JVM process on a remote machine.

Last update: 2015.

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

'jstat' - JVM Statistics Monitoring Tool

 'jps' - JVM Process Status Tool

 Listing JVM Processes on the Local Machine with "jps"

 'jstatd' - JVM Remote Monitoring Server

 Starting 'jstatd' with a Security Policy File

 Connecting to 'jps' to Remote 'jstatd'

 'jstat' Command Options and Parameters

 Garbage Collection Testing Program

 'jstat -gcutil' - Garbage Collection Statistics

Accessing Remote JVM Processes with 'jstat'

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

 'jar' - The JAR File Tool

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 PDF Printing Version