Created
January 6, 2011 10:36
-
-
Save stephen-masters/767747 to your computer and use it in GitHub Desktop.
WebLogic - Get JMS server stats
This file contains hidden or 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
# ---------------------------------------------------------------------- | |
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fair point ... now updated to improve style.