Saturday, July 16, 2016

Weblogic MBean Monitoring


Weblogic provides a nice feature to monitor the server resources i.e. through MBeans.

weblogic mbeans types - configuration MBeans, Runtime MBeans and Application Defined MBeans

These can be browsed from EM console - go to admin server EM url for the domain which you are interested. Navigate to the server under the domain from EM console and then menu - System MBean Browser

you can see the above 3 types of MBeans tree structure. Normally for runtime stats, we check Runtime MBeans. say  com.bea - select a server - ServerRuntime - and select a type of MBean to browse and select the server


Example MBean for JDBC Data Sources

MBean Name com.bea:ServerRuntime=Server_1,Name=Server_1,Location=Server_1,Type=JDBCServiceRuntime
There are many attributes for this MBean and interesting one to monitor the resource usage is 'JDBCDataSourceRuntimeMBeans'
This attribute will list all the data sources configured for the server - click on a datasource to see its current usage

This is same as what we monitor from Admin console - datasources - monitoring ..

The same can also be done via a script using python/wlst

------------------------------------------------------------------------------------
def getConnectionPoolStat():
connect('adminUserName', 'adminPassword', 'adminURL')
name=cmo.getName()
domainRuntime()
cd('ServerRuntimes')
srvrs=domainRuntimeService.getServerRuntimes()
crntdr=pwd()
for srv in srvrs:
srvName=srv.getName()
cd(crntdr)
print srvName
cd(srvName +'/JDBCServiceRuntime/' + srvName)
allDS=cmo.getJDBCDataSourceRuntimeMBeans()
cd('JDBCDataSourceRuntimeMBeans')
for ds in  allDS:
dsName = ds.getName()
cd(dsName)
lcc=cmo.getLeakedConnectionCount()
ccy=cmo.getCurrCapacity()
accc=cmo.getActiveConnectionsCurrentCount()
frrc=cmo.getFailedReserveRequestCount()
ctc=cmo.getConnectionsTotalCount()
acavg=cmo.getActiveConnectionsAverageCount()
cchc=cmo.getCurrCapacityHighCount()
achc=cmo.getActiveConnectionsHighCount()
ftrc=cmo.getFailuresToReconnectCount()
st=name + ',' + dsName + ',' + srvName + ',' + str(acavg) + ',' + str(accc) + ',' + str(achc) + ',' + str(ctc) + ',' + str(ccy)+','+str(cchc)+ ',' + str(lcc) +',' + str(frrc)+','+ str(ftrc) + '\n'
fo.write(st)
cd('..')


fo=open("outputcsvfile","w+")
fo.write('DomainName , DataSourceName, ServerName, Active Connections Avg Count, Active connections current count, Active Connections high count, Connections Total Count, Current Capacity , Current High Capacity, Leaked Connection Count, Failed ReserveRequest Count, FailuresToReconnectCount  \n')
getConnectionPoolStat()
fo.close()

This needs to be executed from wlst in oracle common home
sessions per app can be collected through weblogic_j2eeserver:app_session..