jvmstat介绍
jvmstat Tools Installation
The jvmstat tools distribution is released in both tar and zip formats. There is a single distribution for all supported platforms. These instructions will guide you though the installation process using the Korn Shell on Solaris, Linux, and for the Korn Shell in the MKS Tookit for Windows. Every effort has been made to use shell commands that are compatible with both the Bourne and Korn shells. You may need to adapt these instructions to your preferred shell.
In the following instructions, the>character represents the shell's command prompt and the commands you enter to the shell are indicated by text typeset inbold. These instructions will also contain references toJVMSTAT_HOMEandJAVA_HOMEstrings. Although these appear to be environment variables at first glance, they are intended to be substituted with the paths to the installation directories for jvmstat and the Java 2 JDK, respectively. You may choose to create environment variables with these names; however, they are not required for proper installation or operation of the jvmstat tools.
Step 1: Open a shell window
>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>
Step 2: Select Installation Directory
Step 3: Install the jvmstat distribution
To install the distribution, perform. the following steps.
Change your working directory to the installation directory.
Verify that either the.zipor.tarjvmstat distribution file is located in the current directory:
If you are installing thetarfile, enter the following
If you are installing thezipfile, enter the following
>rm jvmstat-3.0_b03.tar jvmstat-3.0_b03.zip
>ls -FC jvmstat
bat/ bin/ docs/ etc/ jars/
Step 4: Set Environment Variables
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
Step 5: Install the jstatd policy file
Thejstatdtool 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, thejstatdserver installs an instance of the RMI security manager and therefore requires a security policy file. TheJ2SE 5.0jstatddocumentationdescribes a simpile security policy that provides unlimited access to classes loaded from thetools.jararchive.
First, create a file calledjstatd.policyusing your favorite text editor. The file should contain the following text:
Thejstatd.policyfile can reside in any directory you choose. The instructions that follow assume that thejstatd.policyfile is located in the/home/userdirectory.
Step 6: Test the installation
Now that your jvmstat distribution is installed and configured, let's run some tests.
The output from thejstatcommand should be similar to the output shown above. If an error message or exception is output, then proceed to thetrouble shootingsection below.
>java -jarJAVA_HOME/demo/jfc/Java2D/Java2Demo.jar
Once the target Java application is running, execute thejpscommand from a separate cmdtool, dtterm, or xterm windows and find thelvmidfor the target JVM. Remember, you need to set the PATH environment variable in this new window as described inSet Environment Variablessection above.
>jps
23551 Java2Demo.jar
23581 Jps
It's typical to seeJpslisted in the output of thejpscommand. Next, runjstat, telling it to monitorlvmid23551, taking 3 samples at one second intervals:
>jstat -gcutil 23551 1000 3
The output fromjstatis omitted here; however, it should be similar to the output observed in theSimple Testsection above.
Now, runvisualgctelling it to monitorlvmid23551:
>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 thevisualgc manual page. If an error message or exception is output, then proceed to thetrouble shootingsection 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 aremonitoredfor the system running the target application andmonitoringfor the system running the jvmstat tools.
Onmonitored, startup thejstatdserver and the target Java application. Once again, we will use the Java2Demo application as our target Java application. Thejstatdserver is started as follows:
>jstatd -J-Djava.security.policy=/home/user/jstatd.policy
Now, from a cmdtool, dtterm, or xterm window onmonitoring, run thejpscommand to discover thelvmisof the target Java application. Substitute the name of your monitored system formonitoredin the following commands.
>jps monitored
17869 Java2Demo.jar
17876 Jstatd
17877 Jps
It's typical to see bothJpsandJstatdlisted in the output of thejpscommand. Next, runjstat, telling it to monitorlvmid17869 on the system namedmonitored, taking 3 samples at one second intervals.
>jstat -gcutil 17869@monitored 1000 3
The output fromjstatis omitted here; however, it should be similar to the output observed in theSimple Testsection above.
Now, runvisualgctelling it to monitorlvmid17869 on the system namedmonitored:
>visualgc 17869@monitored
Two or three windows will appear as decribed in theLocal Testsection above.
Terminating Processes
You may want to terminate the processes we started in the above tests. Thejstatdprocess can be terminated as follows:
>kill 17876
Where17876
is the process id reported by the nativepscommand or thelvmidreported by thejpscommand as shown above.
Trouble Shooting
If you experience error messages or exceptions from any of the jvmstat tools, check that your PATH variable is set correctly. Also, check themanual pagesfor the tools for proper usage. If these suggestions do not resolve your problems, consult thejvmstat FAQ. If the jvmstat FAQ does not provide a resolution for the problem you are experencing, then send an e-mail tojvmstat-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.
S0 S1 E O P YGC YGCT FGC FGCT GCT 0.00 0.00 37.20 55.10 15.77 106 0.174 58 5.268 5.442 0.00 0.00 45.87 55.14 15.77 106 0.174 59 5.357 5.531 0.00 0.00 96.42 55.14 15.77 106 0.174 59 5.357 5.531
grant codebase "file:${java.home}/../lib/tools.jar" { permission java.security.AllPermission; };
转:http://517sou.net/Article/379.aspx
TAG:
标题搜索
日历
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
1 | 2 | 3 | 4 | ||||||
5 | 6 | 7 | 8 | 9 | 10 | 11 | |||
12 | 13 | 14 | 15 | 16 | 17 | 18 | |||
19 | 20 | 21 | 22 | 23 | 24 | 25 | |||
26 | 27 | 28 | 29 | 30 | 31 |
我的存档
数据统计
- 访问量: 9029
- 日志数: 21
- 文件数: 4
- 书签数: 11
- 建立时间: 2009-12-02
- 更新时间: 2013-09-05