Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slow WLST script

Status
Not open for further replies.

lhg1

IS-IT--Management
Mar 29, 2005
134
DK
Hi

I have a wlst script that is very slow. It can take over 1 hour to run.

It is collecting IdleThreads.
We have a Dashbord that collects the same, and running a lot quicker.

Can any body tell me how to optimize the script.
It is running like this.

./wlst.sh scripts/MonitorThreads.py environments/middleware_domain/online

Code:
export BEA_HOME=/appl/bea
export WL_HOME=$BEA_HOME/weblogic816

export JAVA_HOME=$BEA_HOME/jdk142_11

LIB_BASE=.

export JYTHON_HOME=${LIB_BASE}/common/jython/

CLASSPATH=

CLASSPATH=$CLASSPATH:${LIB_BASE}/common/jython/wlst.jar
CLASSPATH=$CLASSPATH:${LIB_BASE}/common/jython/jython.jar
CLASSPATH=$CLASSPATH:$WL_HOME/server/lib/weblogic.jar
CLASSPATH=$CLASSPATH:$WL_HOME/server/lib/wli.jar

PATH=$PATH:${JAVA_HOME}/bin:${WL_HOME}/server/bin


export CLASSPATH
export PATH

export WLST_HOME=${LIB_BASE}/common/jython

export PYTHON_PATH=${LIB_BASE}/common/jython/lib
CACHE_DIR=/var/tmp


${JAVA_HOME}/bin/java -classpath ${CLASSPATH} -Dpython.cachedir=${CACHE_DIR} -Dpython.home=${JYTHON_HOME} -Dpython.path=${PYTHON_PATH} -Dweblogic.wlstHome=${WLST_HOME} weblogic.
WLST ${*}

Code:
#! /usr/bin/env jython

""" Our libs """
""" Standard libs """
import os
import shutil
import java.util
import time

execfile('./common/jython/lib/onlineutils.py')

################################################################################
# Global variables
################################################################################

ThreadPoolSize = []
MyErrors = []

#===============================================================================
# Connect to the WLS server
#===============================================================================
envDir = sys.argv[1]
if os.path.exists(envDir + '/wls/domain/domain.properties'):
  domain = loadProperties(envDir + '/wls/domain/domain.properties')

  User = domain.get('User')
  Password = domain.get('Password')
  ServerName = domain.get('ServerName')
  AdminURL = domain.get('AdminURL')
  getConnection(User,Password,AdminURL)

#===============================================================================
# Get WLS thread count
#===============================================================================
  runtime()

  try:
    printMessage("Getting server runtime")
    cd ('/ServerRuntimes/' + ServerName)
    printMessage("Getting server state")
    state = cmo.getState()
    printMessage("Got server state")

    cd ('ExecuteQueueRuntimes/weblogic.kernel.Default')
    size = cmo.getExecuteThreadCurrentIdleCount()

    localTime = time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime(time.time()))
    ThreadPoolSize.append('[' + localTime +' ] WLS.IdleThreads : %d'%size)
    ThreadPoolSize.append('[' + localTime +' ] WLS.State : %s'%state)
  except Exception:
      printError("A problem was encountered whilst retrieving Idle Thread Count for : " + ServerName)
      MyErrors.append("A problem was encountered whilst retrieving Idle Thread Count for WLS")
  disconnect()

#===============================================================================
# Connect to the WLI server
#===============================================================================
redirect('/dev/null')
envDir = sys.argv[1]
if os.path.exists(envDir + '/wli/domain/domain.properties'):
  domain = loadProperties(envDir + '/wli/domain/domain.properties')

  User = domain.get('User')
  Password = domain.get('Password')
  AdminURL = domain.get('AdminURL')
  getConnection(User,Password,AdminURL)

#===============================================================================
# Get WLI thread count
#===============================================================================
  runtime()

  cd ('/ServerRuntimes/')
  # Get list of servers
  servers=ls().splitlines()

  # Loop thru each server
  for server in servers:
    try:
      server = server.replace('drw-','').strip()
      cd ('/ServerRuntimes/' + server)
      state = cmo.getState()
      cd ('ExecuteQueueRuntimes/weblogic.kernel.Default')
      size = cmo.getExecuteThreadCurrentIdleCount()
      localTime = time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime(time.time()))

      ThreadPoolSize.append("  Server: " + server)
      ThreadPoolSize.append('    [' + localTime +' ] ' + server + ' WLI.IdleThreads : %d'%size )  
      ThreadPoolSize.append('    [' + localTime +' ] ' + server + ' WLI.State : %s'%state )

    except Exception:
      #printError("A problem was encountered whilst retrieving Idle Thread Count for : " + server + " " + envDir)
      MyErrors.append("A problem was encountered whilst retrieving Idle Thread Count for " + server + " " + envDir)	
  disconnect()

#===============================================================================
# Log Messages
#===============================================================================

logFile = open('logs/threadMonitor.log', 'w')
logFile.write("Server Status for : " + envDir + "\n")
stopRedirect()
printMessage("Server Status for : " + envDir)

for message in ThreadPoolSize:
  printMessage("" + message)
  logFile.write(message + "\n")

for message in MyErrors:
  printError("" + message)
  logFile.write(message  + "\n")

logFile.close()
exit()

Thanks

/LHG
 
Who knows. I'd add timestamp traces to see where the time is going

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top