Skip to content

Instantly share code, notes, and snippets.

@stephen-masters
Created January 6, 2011 10:28
Show Gist options
  • Save stephen-masters/767740 to your computer and use it in GitHub Desktop.
Save stephen-masters/767740 to your computer and use it in GitHub Desktop.
WebLogic - Get connection pool sizes
# --------------------------------------------------
# Use WLST to connect to running WebLogic application servers and
# output a list of database connection pools and their sizes.
#
# This can be used for health monitoring and to support tuning.
# --------------------------------------------------
import java.lang.Thread
def get_connection_pool_sizes():
print 'Searching for JDBC data sources...'
# Get a java.util.HashMap of running servers.
server_map = ls('/JDBCServiceRuntime', returnMap='true')
if server_map.size() > 0:
for server_bean in server_map:
data_source_map = ls('/JDBCServiceRuntime/' + server_bean + '/JDBCDataSourceRuntimeMBeans', returnMap='true')
if data_source_map.size() > 0:
print 'Found the following data sources...'
for data_source_bean in data_source_map:
# Move to it so that we have access to the 'cmo'
cd('/JDBCServiceRuntime/' + server_bean + '/JDBCDataSourceRuntimeMBeans/' + data_source_bean)
print 'Data source=' + cmo.getName() + ' ActiveConnectionsCurrentCount=' + str(cmo.getActiveConnectionsCurrentCount()) + ' ActiveConnectionsHighCount=' + str(cmo.getActiveConnectionsHighCount()) + ' ConnectionDelayTime=' + str(cmo.getConnectionDelayTime()) + ' ConnectionsTotalCount=' + str(cmo.getConnectionsTotalCount()) + ' NumAvailable=' + str(cmo.getNumAvailable()) + ' NumUnavailable=' + str(cmo.getNumAvailable()) + ' WaitingForConnectionCurrentCount=' + str(cmo.getWaitingForConnectionCurrentCount()) + ' WaitingForConnectionFailureTotal=' + str(cmo.getWaitingForConnectionFailureTotal()) + ' WaitingForConnectionHighCount=' + str(cmo.getWaitingForConnectionHighCount()) + ' WaitingForConnectionSuccessTotal=' + str(cmo.getWaitingForConnectionSuccessTotal()) + ' WaitingForConnectionTotal=' + str(cmo.getWaitingForConnectionTotal())
else:
print 'No data sources found on this server.'
else:
print 'No servers found on this server ... what?'
# --------------------------------------------------
# Main script starts here...
# --------------------------------------------------
# Connect using t3 to the port the application server is listening on.
connect("adminuser", "adminpassword", "t3://server:port")
serverRuntime()
while true:
get_connection_pool_sizes()
Thread.sleep(60000)
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment