Tuesday, March 5, 2013

Date Command                                    Cron Job in Linux

In Linux, we are using the ps command to check process information and to check machine's performance we use top command. But some times, in case of java processes, we need more information. These commands are not sufficient to get that much of information of particular java process.

Depends on your requirement you can use following commands to get required information of particular java processes.  Jstat, Jmap, Jinfo commands are very useful to analyze to java process performance as well as memory mapping.


Jstat command is a Java virtual machine statistics monitoring tool. Please see below example for how to use command and its output.

Jstat -gc <PID>

root@Hello:~# jstat -gc 9020
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
6912.0 6528.0 16.0 0.0 117632.0 108377.4 393216.0 7188.1 17280.0 17262.5 24 0.103 0 0.000 0.103

root@Hello:~# jstat -class 9020
Loaded Bytes Unloaded Bytes Time
3284 3939.7 0 0.0 2.26

There are many options for this command you can use man page for getting all options of this command. For better understanding of jstat output short forms like S0C, S1C click on this link. Jstat Command in Linux.


Jmap is used to check memory mapping of particular java process. Jmap can give memory mapping of class wise of that java program as well. We can use this command as follows:

usage of this command as

jmap <OPTONS> <PID>

or

jmap <PID>

root@Hello:~# jmap 9020
Attaching to process ID 9020, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.0-b12

using thread-local object allocation.
Parallel GC with 2 thread(s)

Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 536870912 (512.0MB)
NewSize = 1048576 (1.0MB)
MaxNewSize = 4294901760 (4095.9375MB)
OldSize = 4194304 (4.0MB)
NewRatio = 3
SurvivorRatio = 8
PermSize = 16777216 (16.0MB)
MaxPermSize = 134217728 (128.0MB)

Heap Usage:
PS Young Generation
Eden Space:
capacity = 120455168 (114.875MB)
used = 115808768 (110.44384765625MB)
free = 4646400 (4.43115234375MB)
96.14263125680087% used
From Space:
capacity = 7077888 (6.75MB)
used = 16384 (0.015625MB)
free = 7061504 (6.734375MB)
0.23148148148148148% used
To Space:
capacity = 6684672 (6.375MB)
used = 0 (0.0MB)
free = 6684672 (6.375MB)
0.0% used
PS Old Generation
capacity = 402653184 (384.0MB)
used = 7360656 (7.0196685791015625MB)
free = 395292528 (376.98033142089844MB)
1.8280386924743652% used
PS Perm Generation
capacity = 17694720 (16.875MB)
used = 17676760 (16.857872009277344MB)
free = 17960 (0.01712799072265625MB)
99.8985007957176% used


Another use of this jmap command to check all java classes as :

root@Hello:~# jmap -permstat 9020
Attaching to process ID 9020, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.0-b12
9569 intern Strings occupying 747072 bytes.
finding class loader instances ..Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
done.
computing per loader stat ..done.
please wait.. computing liveness....liveness analysis may be inaccurate ...
class_loader classes bytes parent_loader alive? type

<bootstrap> 1673 7167072 null live <internal>
0x94c0ac88 1 1800 0x9464a2d0 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94b4d988 1 1768 null dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad3738 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0ab70 1 1168 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x945e09f0 98 607840 0x945e0a38 live sun/misc/Launcher$AppClassLoader@0x8c775510
0x9485b068 1 1784 null dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c110b8 1 1768 null dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0abe0 1 1768 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94a3cf38 1 1168 null dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x945e0960 720 3903736 0x945e09a8 live org/apache/catalina/loader/StandardClassLoader@0x8cb28578
0x94c0a8d0 1 1808 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0ac18 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad5090 1 1808 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x9488bb88 171 890600 0x945f97d0 live org/apache/catalina/loader/WebappClassLoader@0x8cee3928
0x94ad53a0 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0a940 1 1768 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94857948 1 1784 null dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad2d80 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0a978 1 1768 null dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c11c58 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0aac8 1 1800 0x9464a2d0 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0a860 1 1768 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0aa58 1 1168 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad1748 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad1128 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0a9e8 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad3a48 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0ab38 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94852000 2 24344 null dead javax/management/remote/rmi/NoCallStackClassLoader@0x8ca81c88
0x94c0acc0 1 1808 0x9464a2d0 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad59c0 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0aa20 1 1816 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0a908 1 1800 0x9464a2d0 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0ac50 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94857650 1 1784 null dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94ad6ce0 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x945e09a8 661 2994208 0x945e09f0 live org/apache/catalina/loader/StandardClassLoader@0x8cb28578
0x94ad56b0 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94c0a898 1 1808 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x94851b50 4 9544 null dead javax/management/remote/rmi/NoCallStackClassLoader@0x8ca81c88
0x94ad33a0 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x9464a2d0 800 3519760 0x945f97d0 live org/apache/catalina/loader/WebappClassLoader@0x8cee3928
0x94ad1a58 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x945f97d0 0 0 0x945e09a8 live org/apache/catalina/loader/StandardClassLoader@0x8cb28578
0x945fda98 0 0 0x945e09f0 live java/util/ResourceBundle$RBClassLoader@0x8caedee8
0x94ad6ff0 1 1800 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0
0x945e0a38 0 0 null live sun/misc/Launcher$ExtClassLoader@0x8c72c0a8
0x94c0ab00 1 1768 0x945e0960 dead sun/reflect/DelegatingClassLoader@0x8c6317a0

total = 60 4178 19203080 N/A alive=9, dead=51 N/A


If you need more information regarding the Jmap command then please click on next link : Jmap Commandin Linux.

Jstack Command

Jstack command used to trace Java process stack trace.

Usage of jstack as follows :

jstack <PID>

Its output is very bigger thats why I couldn't paste here. Please check your own to exact output as above format.

Click here to know more about: While Loop in Shell Scripting

And most important command for java process is that jinfo.


Jinfo command gives configuration information of java process.

Usage:

jinfo <PID>

jinfo <OPTIONS> <PID>

example of jinfo command as :

root@Hello:~# jinfo 9020
Attaching to process ID 9020, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.0-b12
Java System Properties:

java.runtime.name = OpenJDK Runtime Environment
sun.boot.library.path = /usr/lib/jvm/java-5-openjdk/jre/lib/i586
java.vm.version = 20.0-b12
shared.loader = ${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar
java.vm.vendor = Sun Microsystems Inc.
java.vendor.url = http://java.sun.com/
java.rmi.server.randomIDs = true
path.separator = :
tomcat.util.buf.StringCache.byte.enabled = true
java.util.logging.config.file = /hello/test/tomcat/conf/logging.properties
java.vm.name = OpenJDK Server VM
file.encoding.pkg = sun.io
sun.java.launcher = SUN_STANDARD
user.country = IN
sun.os.patch.level = unknown
com.sun.management.jmxremote.port = 3080
java.vm.specification.name = Java Virtual Machine Specification
user.dir = /hello/test/tomcat/bin
java.runtime.version = 1.6.0_24-b24
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.endorsed.dirs = /hello/test/tomcat/common/endorsed
os.arch = i386
java.io.tmpdir = /hello/test/tomcat/temp
line.separator =

java.vm.specification.vendor = Sun Microsystems Inc.
java.naming.factory.url.pkgs = org.apache.naming
java.util.logging.manager = org.apache.juli.ClassLoaderLogManager
os.name = Linux
sun.jnu.encoding = UTF-8
java.library.path = /usr/lib/jvm/java-5-openjdk/jre/lib/i586/server:/usr/lib/jvm/java-5-openjdk/jre/lib/i586:/usr/lib/jvm/java-6-openjdk/jre/../lib/i386:/usr/java/packages/lib/i386:/usr/lib/jni:/lib:/usr/lib
java.specification.name = Java Platform API Specification
java.class.version = 50.0
sun.management.compiler = HotSpot Tiered Compilers
os.version = 3.0.0-12-generic
com.sun.management.config.file = /hello/test/tomcat/conf/management.properties
user.home = /root
catalina.useNaming = true
user.timezone = Asia/Kolkata
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = UTF-8
java.specification.version = 1.6
catalina.home = /hello/test/tomcat
java.class.path = :/hello/test/tomcat/bin/bootstrap.jar:/hello/test/tomcat/bin/commons-logging-api.jar
user.name = root
java.naming.factory.initial = org.apache.naming.java.javaURLContextFactory
package.definition = sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
java.vm.specification.version = 1.0
org.xmldb.common.xml.queries.XPathQueryFactory = org.xmldb.common.xml.queries.xalan2.XPathQueryFactoryImpl
sun.java.command = org.apache.catalina.startup.Bootstrap start
java.home = /usr/lib/jvm/java-6-openjdk/jre
sun.arch.data.model = 32
user.language = en
java.specification.vendor = Sun Microsystems Inc.
java.vm.info = mixed mode
java.version = 1.6.0_24
java.ext.dirs = /usr/lib/jvm/java-6-openjdk/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /hello/test/tomcat/common/endorsed/commons-collections-3.1.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/netx.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/plugin.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/modules/jdk.boot.jar:/usr/lib/jvm/java-6-openjdk/jre/classes
server.loader = ${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar
java.vendor = Sun Microsystems Inc.
catalina.base = /hello/test/tomcat
java.security.auth.login.config = ../conf/jaas.conf
file.separator = /
java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
common.loader = ${catalina.home}/common/classes,${catalina.home}/common/i18n/*.jar,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
package.access = sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.
sun.cpu.isalist =

VM Flags:

-Djava.security.auth.login.config=../conf/jaas.conf -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/hello/test/tomcat/conf/logging.properties -Dcom.sun.management.config.file=/hello/test/tomcat/conf/management.properties -Dcom.sun.management.jmxremote.port=3080 -Xms512m -Xmx512m -XX:NewRatio=3 -XX:+UseAdaptiveSizePolicy -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/internet/apps/cmt/outofmemory.hprof -Djava.endorsed.dirs=/hello/test/tomcat/common/endorsed -Dcatalina.base=/hello/test/tomcat -Dcatalina.home=/hello/test/tomcat -Djava.io.tmpdir=/hello/test/tomcat/temp



If you want to more information of this command and click on next link : Jinfo command inLinux.


Logical Volume Manager                       Difference of Unix and Linux       Type Command
Posted by Machindra Dharmadhikari On 3/05/2013 07:35:00 PM 1 comment

1 comments:

Post a Comment

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner