Hi,

Jay SenSharma

Jay SenSharma

Many times we want to monitor the different modules available as part of our WebLogic Domain. WebLogic Scripting Tool (WLST) is one of the best utility which is based on Jython (The Java Version of Python Scripting) Option.

WLST not only allows to configure different resources in WebLogic Server/Domain as well as it allows a very easy way to monitor different resources available as part of WebLogic Server/Domain. We can monitor JMS/ DataSources/JDBC Parameters…etc using WLST.

Here we are going to see a very simple demonstration of using WLST to monitor DataSources and the JDBC Properties which it holds, this part of monitoring includes both the Configuration Informations as well as the Runtime informations of the dataSource.

Step1). Create a WLST Script somewhere in your file system with some name like “Monitor_Jdbc.py”   inside “C:WLST_Jdbc”  contents will be something like following:

#############################################################################
#
# @author Copyright (c) 2010 - 2011 by Middleware Magic, All Rights Reserved.
#
#############################################################################

connect('weblogic','weblogic','t3://localhost:7001')
allServers=domainRuntimeService.getServerRuntimes();
if (len(allServers) > 0):
  for tempServer in allServers:
    jdbcServiceRT = tempServer.getJDBCServiceRuntime();
    dataSources = jdbcServiceRT.getJDBCDataSourceRuntimeMBeans();
    if (len(dataSources) > 0):
		for dataSource in dataSources:
			print 'ActiveConnectionsAverageCount      '  ,  dataSource.getActiveConnectionsAverageCount()
			print 'ActiveConnectionsCurrentCount      '  ,  dataSource.getActiveConnectionsCurrentCount()
			print 'ActiveConnectionsHighCount         '  ,  dataSource.getActiveConnectionsHighCount()
			print 'ConnectionDelayTime                '  ,  dataSource.getConnectionDelayTime()
			print 'ConnectionsTotalCount              '  ,  dataSource.getConnectionsTotalCount()
			print 'CurrCapacity                       '  ,  dataSource.getCurrCapacity()
			print 'CurrCapacityHighCount              '  ,  dataSource.getCurrCapacityHighCount()
			print 'DeploymentState                    '  ,  dataSource.getDeploymentState()
			print 'FailedReserveRequestCount          '  ,  dataSource.getFailedReserveRequestCount()
			print 'FailuresToReconnectCount           '  ,  dataSource.getFailuresToReconnectCount()
			print 'HighestNumAvailable                '  ,  dataSource.getHighestNumAvailable()
			print 'HighestNumUnavailable              '  ,  dataSource.getHighestNumUnavailable()
			print 'LeakedConnectionCount              '  ,  dataSource.getLeakedConnectionCount()
			print 'ModuleId                           '  ,  dataSource.getModuleId()
			print 'Name                               '  ,  dataSource.getName()
			print 'NumAvailable                       '  ,  dataSource.getNumAvailable()
			print 'NumUnavailable                     '  ,  dataSource.getNumUnavailable()
			print 'Parent                             '  ,  dataSource.getParent()
			print 'PrepStmtCacheAccessCount           '  ,  dataSource.getPrepStmtCacheAccessCount()
			print 'PrepStmtCacheAddCount              '  ,  dataSource.getPrepStmtCacheAddCount()
			print 'PrepStmtCacheCurrentSize           '  ,  dataSource.getPrepStmtCacheCurrentSize()
			print 'PrepStmtCacheDeleteCount           '  ,  dataSource.getPrepStmtCacheDeleteCount()
			print 'PrepStmtCacheHitCount              '  ,  dataSource.getPrepStmtCacheHitCount()
			print 'PrepStmtCacheMissCount             '  ,  dataSource.getPrepStmtCacheMissCount()
			print 'Properties                         '  ,  dataSource.getProperties()
			print 'ReserveRequestCount                '  ,  dataSource.getReserveRequestCount()
			print 'State                              '  ,  dataSource.getState()
			print 'Type                               '  ,  dataSource.getType()
			print 'VersionJDBCDriver                  '  ,  dataSource.getVersionJDBCDriver()
			print 'WaitingForConnectionCurrentCount   '  ,  dataSource.getWaitingForConnectionCurrentCount()
			print 'WaitingForConnectionFailureTotal   '  ,  dataSource.getWaitingForConnectionFailureTotal()
			print 'WaitingForConnectionHighCount      '  ,  dataSource.getWaitingForConnectionHighCount()
			print 'WaitingForConnectionSuccessTotal   '  ,  dataSource.getWaitingForConnectionSuccessTotal()
			print 'WaitingForConnectionTotal          '  ,  dataSource.getWaitingForConnectionTotal()
			print 'WaitSecondsHighCount               '  ,  dataSource.getWaitSecondsHighCount()

Step2). Start your WebLogic Server and Databases (Make sure that you have configured some dataSources in the Server to monitor).

Step3). Open a command prompt and then run the “setWLSEnv.cmd” or “setWLSEnv.sh”  to set the CLASSPATH and PATH variables. Better you do echo %CLASSPATH%    or echo $CLASSPATH to see whether the CLASSPATH is set properly or not. If you see an Empty Classpath even after running the “setWLSEnv.sh” then please refer to the Note mentioned at Step3) in the Following post:   http://middlewaremagic.com/weblogic/?page_id=1492

Step4). Now run the WLST Script in the same command prompt like following:

java       weblogic.WLST        C:WLST_JdbcMonitor_Jdbc.py
You will see the following kind of results in the command prompt

ActiveConnectionsAverageCount       0
ActiveConnectionsCurrentCount       0
ActiveConnectionsHighCount          0
ConnectionDelayTime                 25
ConnectionsTotalCount               10
CurrCapacity                        10
CurrCapacityHighCount               1
DeploymentState                     2
FailedReserveRequestCount           0
FailuresToReconnectCount            0
HighestNumAvailable                 10
HighestNumUnavailable               0
LeakedConnectionCount               0
ModuleId                            TestDS
Name                                TestDS
NumAvailable                        10
NumUnavailable                      0
Parent                              [MBeanServerInvocationHandler]com.bea:Name=AdminServer,Location=AdminServer,Type=ServerRuntime
PrepStmtCacheAccessCount            0
PrepStmtCacheAddCount               0
PrepStmtCacheCurrentSize            0
PrepStmtCacheDeleteCount            0
PrepStmtCacheHitCount               0
PrepStmtCacheMissCount              0
Properties                          {databaseName=jdbc:pointbase:server://localhost:9092/demo, user=PBPUBLIC}
ReserveRequestCount                 0
State                               Running
Type                                JDBCDataSourceRuntime
VersionJDBCDriver                   com.pointbase.jdbc.jdbcUniversalDriver
WaitingForConnectionCurrentCount    0
WaitingForConnectionFailureTotal    0
WaitingForConnectionHighCount       0
WaitingForConnectionSuccessTotal    0
WaitingForConnectionTotal           0
WaitSecondsHighCount                0
Jdbc_Monitoring_Using_WLST

Jdbc_Monitoring_Using_WLST

.

.

Thanks

Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.