Created
January 6, 2011 10:28
-
-
Save stephen-masters/767740 to your computer and use it in GitHub Desktop.
WebLogic - Get connection pool sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------------------------------------- | |
# 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