2014년 4월 21일 월요일

weblogic wlst workmanager monitoring

import thread
from java.util import Date
from java.text import SimpleDateFormat

# Configured user credentials with storeUserConfig

def monitorThrds():
    connect("weblogic", "
pwd", "t3://IP:Port");
    serverNames = getRunningServerNames()
    domainRuntime()


    for i in range(10000):
        print '[' + SimpleDateFormat('d MMM yyyy HH:mm:ss').format(java.util.Date()) + ']'
        for sname in serverNames:
            try:
                cd("domainRuntime:/ServerRuntimes/" + sname.getName() + "/MaxThreadsConstraintRuntimes/MaxThreadConstraint-oms")
                automaxexecnt=get('ExecutingRequests')
                automaxdefcnt = get('DeferredRequests')

                cd("domainRuntime:/ServerRuntimes/" + sname.getName() + "/MaxThreadsConstraintRuntimes/MaxThreadsConstraint-oms.ws.jms")
                jmsmaxexecnt=get('ExecutingRequests')
                jmsmaxdefcnt = get('DeferredRequests')

                cd("domainRuntime:/ServerRuntimes/" + sname.getName() + "/MinThreadsConstraintRuntimes/MinThreadsConstraint-oms.automation")
                autominexecnt=get('ExecutingRequests')
                autominpendcnt = get('PendingRequests')

                cd("domainRuntime:/ServerRuntimes/" + sname.getName() + "/MinThreadsConstraintRuntimes/MinThreadsConstraint-oms.ws.jms")
                jmsminexecnt=get('ExecutingRequests')
                jmsminpendcnt = get('PendingRequests')

                print '%8s %10s  Min = ( E:%4d    P:%4d )    Max = ( E:%4d        D:%4d )' %  ("(auto)", sname.getName(), autominexecnt, autominpendcnt, automaxexecnt, automaxdefcnt)
                print '%8s %10s  Min = ( E:%4d    P:%4d )    Max = ( E:%4d        D:%4d )' %  ("(jms)", sname.getName(), jmsminexecnt, jmsminpendcnt, jmsmaxexecnt, jmsmaxdefcnt)
            except WLSTException,e:
                # this typically means the server is not active, just ignore
                pass
        print '======================================================================'
        print ''
        import time
        time.sleep(3)

def getRunningServerNames():
        domainConfig()
        return cmo.getServers()

if __name__== "main":
    monitorThrds()
    disconnect()

weblogic wlst jms monitoring

import thread
from java.util import Date
from java.text import SimpleDateFormat

# Configured user credentials with storeUserConfig

def monitorJMS():
    connect("weblogic", "
pwd", "t3://IP:Port");
    servers = domainRuntimeService.getServerRuntimes();
    for i in range(10000):
        print '[' + SimpleDateFormat('d MMM yyyy HH:mm:ss').format(java.util.Date()) + ']'
        if (len(servers) > 0):
            for server in servers:
                print '  Server Name           ' , server
                jmsRuntime = server.getJMSRuntime();
                jmsServers = jmsRuntime.getJMSServers();
                for jmsServer in jmsServers:
                        destinations = jmsServer.getDestinations();
                        for destination in destinations:
                                print destination.getName()
                                print '  MessagesCurrentCount        ' ,  destination.getMessagesCurrentCount()
                                print '  MessagesHighCount           ' ,  destination.getMessagesHighCount()
                                print '  MessagesMovedCurrentCount   ' ,  destination.getMessagesMovedCurrentCount()
                                print '  MessagesPendingCount        ' ,  destination.getMessagesPendingCount()
                                print '  MessagesReceivedCount       ' ,  destination.getMessagesReceivedCount()
                print ''
                import time
                time.sleep(10)

if __name__== "main":
    monitorJMS()
    disconnect()

weblogic wlst thread monitoring

from java.util import Date
from java.text import SimpleDateFormat

# Configured user credentials with storeUserConfig

def monitorThrds():
    connect("weblogic", "
pwd", "t3://IP:Port");
    serverNames = getRunningServerNames()
    domainRuntime()


    for i in range(10000):
        print '[' + SimpleDateFormat('d MMM yyyy HH:mm:ss').format(java.util.Date()) + ']'
        print '======================================================================'
        print '| Execute     Total    Idle    Pending     Hogging    Queue     StdBy'
        print '| QueueName   Count    Count    Count       Count     Length    Count'
        print '======================================================================'
        for sname in serverNames:
            try:
                cd("domainRuntime:/ServerRuntimes/" + sname.getName() + "/ThreadPoolRuntime/ThreadPoolRuntime")

                totcnt=get('ExecuteThreadTotalCount')
                idlecnt = get('ExecuteThreadIdleCount')
                pndcnt =get('PendingUserRequestCount')
                sevcnt = get('HoggingThreadCount')
                queuelength = get('QueueLength')
                stdbycnt = get('StandbyThreadCount')
                print '| %10s  %4d    %4d       %4d        %4d     %4d      %4d' %  (sname.getName(), totcnt, idlecnt, pndcnt, sevcnt, queuelength, stdbycnt)
            except WLSTException,e:
                # this typically means the server is not active, just ignore
                pass
        print '======================================================================'
        print ''
        import time
        time.sleep(3)

def getRunningServerNames():
        domainConfig()
        return cmo.getServers()

if __name__== "main":
    monitorThrds()
    disconnect()

weblogic wlst SAF monitoring

from java.util import Date
from java.text import SimpleDateFormat

# Configured user credentials with storeUserConfig

def monitorThrds():
    connect("weblogic", "
pwd", "t3://IP:Port");
    serverNames = getRunningServerNames()
    serverRuntime()

    for i in range(10000):
        print '[' + SimpleDateFormat('d MMM yyyy HH:mm:ss').format(java.util.Date()) + ']'
        print '======================================================================'
        for sname in serverNames:
            try:
                cd("domainRuntime:/ServerRuntimes/" + sname.getName() + "/SAFRuntime/" +sname.getName() + ".saf/Agents")
                try:
                    agents=cmo.getAgents()
                    for agName in agents:
                        #print agName.getName()
                        cd(agName.getName())
                        msgpend=cmo.getMessagesPendingCount()
                        msgcur=cmo.getMessagesCurrentCount()
                        msgtot=cmo.getMessagesReceivedCount()
                        #print '%s messages received %s  = %d  %d  %d' % (agName.getName(), sname.getName(), msgcur, msgpend, msgtot)
                        #print '%-30s %s  CUR:%5d   PEND:%5d   RECV:%5d' % (agName.getName(), sname.getName(), msgcur,msgpend,msgtot )
                        print '%-30s  CUR:%5d   PEND:%5d  RECV:%8d' % (agName.getName(),  msgcur,msgpend,msgtot )
                        cd("..")

                except WLSTException,e:
                    pass
            except WLSTException,e:
                # this typically means the server is not active, just ignore
                pass
        print '======================================================================'
        print ''
        import time
        time.sleep(10)

def getRunningServerNames():
        domainConfig()
        return cmo.getServers()

if __name__== "main":
    monitorThrds()
    disconnect()