Jul 28, 2018

Oracle Weblogic 12c: Extracting the complete configuration via wlst.sh python script

If you want to get all information out of a weblogic server via wlst.sh than you can use the following script:
# written by Dietrich Schroff 2018
import sys


OutputFile='myfile.txt'
sys.stdout = open(OutputFile,'w')
connect('weblogic','mypasswd','t3://localhost:7001')
depth=0

def loopOverAllSubdirectories(goIntoThisDirectory,depth):
    depth=depth+1
    cd(goIntoThisDirectory)
    print depth," "*depth*2,goIntoThisDirectory
    try:
            completeInput=ls()
            inputArray=completeInput.split('\n')
        allParameters=[ x for x in inputArray if (not ("dr--" in x) or ("drw-" in x)) ]
        for Parameter in allParameters:
            if Parameter != "" :
                print depth," "*depth*2,Parameter
            allDirectoriesWrongFormat=[ x for x in inputArray if (("dr--" in x) or ("drw-" in x)) ]
            allDirectoriesWrongFormat2=[x.replace('dr--', '') for x in allDirectoriesWrongFormat]
            allDirectoriesToManyBlanks=[x.replace('drw-', '') for x in allDirectoriesWrongFormat2]
            allDirectories=[x.lstrip().rstrip() for x in allDirectoriesToManyBlanks]
        for Directory in allDirectories:
            if depth < 5 :
                loopOverAllSubdirectories(Directory,depth)
            cd('..')
    except:
        cd('..')

domainRuntime()
print "domainRuntime"
print "###############################################"
loopOverAllSubdirectories('/',0)
serverConfig()
print "ServerConfig"
print "###############################################"
loopOverAllSubdirectories('/',0)
This is a recursiv program which steps into all directories until a level of 5. On my weblogic server this scripts ran for more than two minutes:
# time ./wlst.sh myScript.py > /dev/null 

real    2m35.241s
user    0m29.405s
sys    0m4.259s
I tried unlimited depth, but then i had to stop at level 1500, because i think, that it will never stop ;-).

The output file would look like this:
domainRuntime
###############################################
1    /
1    -r--   ActivationTime                               Fri Feb 23 13:03:05 EST 2018  
1    -r--   MigrationDataRuntimes                        null  
1    -r--   Name                                         ovm_domain  
1    -rw-   Parent                                       null  
1    -r--   ServiceMigrationDataRuntimes                 null  
1    -r--   Type                                         DomainRuntime  
1    -r-x   preDeregister                                Void :   
1    -r-x   restartSystemResource                        Void : WebLogicMBean(weblogic.management.configuration.SystemResourceMBean)  
2      AppRuntimeStateRuntime
2      drw-   AppRuntimeStateRuntime
3        AppRuntimeStateRuntime
3        -r--   ApplicationIds                               java.lang.String[oracle.sdp.client#2.0@12.1.3, oracle.pwdgen#2.0@12.1.3, owasp.esapi#2.0@12.1.3, oracle.wsm.seedpolicies#2.0@12.1.3, odl.clickhistory#1.0@12.1.3, odl.clickhistory.webapp#1.0@12.1.3, oracle.jrf.system.filter, oracle.jsp.next#12.1.3@12.1.3, oracle.dconfig-infra#2.0@12.1.3, orai18n-adf#11@11.1.1.1.0, oracle.adf.dconfigbeans#1.0@12.1.3.0.0, adf.oracle.domain#1.0@12.1.3.0.0, adf.oracle.businesseditor#1.0@12.1.3.0.0, oracle.adf.management#1.0@12.1.3.0.0, adf.oracle.domain.webapp#1.0@12.1.3.0.0, jsf#2.1@2.1.7-01-, jstl#1.2@1.2.0.1, UIX#11@12.1.3.0.0, ohw-rcf#5@12.1.3.0.0, ohw-uix#5@12.1.3.0.0, oracle.adf.desktopintegration.model#1.0@12.1.3.0.0, oracle.adf.desktopintegration#1.0@12.1.3.0.0, oracle.bi.jbips#11.1.1@0.1, oracle.bi.composer#11.1.1@0.1, oracle.bi.adf.model.slib#1.0@12.1.3.0.0, oracle.bi.adf.view.slib#1.0@12.1.3.0.0, oracle.bi.adf.webcenter.slib#1.0@12.1.3.0.0, state-management-provider-memory-rar-12.1.3, wsil-wls#12.1.3.0.0, DMS Application#12.1.3.0.0, coherence-transaction-rar, ovm_core, ovm_console, ovm_help]  
3        -r--   Name                                         AppRuntimeStateRuntime  
3        -r--   Type                                         AppRuntimeStateRuntime  
3        -r-x   getCurrentState                              String : String(appid),String(moduleid),String(subModuleId),String(target)  
3        -r-x   getCurrentState                              String : String(appid),String(moduleid),String(target)  
[.....]
4          JVMRuntime
4          drw-   AdminServer
5            AdminServer
5            -r--   HeapFreeCurrent                              447991664  
5            -r--   HeapFreePercent                              90  
5            -r--   HeapSizeCurrent                              841109504  
5            -r--   HeapSizeMax                                  4151836672  
5            -r--   JavaVMVendor                                 Oracle Corporation  
5            -r--   JavaVendor                                   Oracle Corporation  
5            -r--   JavaVersion                                  1.7.0_151  
5            -r--   Name                                         AdminServer  
5            -r--   OSName                                       Linux  
5            -r--   OSVersion                                    4.1.12-94.3.9.el7uek.x86_64  
5            -r--   Type                                         JVMRuntime  
5            -r--   Uptime                                       22612965  
5            -r-x   preDeregister                                Void :   
# wc -l myfile.txt 
19787 myfile.txt
Nearly 20.000 parameters... not bad...

1 comment: