Skip to content

Instantly share code, notes, and snippets.

@stephen-masters
Created January 6, 2011 10:36
Show Gist options
  • Save stephen-masters/767747 to your computer and use it in GitHub Desktop.
Save stephen-masters/767747 to your computer and use it in GitHub Desktop.
WebLogic - Get JMS server stats
# ----------------------------------------------------------------------
# Example of connecting to a running JMS server and getting stats.
# ----------------------------------------------------------------------
import java.lang.Thread
def get_messaging_stats():
print 'Searching for JMS connections...'
# Hard-codes the JMS server name. You will probably want to parameterize this.
ls('/JMSRuntime/MyJmsServer.jms')
server_map = ls('/JMSRuntime/MyJmsServer.jms/JMSServers', returnMap='true')
if server_map.size() > 0:
for jms_server in server_map:
# Move to it so that we have access to the 'cmo'
cd('/JMSRuntime/MyJmsServer.jms/JMSServers/' + jms_server)
ls()
print 'JMS Server Name=' + cmo.getName() + ', MessagesReceivedCount=' + str(cmo.getMessagesReceivedCount())
else:
print 'No JMS servers found on this server.'
else:
print 'No servers found on this server ... what?'
# --------------------------------------------------
# Main script starts here...
# --------------------------------------------------
# Connect to the JMS server...
connect("user", "password", "t3://server:port")
serverRuntime()
while true:
get_messaging_stats()
Thread.sleep(5000)
exit()
@stephen-masters
Copy link
Author

Fair point ... now updated to improve style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment