Pages

Thursday, July 19, 2012

Connecting To Weblogic JVM



Working as an Application System admin, I need to work very closely with Weblogic and JBoss. Since JBoss runs mostly on JDK versions, Weblogic has one more jdk available called JRocket.

 Most of the production servers contains Weblogic will be running on JRocket jvm since it provides some benefits that normal jdk. In this article we will see how we can communicate with Weblogic serer that started using JRocket jvm (thinking that the Weblogic is running on JRocket Jvm).

There is a tool called “jrcmd” provided with JRocket jdk which sends commands to the JRocket jvm. This is a command line tool available in the JRcoket/bin/.Considering the process ID for Weblogic is 3448.Here are a list of commands used with “jrcmd” for communicating with the Weblogic process.

1. Find the Version of the JRocket Running  

jrcmd 3448 version
3448:
Oracle JRockit(R) build R28.2.3-13-149708-1.6.0_31-20120327-1522-linux-ia32, compiled mode
GC mode: Garbage collection optimized for throughput, strategy: genparpar

2. Find the available Weblogic process running

jrcmd -p
4536 jrockit.tools.jrcmd.JrCmd -p
3448 weblogic.Server

3. Find the Commands provided by this version

jrcmd 3448 help
3448:
The following commands are available:
        kill_management_server
        start_management_server
        print_object_summary
        memleakserver
        print_class_summary
        print_codeblocks
        dump_codelayout
        dump_codelist
        dump_codemap
        print_codegenlist
        exception_trace_filter
        print_vm_state
        print_utf8pool
        check_flightrecording
        dump_flightrecording
        stop_flightrecording
        start_flightrecording
        print_properties
        hprofdump
        print_threads
        datadump_request
        runsystemgc
        runfinalization
        heap_diagnostics
        oom_diagnostics
        print_exceptions
        version
        timestamp
        command_line
        sanity
        verbosity
        set_filename
        help
        print_memusage
        set_vmflag
        list_vmflags
For more information about a specific command use 'help '.
Parameters to commands are optional unless otherwise stated.

If you need to find more about a command we can use, 

jrcmd 3448 help runsystemgc
3448:
Calls java.lang.System.gc().
        full        - do a full GC (same as -XXfullsystemgc). (bool, false)
        fullcompact - force a full compaction (only for full GCs). (bool,
                      true)

4. Find Out the Current Time Stamp and Up time of the VM

jrcmd 3448 timestamp
3448:
==== Timestamp ====  uptime: 0 days, 01:35:06 time: Tue Jul 17 14:36:25 2012


5. Find out the Command line and other information used to start the VM Instance

jrcmd 3448  print_vm_state
3448:
Uptime       : 0 days, 01:30:57 on Tue Jul 17 14:32:16 2012
Version      : Oracle JRockit(R) R28.2.3-13-149708-1.6.0_31-20120327-1522-linux-ia32
CPU          : Intel Core 2 SSE SSE2 SSE3 SSSE3 SSE4.1 Core Intel64
Number CPUs  : 2
Tot Phys Mem : 3179118592 (3031 MB)
OS version   : Red Hat Enterprise Linux Server release 5.6 (Tikanga)
Linux version 2.6.18-238.el5 (mockbuild@ls20-bc2-13.build.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Sun Dec 19 14:24:47 EST 2010 (i686)
.
.
.
.

6. Find out the Command line of a VM Instance

jrcmd 3448  command_line
3448:
Command Line: -Xms512m -Xmx512m -Dweblogic.Name=AdminServer Djava.security.policy=/soa/wls10/Middleware/wlserver_10.3/server/lib/
weblogic.policy Dweblogic.ProductionModeEnabled=true -da -Dplatform.home=/soa/wls10/Middleware/wlserver_10.3 -Dwls.home=/soa/wls10/Middleware/wlserver_10.3/server Dweblogic.home=/soa/wls10/Middleware/wlserver_10.3/server Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false Dweblogic.ext.dirs=/soa/wls10/Middleware/patch_wls1036/profiles/default/
sysext_manifest_classpath:/soa/wls10/Middleware/patch_oepe180/profiles/
default/sysext_manifest_classpath:/soa/wls10/Middleware/patch_ocp371/
profiles/default/sysext_manifest_classpath:/soa/wls10/Middleware/
patch_adfr1111/profiles/default/sysext_manifest_classpath -Dsun.java.command=weblogic.Server Dsun.java.launcher=SUN_STANDARD weblogic.Server


7. Find out the Properties available to the VM Instance

jrcmd 3448  print_properties
3448:

=== Initial Java properties: ===
java.vm.specification.name=Java Virtual Machine Specification
java.vm.vendor.url.bug=http://download.oracle.com/docs/cd/E15289_01/
go2troubleshooting.html
weblogic.home=/soa/wls10/Middleware/wlserver_10.3/server
wlw.iterativeDev=false
java.home=/soa/jrockit-jdk1.6.0/jre
java.vm.vendor.url=http://www.oracle.com/
weblogic.ext.dirs=/soa/wls10/Middleware/patch_wls1036/profiles/default/
sysext_manifest_classpath:/soa/wls10/Middleware/patch_oepe180/profiles/
default/sysext_manifest_classpath:/soa/wls10/Middleware/patch_ocp371/
profiles/default/sysext_manifest_classpath:/soa/wls10/Middleware/
patch_adfr1111/profiles/default/sysext_manifest_classpath
java.security.policy=/soa/wls10/Middleware/wlserver_10.3/server/lib/
weblogic.policy
wlw.testConsole=false
java.vm.specification.version=1.0
.
.
.


8. Find Out the memory Details 

jrcmd 3448 print_memusage scale=M baseline 
3448:
Total mapped                       773MB           (reserved=0MB)
-              Java heap            512MB           (reserved=0MB)
-              GC tables             17MB          
-          Thread stacks           15MB           (#threads=36)
-          Compiled code           8MB           (used=7MB)
-               Internal                0MB          
-                     OS                72MB          
-                  Other               73MB          
-        Java class data            72MB           (malloced=72MB #102209 in 18503 classes)
- Native memory tracking       1MB           (malloced=0MB #8)



9. Find out the Object Details

jrcmd 3448 print_object_summary
3448:

--------- Detailed Heap Statistics: ---------
29.9% 10418k   106949 +10418k [C
 7.8% 2703k   115352  +2703k java/lang/String
 5.8% 2023k    18501  +2023k java/lang/Class
 4.6% 1614k    13769  +1614k [Ljava/lang/Object;
 4.0% 1388k    15207  +1388k [Ljava/util/HashMap$Entry;
 3.8% 1326k     6590  +1326k [B
 3.5% 1227k     1059  +1227k [J
 2.5% 877k    37435   +877k java/util/HashMap$Entry
 2.5% 877k    28076   +877k java/util/LinkedHashMap$Entry
 1.6% 541k    17328   +541k java/util/concurrent/ConcurrentHashMap$Segment
 1.5% 522k     3347   +522k [I
 1.3% 446k     5398   +446k [Ljava/lang/String;
 1.2% 432k    18444   +432k java/util/Hashtable$Entry
 1.2% 425k     9085   +425k java/util/HashMap
 1.2% 407k    17385   +407k java/util/concurrent/locks/ReentrantLock$NonfairSync
 1.2% 403k    17236   +403k javax/xml/namespace/QName
 1.1% 387k     8267   +387k java/lang/ref/SoftReference
 1.1% 370k    17328   +370k [Ljava/util/concurrent/ConcurrentHashMap$HashEntry;
 0.9% 326k     5974   +326k java/util/LinkedHashMap
 0.9% 324k     5938   +324k com/bea/staxb/buildtime/internal/bts/QNameProperty
 0.9% 313k     8037   +313k java/lang/ref/WeakReference
 0.9% 311k     4443   +311k [Ljava/util/Hashtable$Entry;
 0.8% 278k    17817   +278k com/bea/staxb/buildtime/internal/bts/MethodName
 0.8% 276k     3538   +276k java/lang/reflect/Method
     34866kB total ---

--------- End of Detailed Heap Statistics ---

10. Find Information Regarding Loaded Class Details 

jrcmd 3448 print_class_summary

**class sun/jkernel/DownloadManager$2$2
**class sun/jkernel/DownloadManager$2$1
*class jrockit/vm/RNI
*class jrockit/vm/Reflect
*class jrockit/vm/VM
**class jrockit/vm/Locks
*class jrockit/vm/AccessController
*class java/lang/reflect/AccessibleObject
**class java/lang/reflect/Constructor
**class java/lang/reflect/Field
**class java/lang/reflect/Method
*
*
*

11. Run Garbage Collection

jrcmd 3448 help runsystemgc
3448:
Calls java.lang.System.gc().
        full        - do a full GC (same as -XXfullsystemgc). (bool, false)
        fullcompact - force a full compaction (only for full GCs). (bool,
                      true)


12. Run Finalization

jrcmd 3448 help runfinalization
3448:
Calls java.lang.System.runFinalization().

13. Generate a Thread Dump

jrcmd 3448 print_threads



14. Heap_diagnostics 

This can used in getting detailed information about the heap usage. When this command is executed a full GC is trigged during which the information is collected. The output normally contains 3 sections,

General Information: available memory and heap usage

Detailed heap Details : list the amount of heap that a particular class occupy, the amount of memory in Kbs that they consume, the total number of instances alive and other more information

Reference object statistics – lists the amount of total instances, how many instances are reachable, how many instances are unreachable and thus eligible for garbage collection, how many reference objects were found unreachable during this garbage collection, how many objects were activated before this garbage collection, how many instances are pointing to null and the instance types.

We can run the command like, jrcmd 3448 heap_diagnostics > /logs/heap.conf
If we are interested in a septic class, we can use

jrcmd heap_diagnostics | grep '%.*GenericClassLoader : This will grep for the one line we are interested in. The output seems to be

0.0% 10k 150 +10k weblogic/utils/classloaders/GenericClassLoader

15. Oom_diagnostics 

This allows to print the current state of heap when an Out of memory occurs. We can add the following variables to the startup files like

jrcmd 3448 oom_diagnostics > /logs/oos.conf

More to Come, happy learning