Get jvm heap params of remote server in weblogic domain (WLST)

  • Given weblogic domain containing admin and manage servers.
  • We would like to get JVM parameters of remote Admin or manager server.
    • We will get remote attributes of JVM like:
      • Java version of remote server.
      • Max heap storage.
      • Free heap space in percentage.
      • JVM uptime.
  • We would perform following steps to get JVM diagnostic parameters  (WLST).
    • Connect to admin server using t3 protocol.
    • Get list of all servers active servers in current domain.
    • Fetch JVM attributes of remote servers using JVMRuntimeMBean.
    • Disconnect from admin server

Script: Get jvm heap params of remote server in weblogic (WLST/python)

def printJVMParametersOfRemoteServer():

    servers = runningServers()

    for server in servers:
        cd("/ServerRuntimes/"+server+"/JVMRuntime/"+server)

        #Get JVM Version
        java_version = get('JavaVersion')

        #Max Heap
        max_heap = int(get('HeapSizeMax'))/(1024*1024)

        #Available heap store
        freeHeapPercent = int(get('HeapFreePercent'))

        #JVM Uptime
        jvm_uptime = get('Uptime')

        print 'JVM parameters of %s server is :' % server
        print '\t\t\tJava Version: %s' % java_version
        print '\t\t\tMax Heap: %d MB' % max_heap
        print '\t\t\tAvailable Heap: %d percent' % freeHeapPercent
        print '\t\t\tJVM Uptime: %d seconds' % (jvm_uptime / 1000)

def runningServers():

    #Get list of servers in current domain
    servers = cmo.getServers()
    domainRuntime()
    activeServers = []
    print "Getting list of active servers in current domain"
    print ''
    for server in servers:
        cd("/ServerLifeCycleRuntimes/" + server.getName())
        state = cmo.getState()
        if state == "RUNNING":
            activeServers.append(server.getName())

    return activeServers

connect("weblogic","welcome","myAdminServer:7001")

printJVMParametersOfRemoteServer()
print ''
disconnect()

Output – JVM heap attributes of remote server in weblogic (WLST/python)

c:\fmw_12.2.1.3.0\wls12213\oracle_common\common\bin>wlst.cmd d:\code\jvmHeapStatusServers.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://myAdminServer:7001 with userid weblogic ...
Successfully connected to Admin Server "AdminServer" that belongs to domain "osb_domain".

Warning: An insecure protocol was used to connect to the server.
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

Location changed to domainRuntime tree. This is a read-only tree
with DomainMBean as the root MBean.
For more help, use help('domainRuntime')

Getting list of active servers in current domain

JVM parameters of AdminServer server is :
                        Java Version: 1.8.0_74
                        Max Heap: 3048 MB
                        Available Heap: 9 percent
                        JVM Uptime: 2066 seconds
JVM parameters of prod_server1 server is :
                        Java Version: 1.8.0_74
                        Max Heap: 4075 MB
                        Available Heap: 71 percent
                        JVM Uptime: 2564 seconds
JVM parameters of prod_server3 server is :
                        Java Version: 1.8.0_74
                        Max Heap: 6075 MB
                        Available Heap: 81 percent
                        JVM Uptime: 7686 seconds

Disconnected from weblogic server: AdminServer
Scroll to Top