Tuesday, February 12, 2013

SIB queue monitoring

When things go wrong, sometimes they aren't noticed early enough. Queue depth monitoring can provide some means of detecting things that might be wrong before the system hits the wall, e.g. by hitting the max queue depth of a vital queue.
A good approach would e.g. be to have a script, that is periodically kicked off by cron and that records the depth of important queues into a file, which can then be fed into any kind of monitoring and visualization mechanism using some additional scripting.

This sample here is a jython script, that you can call with
wsadmin -lang jython -f my-queue-depth-monitor.py
"wsadmin" is located in the /bin directory. 
A sample my-queue-depth-monitor.py file could look like:
import time
print "Start collecting queue depths - date/time:", time.ctime()
print
allqueues=AdminControl.queryNames('WebSphere:*,name=BPEIntQueue_BPMP.AppTarget,type=SIBQueuePoint').splitlines()
allqueues=allqueues + AdminControl.queryNames('WebSphere:*,name=sca/mySCAModule,type=SIBQueuePoint').splitlines()
allqueues=allqueues + AdminControl.queryNames('WebSphere:*,name=BPEHldQueue_BPMP.AppTarget,type=SIBQueuePoint').splitlines()
allqueues=allqueues + AdminControl.queryNames('WebSphere:*,name=WBI.FailedEvent.BPMP.AppTarget,type=SIBQueuePoint').splitlines()
allqueues=allqueues + AdminControl.queryNames('WebSphere:*,name=HTMHldQueue_BPMP.AppTarget,type=SIBQueuePoint').splitlines()
i=0
print "sequence number, queue name, current queue depth"
for queue in allqueues:
    i=i+1
    identifier=AdminControl.getAttribute(queue, 'identifier')
    depth=AdminControl.getAttribute(queue, 'depth')
    print i, identifier, depth
print
To use this, you need to adjust the names of the queues you'd like to monitor. The easiest would e.g. be to use the admin console, go to "Service Integration" -> "Service Integration Bus Browser" and then get the correct names of the queue points in the various buses on the right pane.
(with credits to my script co-author Sascha P.)