WLST Script to Monitor Throughput and HeapSize of Weblogic Server

In this simple example ill demonstrate how to browse to ThreadPoolRuntime and JVMRuntime Mbeans of Weblogic Server and monitor their attributes. We get a lot of useful runtime date from this Mbeans which we can store for later reference.

cd(“/ServerRuntimes/AdminServer/ThreadPoolRuntime/ThreadPoolRuntime”)

-r– HealthState State: HEALTH_OK,ReasonCode:[]
-r– HoggingThreadCount 0
-r– MinThreadsConstraintsCompleted 20485
-r– MinThreadsConstraintsPending 0
-r– Name ThreadPoolRuntime
-r– PendingUserRequestCount 0
-r– QueueLength 0
-r– SharedCapacityForWorkManagers 65536
-r– StandbyThreadCount 4
-r– Suspended false
-r– Throughput 49.25373134328358
-r– Type ThreadPoolRuntime

cd(“/ServerRuntimes/AdminServer/JVMRuntime/AdminServer”)

-r– HeapFreeCurrent 201978672
-r– HeapFreePercent 75
-r– HeapSizeCurrent 267583488
-r– HeapSizeMax 535166976
-r– JavaVMVendor Sun Microsystems Inc.
-r– JavaVendor Sun Microsystems Inc.
-r– JavaVersion 1.5.0_12
-r– Name AdminServer
-r– OSName SunOS
-r– OSVersion 5.10
-r– Type JVMRuntime
-r– Uptime 19589860

SCRIPT

def serverStatus(server):
cd(‘/ServerLifeCycleRuntimes/’+server)
return cmo.getState()

def getServerNames():
domainConfig()
return cmo.getServers()

def printThreadDetails():
connect(“weblogic”,”weblogic”,”t3://localhost:7001?)
serverNames=getServerNames()
domainRuntime()

for name in serverNames:
serverState = serverStatus(name.getName())

if serverState != “SHUTDOWN”:
cd(“/ServerRuntimes/”+name.getName()+”/ThreadPoolRuntime/ThreadPoolRuntime”)
tput=cmo.getThroughput()
cd(“/ServerRuntimes/” + name.getName() + “/JVMRuntime/” + name.getName())
heapSize=cmo.getHeapSizeCurrent()
print name.getName()
print ” Throughput:”,tput
print ” HeapSize:”,heapSize
print “n”

if __name__== “main”:
printThreadDetails()

OUTPUT

AdminServer
Throughput: 55.72139303482587
HeapSize: 267583488

MS2
Throughput: 0.9950248756218906
HeapSize: 92995584

6 comments

  1. thanks for the post. The script run fine but at the end it throws the error as below:

    No stack trace available.
    Problem invoking WLST – Traceback (innermost last):
    File “/home/hosting/vguptr5/bea10mp2/domains/v10/TEST_DOMAIN/get.py”, line 11, in ?
    File “”, line 170, in cd
    WLSTException: Error cding to the MBean

    Please suggest further.

    Thanks
    Rahul Gupta

  2. I get the following error when I running it:

    Traceback (innermost last):
    File “”, line 1, in ?
    File “/home/oracle11/kurz.py”, line 2
    cd(‘/ServerLifeCycleRuntimes/’+server)
    ^
    SyntaxError: invalid syntax

  3. How to get the server throughput in weblogic8.1.6 as there is no ThreadPoolRuntime/ThreadPoolRuntime.

    1. Hi Kapil,

      WLST was not fully developed in WLS 8.1 hence it was not available there.

  4. Thanks for the Post.

    Along with the heap size pf Admin Server and Managed Server is it possible to print exactly at what time this heap size is consuming.

    My requirement is along with heap size date and time also have to print. Could you please share any suggestion on this.

    Thanks
    Krishna

Comments are closed.