If you have not already downloaded and installed the J2SE 5.0 JDK, please do so now. Follow the J2SE 5.0 JDK download and installation instructions. Once you have a working J2SE 5.0 JDK installation, continue with jvmstat Tools Installation. Note that the J2SE 5.0 JRE does not contain the class files need to run the jvmstat 3.0 tools. You must download the J2SE 5.0 JDK to run the jvmstat 3.0 tools.
> PATH=$PATH:<path to tar/unzip directory>
> export PATH
> PATH=$PATH:JAVA_HOME/bin
> export PATH
The above assumes that a version of the J2SE JRE or JDK is not already found in the user's PATH.
> PATH=$PATH\;<path to tar/unzip directory>
To install the distribution, perform the following steps.
Change your working directory to the installation directory.
Verify that either the .zip or .tar jvmstat distribution file is located in the current directory:
If you are installing the tar file, enter the following
If you are installing the zip file, enter the following
> rm jvmstat-3.0_b03.tar jvmstat-3.0_b03.zip
> ls -FC jvmstat
bat/ bin/ docs/ etc/ jars/
Set your PATH variable to include the jvmstat and J2SE 5.0 SDK bin directories
> PATH=JVMSTAT_HOME/bin:JAVA_HOME/bin:$PATH
> export PATH
> PATH=JVMSTAT_HOME/bin\;JAVA_HOME/bin\;$PATH>
> export PATH
The jstatd tool is an RMI based server that ships with the J2SE 5.0 SDK and allows the various jvmstat tools to remotely monitor target JVM processes. By default, the jstatd server installs an instance of the RMI security manager and therefore requires a security policy file. The J2SE 5.0 jstatd documentation describes a simpile security policy that provides unlimited access to classes loaded from the tools.jar archive.
First, create a file called jstatd.policy using your favorite text editor. The file should contain the following text:
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
The jstatd.policy file can reside in any directory you choose. The instructions that follow assume that the jstatd.policy file is located in the /home/user directory.
Now that your jvmstat distribution is installed and configured, let's run some tests.
The output from the jstat command should be similar to the output shown above. If an error message or exception is output, then proceed to the trouble shooting section below.
> java -jar JAVA_HOME/demo/jfc/Java2D/Java2Demo.jar
Once the target Java application is running, execute the jps command from a separate cmdtool, dtterm, or xterm windows and find the lvmid for the target JVM. Remember, you need to set the PATH environment variable in this new window as described in Set Environment Variables section above.
> jps
23551 Java2Demo.jar
23581 Jps
It's typical to see Jps listed in the output of the jps command. Next, run jstat, telling it to monitor lvmid 23551, taking 3 samples at one second intervals:
> jstat -gcutil 23551 1000 3
The output from jstat is omitted here; however, it should be similar to the output observed in the Simple Test section above.
Now, run visualgc telling it to monitor lvmid 23551:
> visualgc 23551
Two or three windows will appear (depending on which garbage collection policy is in effect). The following two windows will appear regardless of the garbage collection policy:
Descriptions of the various panels in these windows are provided in the visualgc manual page. If an error message or exception is output, then proceed to the trouble shooting section below.
Remote test
This test will verify that the remote monitoring functionality is working. This test can be run on one system, but it is better to run it on two systems. For a two system test, you will need to perform the installation of the jvmstat tools on the second system before proceeding with this test.
For this test, we will assume that the system names are monitored for the system running the target application and monitoring for the system running the jvmstat tools.
On monitored, startup the jstatd server and the target Java application. Once again, we will use the Java2Demo application as our target Java application. The jstatd server is started as follows:
> jstatd -J-Djava.security.policy=/home/user/jstatd.policy
Now, from a cmdtool, dtterm, or xterm window on monitoring, run the jps command to discover the lvmis of the target Java application. Substitute the name of your monitored system for monitored in the following commands.
> jps monitored
17869 Java2Demo.jar
17876 Jstatd
17877 Jps
It's typical to see both Jps and Jstatd listed in the output of the jps command. Next, run jstat, telling it to monitor lvmid 17869 on the system named monitored, taking 3 samples at one second intervals.
> jstat -gcutil 17869@monitored 1000 3
The output from jstat is omitted here; however, it should be similar to the output observed in the Simple Test section above.
Now, run visualgc telling it to monitor lvmid 17869 on the system named monitored:
> visualgc 17869@monitored
Two or three windows will appear as decribed in the Local Test section above.
Terminating Processes
You may want to terminate the processes we started in the above tests. The jstatd process can be terminated as follows:
> kill 17876
Where 17876 is
the process id reported by the native ps command or the
lvmid reported by the jps command as shown above.
If you experience error messages or exceptions from any of the jvmstat tools, check that your PATH variable is set correctly. Also, check the manual pages for the tools for proper usage. If these suggestions do not resolve your problems, consult the jvmstat FAQ. If the jvmstat FAQ does not provide a resolution for the problem you are experencing, then send an e-mail to jvmstat-support@sun.com. Please include the J2SE JDK version information (java -version) and the jvmstat version information (visualgc -version) in the e-mail along with a description of the problem you are experiencing.