In environments where you have more usage of WAS JMS services and integration with Websphere MQ and MB. We might be in the need to look after the JMS listener status, always.
If the Listener status is "false" it means that your listener is not picking/writing messages from/to the Queue.
Before we end up in the backlog. Its always recommended to have one listener status monitoring which should/could intimate you in case of abrupt failure (or) stoppage in listener.
Here is the wsadmin Jython Script which will let you know the status of WAS Listeners under the Cell.
Jython code
Note on compatibility:
WAS6.1 and above as it has REGEX usage.
If the Listener status is "false" it means that your listener is not picking/writing messages from/to the Queue.
Before we end up in the backlog. Its always recommended to have one listener status monitoring which should/could intimate you in case of abrupt failure (or) stoppage in listener.
Here is the wsadmin Jython Script which will let you know the status of WAS Listeners under the Cell.
Jython code
import re Running_Nodes=AdminControl.queryNames('*:type=Server,name=nodeagent,*').split(java.lang.System.getProperty("line.separator")) print "----------------------------------------------------------------------------------------------" print "Websphere Listener Status Report for the Cell", AdminControl.getCell() cell=AdminControl.getCell() print "----------------------------------------------------------------------------------------------" print "" print "" for nod in Running_Nodes: NodeName=AdminControl.invoke(nod ,"getNodeName()") Running_JVMS=AdminControl.queryNames('*:type=Server,node='+NodeName+',*').split(java.lang.System.getProperty("line.separator")) for Serv in Running_JVMS: ServerName=AdminControl.invoke(Serv,"getName()") Listener_Ports=AdminControl.queryNames('*:type=ListenerPort,cell='+cell+',process='+ServerName+',*').split(java.lang.System.getProperty("line.separator")) if Listener_Ports == ['']: break else: print "" print ">>Server %r Running at %r"%(AdminControl.invoke(Serv,"getName()"),NodeName) print "----------------------------------------------------------------------------------------------" print "Name\tJNDIName\tDestiationQueueName\tAvailable" print "----------------------------------------------------------------------------------------------" for lis in Listener_Ports: JNDIName=AdminControl.invoke(lis,"getJmsConnJNDIName()") DestName=AdminControl.invoke(lis,"getJmsDestJNDIName()") match=re.search(r'([:\w]+)=([\w]+)',lis) name=match.group(2) state=AdminControl.invoke(lis,"isStarted()") print "%r\t%r\t%r\t%r"%(name,JNDIName,DestName,state) print "----------------------------------------------------------------------------------------------"
Note on compatibility:
WAS6.1 and above as it has REGEX usage.
Result
You can have a shell script on top of it which would trigger alert email in case of any "false" in the Available status.
Here is the sample shell script to send email notification. ( Make sure you have valid mail setup in your server with dummy mail before setting this up)
Environment Setup:
Shell script
As usual let me know your queries by comments.
Hope it helps.
Cheers,
Sarav
-------------------------------------------------------------------------------------- Websphere Listener Status Report for the Cell MWICell -------------------------------------------------------------------------------------- >>Server 'MWIServer1" Running at 'mwiNode01' -------------------------------------------------------------------------------------- Name JNDIName DestinationQueue Available -------------------------------------------------------------------------------------- 'Queue1_Rec' 'jms/App1_QCF' 'jms/App1receiverqueue' 'true' 'Queue2_Rec' 'jms/App2_QCF' 'jms/App2receiverqueue' 'true' 'Queue1_Send' 'jms/App1s_QCF' 'jms/App1senderqueue' 'true' 'Queue2_Send' 'jms/App2s_QCF' 'jms/App1senderqueue' 'true' --------------------------------------------------------------------------------------
You can have a shell script on top of it which would trigger alert email in case of any "false" in the Available status.
Here is the sample shell script to send email notification. ( Make sure you have valid mail setup in your server with dummy mail before setting this up)
Environment Setup:
- Create a directory in your server and copy all these script files (.py file and .sh file).
- Make sure you have full access on that directory as the script will be creating some temp files for processing.
Shell script
#!/bin/sh BASEDIR=`dirname $0` /apps/websphere8/mwi/bin/wsadmin.sh -conntype SOAP -host MWICell -port 8834 -user wasadminusr -password wasadminpass -lang jython -f $BASEDIR/listenerstatus.py > report RECIPIENTS="sara@mwinventory.in" grep -i "false" $report > $BASEDIR/outfile if [ $? -eq 0 ] then echo "Hi Team" >> $BASEDIR/outfile echo "" >> $BASEDIR/outfile echo "Below Listeners are seem to be notrunning or stopped, Please check the status and restart the JVM if required." >> $BASEDIR/outfile echo "" >> $BASEDIR/outfile mailx -s "ALERT: Listener Status Stopped" $RECIPIENTS < $BASEDIR/outfile fi
As usual let me know your queries by comments.
Hope it helps.
Cheers,
Sarav