WebLogic Scripting Tool

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Getting Runtime Information

You can use WLST to retrieve information that WebLogic Server instances produce to describe their runtime state. The following sections using WLST to get runtime information:


Accessing Runtime Information: Main Steps

The Administration Server hosts the domain runtime hierarchy which provides access to any MBean on any server in the domain. If the Administration Server is not running for a domain, WLST can connect to individual Managed Servers to retrieve runtime data.

Accessing the runtime information for a domain includes the following main steps:

  1. Invoke WLST and connect to a running Administration Server instance. See Invoking WLST.
  2. Navigate to the domain runtime MBean hierarchy by entering the domainRuntime command.
  3. wls:/mydomain/serverConfig>domainRuntime()

    The domainRuntime command places WLST at the root of the domain-wide runtime management objects, DomainRuntimeMBean.

  4. Navigate to ServerRuntimes and then to the server instance which you are interested in monitoring.
  5. wls:/mydomain/domainRuntime>cd('ServerRuntimes/myserver')

  6. At the server instance, navigate to and interrogate runtime MBeans.
  7. wls:/mydomain/domainRuntime/ServerRuntimes/myserver>cd('JVMRuntime/myserver')>

    -r--   AllProcessorsAverageLoad                     0.0
    -r-- Concurrent true
    -r-- FreeHeap 15050064
    -r-- FreePhysicalMemory 900702208
    -r-- GCHandlesCompaction true
    -r-- GcAlgorithm Dynamic GC currently running
    strategy: Nursery, parallel mark, parallel sweep
    -r-- Generational true
    -r-- HeapFreeCurrent 14742864
    -r-- HeapFreePercent 5
    -r-- HeapSizeCurrent 268435456
    -r-- HeapSizeMax 268435456
    -r-- Incremental false
    -r-- JVMDescription Oracle JRockit Java Virtual Machine
    -r-- JavaVMVendor BEA Systems, Inc.
    -r-- JavaVendor BEA Systems, Inc.
    -r-- JavaVersion 1.5.0

The following sections provide example scripts for retrieving runtime information about WebLogic Server server instances and domain resources.

Script for Monitoring Server State

The WLST online script in Listing 8-1 navigates the domain runtime hierarchy and checks the status of a Managed Server every 5 seconds. It restarts the server if the server state changes from RUNNING to any other status. It assumes that WLST is connected to the domain’s Administration Server.

For information on how to run this script, see Invoking WLST.

Listing 8-1 Monitoring Server State
# Node Manager needs to be running to run this script.
import thread
import time
def checkHealth(serverName):
  while 1:
    slBean = getSLCRT(serverName)
    status = slBean.getState()
    print 'Status of Managed Server is '+status
    if status != "RUNNING":
      print 'Starting server '+serverName
      start(serverName, block="true")
def getSLCRT(svrName):
    slrBean = cmo.lookupServerLifecycleRuntime(svrName)
    return slcBean

Script for Monitoring the JVM

The WLST online script in Listing 8-2 monitors the HJVMHeapSize for all running servers in a domain; it checks the heap size every 3 minutes and prints a warning if the heap size is greater than a specified threshold. It assumes that the URL for the domain’s Administration Server is t3://localhost:7001.

For information on how to run this script, see Invoking WLST.

Listing 8-2 Monitoring the JVM Heap Size
uname = "weblogic"
pwd = "weblogic"
url = "t3://localhost:7001"
def monitorJVMHeapSize():
    connect(uname, pwd, url)
    while 1:
        serverNames = getRunningServerNames()
        for name in serverNames:
            print 'Now checking '+name.getName()
            except WLSTException,e:
                # this typically means the server is not active, just ignore
            heapSize = cmo.getHeapSizeCurrent()
            if heapSize > THRESHOLD:
            # do whatever is neccessary, send alerts, send email etc
                print 'WARNING: The HEAPSIZE is Greater than the Threshold'
                print heapSize
def getRunningServerNames():
    return cmo.getServers()
if __name__== "main":


Configuring Logging

Using WLST, you can configure a server instance’s logging and message output.

To determine which log attributes can be configured, see LogMBean and LogFileMBean in the WebLogic Server MBean Reference. The reference also indicates valid values for each attribute.

The WLST online script in Listing 8-3 sets attributes of LogMBean (which extends LogFileMBean). For information on how to run this script, see Invoking WLST.

Listing 8-3 Configuring Logging
# Connect to the server
# set CMO to the server log config
ls ()
# change LogMBean attributes
set("FileCount", 5)
set("FileMinSize", 400)
# list the current directory to confirm the new attribute values
ls ()
# save and activate the changes
# all done...


Working with the WebLogic Diagnostics Framework

The WebLogic Diagnostic Framework (WLDF) is a monitoring and diagnostic framework that can collect diagnostic data that servers and applications generate. You configure WLDF to collect the data and store it in various sources, including log records, data events, and harvested metrics. For more information, see Configuring and Using the WebLogic Diagnostics Framework.

For example scripts that demonstrate using WLST to configure the WebLogic Diagnostic Framework, see WebLogic Scripting Tool Examples in Configuring and Using the WebLogic Diagnostics Framework.

To view the collected diagnostics information using WLST, use one of the following commands to export the data from the WLDF repositories:

  Back to Top       Previous  Next