Thursday, June 23, 2011

Getting Fusion Middleware Application MBeans

To get fusion middleware MBeans (eg: BPEL properties, Mediator properties), the WLST shell that needs to be invoked is different from the regular weblogic WLST shell.

For querying the SOA MBeans, the following shell needs to be invoked.

SOA_ORACLE_HOME\common\bin\wlst.cmd (eg: C:\oracle\Middleware\Oracle_SOA1\common\bin\wlst.cmd)

fmwMBean.py
===================
connect('weblogic','password','t3://Adminhost:port')
domainRuntime()
SOAInfraConfigobj = ObjectName('oracle.as.soainfra.config:Location=soa_server1,name=soa-infra,type=SoaInfraConfig,Application=soa-infra')
print 'Common Properties for soa_server1'
print 'AuditLevel at SOAConfig (Global)~', mbs.getAttribute(SOAInfraConfigobj,'AuditLevel')
print 'CallbackServerURL~', mbs.getAttribute(SOAInfraConfigobj,'CallbackServerURL')
print 'GlobalTxMaxRetry~', mbs.getAttribute(SOAInfraConfigobj,'GlobalTxMaxRetry')
print 'GlobalTxRetryInterval~', mbs.getAttribute(SOAInfraConfigobj,'GlobalTxRetryInterval')

#Get BPEL Properties
BPELMBeanobj = ObjectName('oracle.as.soainfra.config:Location=soa_server1,name=bpel,type=BPELConfig,Application=soa-infra')
print 'BPEL Properties for soa_server1'
print 'DispatcherEngineThreads~', mbs.getAttribute(BPELMBeanobj,'DispatcherEngineThreads')
print 'DispatcherInvokeThreads~', mbs.getAttribute(BPELMBeanobj,'DispatcherInvokeThreads')
print 'DispatcherSystemThreads~', mbs.getAttribute(BPELMBeanobj,'DispatcherSystemThreads')
print 'LargeDocumentThreshold~', mbs.getAttribute(BPELMBeanobj,'LargeDocumentThreshold')

#Get Mediator Properties
MediatorMbeanobj = ObjectName('oracle.as.soainfra.config:Location=soa_server1,name=mediator,type=MediatorConfig,Application=soa-infra')
print 'Mediator Properties for soa_server1'
print 'AuditLevel for Mediator~',mbs.getAttribute(MediatorMbeanobj,'AuditLevel')
print 'ContainerIdLeaseTimeout~', mbs.getAttribute(MediatorMbeanobj,'ContainerIdLeaseTimeout')
print 'ResequencerWorkerThreadCount~', mbs.getAttribute(MediatorMbeanobj,'ResequencerWorkerThreadCount')

#Get HumanWorkFlow Properties
Humanworkflowobj = ObjectName('oracle.as.soainfra.config:Location=soa_server1,name=human-workflow,type=HWFMailerConfig,Application=soa-infra')
print 'Human Workflow Properties for soa_server1'
print 'Email from address~', mbs.getAttribute(Humanworkflowobj,'ASNSDriverEmailFromAddress')

#Get Adapter Properties for soa_server1
print 'Adapter Properties for soa_server1'
AdapterMbeanobj = ObjectName('oracle.as.soainfra.config:Location=soa_server1,name=adapter,type=AdapterConfig,Application=soa-infra')
print 'GlobalInboundJcaRetryCount~', mbs.getAttribute(AdapterMbeanobj,'GlobalInboundJcaRetryCount')
==============

The above script can be executed as:
c:\$SOA_ORACLE_HOME\common\bin\wlst.cmd fmwMBean.py > wlst.out

This data can be generated into an excel file (without the need to access em).
The above script generates values with a delimiter ~
The below script generates an excel file
Get text2xls.pl from :
http://www.perlmonks.org/bare/?node_id=72985
If you haven't used perl before, download it from ActivePerl site and to run a perl script, just do $ perl script.pl
To run the current script:

C:\WLST>perl text2xls.pl -i wlst.out -o test1.xls -d ~ (wlst.out is generated from above wlst script and -d option is the delimiter)
Starting text2xls.pl
infile = wlst.out
outfile = test1.xls
Finished text2xls.pl

This would generate an excel file (test1.xls) with MBean values without the need for em.

Both the above two operations (generating wlst.out and converting wlst.out to excel) can be wrapped in a batch/shell script for better automation.

References: http://biemond.blogspot.com/2010/02/invoking-fmw-application-mbeans-in.html
http://www.perlmonks.org/bare/?node_id=72985