Site icon

Script: get running/active servers in weblogic (wlst/python)

List of running servers in weblogic domain (WLST /example)

def runningServers():

    #Get list of servers in current domain
    servers = cmo.getServers()
    domainRuntime()
   
    print "List of running servers in current domain: "
    for server in servers:
        cd("/ServerLifeCycleRuntimes/" + server.getName())
        state = cmo.getState()
        if state == "RUNNING":
            print server.getName()
    print "End of script"

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

runningServers()

disconnect()

List server status in weblogic domain (WLST/example):

c:\fmw_12.2.1.3.0\wls12213\oracle_common\common\bin>wlst.cmd d:\code\ListRunningServers.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')

List of running servers in current domain:
AdminServer
pro_server1
pro_server3
pro_server9

End of script
Disconnected from weblogic server: AdminServer
Exit mobile version