Tuesday, November 29, 2011

Sending alert message depending upon the JMS Queue count in weblogic server

import os

def sendMail(count,dest):
str3 = 'Queue with the NAME: '+ dest +' , has exceeded the Messages Current Count and now the COUNT is: ' + str(count)
cmd = "echo " + str3 + " > rw_file"
os.system(cmd)
os.system('/bin/mailx -s "ALERT: Messages Current Count Exceeded Limit !!! "abc@abc.com < rw_file')
print '********* ALTERT MAIL HAS BEEN SENT ***********'

connect('weblogic','weblogic1','t3://localhost:7001')
servers = domainRuntimeService.getServerRuntimes();
if (len(servers) > 0):
for server in servers:
jmsRuntime = server.getJMSRuntime();
jmsServers = jmsRuntime.getJMSServers();
for jmsServer in jmsServers:
destinations = jmsServer.getDestinations();
for destination in destinations:
print '.....Queue Count : ' , destination.getMessagesCurrentCount(), destination.getName()
if destination.getMessagesCurrentCount() > 50:
count=destination.getMessagesCurrentCount()
dest = destination.getName()
print '.....Queue Exceeded the Message Current Count : ' , count
print ''
sendMail(count , dest)


This will send an alert message once the queue count is greater than 50

No comments: