rss
SOATUBE
Oracle
Custom Search SOABYTE here

Sunday, June 2, 2013

How To Take Thread Dumps With WLST

Place thread.properties file,threaddump.py and runthreaddumpWLST.sh inside a folder and execute ./runthreaddumpWLST.sh to run the program.
#*****************************************************
# Environment details                                *
#thread.properties file                              *
#*****************************************************
ADMIN_USERNAME = weblogic
ADMIN_PASSWORD = welcome1
ADMIN_URL = t3://localhost:7001
sleepTime = 5000
threadNumber = 10
########################################################################################
# Thread Dump Automation WLST Script                                                   #
# @Team Fusion                                                                         #             
#Do not change the discription                                                         #
########################################################################################
#Running the script                                                                    #
########################################################################################
#WL_HOME\server\bin\setWLSEnv.cmd or                                                   #
#source $WL_HOME/server/bin/setWLSEnv.sh                                               #
#java weblogic.WLST Folder_Loc/threaddump.py                                           #
########################################################################################
from java.io import FileInputStream
import java.lang
import string
from time import strftime
from java.text import SimpleDateFormat
import sys
import os

#read properties file
propInputStream = FileInputStream("thread.properties");
configProps = Properties();
configProps.load(propInputStream);

#Connecting to Server
adminusername = configProps.get('ADMIN_USERNAME');
adminpassword = configProps.get('ADMIN_PASSWORD');
adminurl = configProps.get('ADMIN_URL');
connect(adminusername, adminpassword, adminurl)
domainName=cmo.getName();
serverList = cmo.getServers();
sleepTime = int(configProps.get('sleepTime'));
threadNumber = int(configProps.get('threadNumber'));

def __threadDumpAutomation():
 counter = 0
 i = 0
 while i<len(serverList):
  serverName = serverList[i].getName();
  for counter in range(threadNumber):
        currentDate = java.util.Date().toString()
        myDate = currentDate.split(' ');
        finalDate = myDate[3]
        java.lang.Thread.sleep(sleepTime)
        fileName = 'dump' + '_' + serverName + '_' + finalDate + '.dmp'
        threadDump('true', fileName, serverName)
  i = i+1;
  
# MAIN

#****************************************************************************

#

# Calling all the Methods here

print(' ————————– ')

print('Starting the thread dump')

print('#########################################################################################################################')
print 'Do you want to start thread dump'
input = raw_input("Press y to PROCEED or press n to SKIP ===================================================>                          ");
if input == 'y':
 __threadDumpAutomation()
else:
 exit();

print ('##########################################################################################################################')

print(' ————————– ')

print 'Disconnecting from AdminServer and exiting WLST now'
disconnect();
exit();  
#!/bin/bash

# ************* Setting the Environment ***********************
echo "Setting the Environment"
source /app/oracle/fmw/wlserver_10.3/server/bin/setWLSEnv.sh

echo "Environment has been set....."

# ************* Changing the directory***********************
cd .

echo "Calling the script....."

# ************* Calling the WLST script  *****************
java weblogic.WLST threaddump.py

1 comments:

Post a Comment

 
Blogger Profile