Friday, February 25, 2011

Generate Dumps

1) Use wsadmin jython code for thread dumps (be careful that indention is meaningful in jython)
------------------------------------------------------------------------------------------------------
# define a function that will find the JVM name and generate the dump
# the name of the jython program is wasgeneratethreaddump.py 
     def generateThreadDump(serverName):
     serverJVM = AdminControl.queryNames("type=JVM,process="+serverName+",*")
AdminControl.invoke(serverJVM,"dumpThreads")
# call the function
generateThreadDump("ClstAppSrv02")
-------------------------------------------------------------------------------------------------------
Use the following in wsadmin to call the jython program (windows):
wsadmin -lang jython -f  wasgeneratethreaddump.py
Then, you should see the dump file. You can use IBM Support Assistant to view and analyze the dump.

2) heap dump

A. Use admin console to set up automatic memory dump - this is only for testing and development OR when you have a severe production problem, because the generation of dump will cause the production system an actual pause. Use the following sequence of panels, then, check "Enable Performance and Diagnostic Advisor Framework (Runtime Performance Advisor)" 

Application servers > ClstAppSrv01 > Performance and Diagnostic Advisor Configuration

B. Use wsadmin and jython to generate a heap dump
------------------------------------------------------------------------------------------------------
# define a function that will find the JVM name and generate the dump
# the name of the jython program is wasgeneratethreaddump.py
def generateThreadDump(serverName):
     serverJVM = AdminControl.queryNames("type=JVM,process="+serverName+",*"
     AdminControl.invoke(serverJVM,"generateHeapDump")
# call the function
generateThreadDump("ClstAppSrv02")
-------------------------------------------------------------------------------------------------------
3) Of course, both can be generated from using kill -3 taking JVM  PID as argument in UNIX/LINUX environment (be careful - sometimes there are anomalies - once I got into trouble issuing kill -3 because of a bug in a monitoring tool. Generally speaking, wsadmin and jython is a safer route)
java dmp
javacore txt
Snap trc

No comments: