the listQueueDepth_WAS60.jy :
4:root@defrqap100mssxm:/opt/XXX/jms # cat /home/wasown/listQueueDepth_WAS60.jy
import sys
import os
import time
from java.util import *
# global DEBUG setting: 1 = active, 0 = disabled
DEBUG=0
##
## In this sequence, define the partial names of SIB destinations you are interested in!
##
_sibusName = "Saturn_JMS_Bus"
_myDests = ( '_SYSTEM.Exception', 'JMS' )
###########################################################################
###########################################################################
###
### FUNCTIONS
###
###########################################################################
###########################################################################
#get the command line
def _getScriptName():
p = java.lang.System.getProperties();
keys = p.keys();
while( keys.hasMoreElements() ):
name = keys.nextElement()
# print "Property: ", name," - ",
# print java.lang.System.getProperty(name)
return "not implemented in WAS6.0's jython versio!n"
# returns a timestamp string e.g. "2009.01.01 23:47:59"
def getCurrentTimeStamp():
timeArray = time.localtime(time.time())
tstmp = str(timeArray[0]) + '.' + str(timeArray[1]).zfill(2) + '.' + str(timeArray[2]).zfill(2)
tstmp = tstmp + ' ' + str(timeArray[3]).zfill(2) + ':' + str(timeArray[4]).zfill(2) + ':' + str(timeArray[5]).zfill(2)
return tstmp
# returns the name part from any MBean identifier string
# MBean id strings look like:
# "WebSphere:name=JMSTestOutboundQueue,process=server1,platform=dynamicproxy,node=esbNode,SIBus=MediaBus,......"
#
def getNameFromMBeanID(mbeanId):
t1 = mbeanId.split('name=')
t2 = t1[1].split(',')
return t2[0]
def usage(scriptname):
options = "--h --v --d
print "\n\nusage: ",scriptname, options
print ""
print "\t d secs if
print "\t Otherwise it will run forever, sleeping for
print "\t v verbose mode for better (human) readability. Non verbose means CSV list output."
print "\t "
print "\n\n"
### MAIN
#
#
#
###############################################################
## getopt start
args = sys.argv
if (DEBUG > 0):
print "len argv = ", len(args)
print "args = ",args
print "-----"
sleepTime = -1
verbose = 0
# process single (toggle) args first
#
argscopy = args[:]
for i in range(0,len(argscopy)):
if (argscopy[i] == "--h"):
print "HELP"
args.pop(i)
usage("")
sys.exit(0)
elif (argscopy[i] == "--v"):
args.pop(i)
verbose = 1
# process parameter args next: e.g. "--d 120"
#
if ((len(args) % 2 ) == 1): args.append(" ")
if (DEBUG > 0):
print "remaining args are:",args
argscopy = args[:]
for i in range(0,len(argscopy),2):
opt = argscopy[i]
val = argscopy[i+1]
if (DEBUG > 0): print "option: ", opt, " - value: ",val
if (opt == "--d"):
sleepTime = val
args.pop(i)
args.pop(i)
if (DEBUG > 0):
print "dbg: cmdline options found:"
print "dbg: sleepTime:",sleepTime
print "dbg: verbose :",verbose
print ""
if (len(args) > 0):
print "unprocessed args: ",args
## getopt end
###############################################################
# AdminControl.queryNames() output strings look like this:
#
# WebSphere:name=JMSTestOutboundQueue,process=server1,platform=dynamicproxy,node=esbNode,SIBus=MediaBus,version=6.1.0.23,
# ID=4BF5F7FBBD2C16D3F7D10B5B_QUEUE_10000005,type=SIBQueuePoint,mbeanIdentifier=com.ibm.ws.sib.admin.impl.JsQueuePoint,
# cell=esbCell,spec=1.0,SIBMessagingEngine=esbNode.server1-MediaBus
#
# retrieve all SIBQueuePoints
#
allSIBusDestinations = AdminControl.queryNames("WebSphere:*,type=SIBQueuePoint,SIBus=" + _sibusName).split()
# container for the QueuePoints we are interested in
matchedDests = []
for destMBeanId in allSIBusDestinations:
destName = getNameFromMBeanID(destMBeanId)
if (DEBUG > 0): print "dbg: found destination: ", destName
#
# see if we are interested in this particular SIBus destination
for m in _myDests:
## if (m == destName):
if (destName.startswith(m)):
matchedDests.append(destMBeanId )
# end if
# end for
# end for
if (DEBUG > 0): print ""
# begin CSV output
if (verbose == 0):
# print header row
print "time",",",
for i in matchedDests:
qname = getNameFromMBeanID(i)
print qname,",",
# print data rows
while (1):
if (verbose == 0):
print getCurrentTimeStamp(),",",
for d in matchedDests:
print AdminControl.getAttribute(d, "depth"),",",
else:
print getCurrentTimeStamp()
print "-------------------"
for d in matchedDests:
print AdminControl.getAttribute(d, "identifier")+":",
print AdminControl.getAttribute(d, "depth")
## print AdminControl.getAttribute(d, "state")
if (sleepTime == -1):
print ""
sys.exit(0)
time.sleep(int(sleepTime))
No comments:
Post a Comment