Monday, July 13, 2009

WLST Scripting: Know More on it

Here is a small script to get you started.

import java.lang.System as System
connect(userName,passWord,URL)
cd ('Servers')
servers = cmo.getServers()
cd('/')
runtime()

def isManagedServerRunning(server_name):
    cd('/ServerRuntimes/'+server_name+'/ServerLifeCycleRuntime/')
    print "Current state of server "+server_name+ " : " + cmo.getState()


def printHeapDetails(server_name):
    cd('/')
    cd('ServerRuntimes/'+server_name+'/JVMRuntime/'+server_name)
    hf = float(get('HeapFreeCurrent'))/1024
    hs = float(get('HeapSizeCurrent'))/1024
    hf = hf/1024
    hs = hs/1024
    print 'HeapFreeCurrent - ' + `hf` + 'MB'
    print 'HeapSizeCurrent - ' + `hs` + 'MB'

def jdbcConnectionPoolStatus(server_name):
    cd('/')
    cd('/ServerRuntimes/Desktop_managedServer_1/JDBCConnectionPoolRuntime/DSSReportingPool')
    print "Current State of DSSReportingPool is : " + cmo.getState()


for myServers in servers:

    print "-----------------------------------"
    print 'Status of ' + myServers.getName()
    print "-----------------------------------"

    isManagedServerRunning(myServers.getName())
    printHeapDetails(myServers.getName())
    jdbcConnectionPoolStatus(myServers.getName())


exit()



More info on this can be availed at

1) http://weblogicserver.blogspot.com/search?updated-min=2009-01-01T00%3A00%3A00-08%3A00&updated-max=2010-01-01T00%3A00%3A00-08%3A00&max-results=5

2) http://weblogicserver.blogspot.com/2009/03/check-for-resourceconfiguration.html

No comments: