Python实现的weblogic监控

利用WLST调用对weblogic server进行监控,Python实现。
# WLST WebLogic Server Monitoring Script
# Author: Madan M Noru
# This script can be used to monitor JVM, EXECUTE QUEUE, JDBC and JMS Resources
# of all the WebLogic Instances running in a domain.

# NOTE: If you are unable to run this script, it could be an indentation problem. Please post your E-mail Id, I can send you the script.
import time
Now = time.localtime(time.time())[6]
print Now
username='eprm'
password='eprm123456'
url='t3://134.96.101.9:8001'
urldict={}
connect(username,password,url)
serverlist=adminHome.getMBeansByType('Server')
print serverlist

for svr in serverlist:
#urldict['' + svr.getName() + ''] = str(svr.getListenPort())
        urldict[svr.getName()]='t3://'+svr.getListenAddress()+':'+str(svr.getListenPort())
disconnect()

for svr,url in urldict.items():
        try:
                connect('eprm','eprm123456','t3://134.96.101.9:8001')
                jvmrtlist=home.getMBeansByType('JVMRuntime')
                print jvmrtlist
                print ' '
                print ' ' 
                print 'The Runtime Stats of Server: '+svr
                print ' '
                print 'JVM'
                print ' '
                print 'FreeJVM TotalJVM UsedJVM' 
                print ' '
                for jvmRT in jvmrtlist:
                        freejvm = jvmRT.getAttribute("HeapFreeCurrent")
                        totaljvm = jvmRT.getAttribute("HeapSizeCurrent")
                        usedjvm = (totaljvm - freejvm)
                        print freejvm,' ',totaljvm,' ',usedjvm
                        print ' '
                        print '------------------------------------------------'
                        #time.sleep(5)

#注释掉部分为执行队列的监控
#               eqrtlist=home.getMBeansByType('ExecuteQueueRuntime')
#               print ' '
#               print ' '
#               print 'EXECUTE QUEUES'
#               print ' '
#               print 'ExecuteQueueName TotalCount CurrIdleCount PendRequestCurrCount ServicedRequestTotalCount'
#               print ' '
#               for eqRT in eqrtlist:
#                       eqname = eqRT.getAttribute("Name")
#                       eqtthreads = eqRT.getAttribute("ExecuteThreadTotalCount")
#                       eqithreads = eqRT.getAttribute("ExecuteThreadCurrentIdleCount")
#                       eqqc = eqRT.getAttribute("PendingRequestCurrentCount")
#                       eqthrougp = eqRT.getAttribute("ServicedRequestTotalCount")
#                       print eqname,' ',eqtthreads,' ',eqithreads,' ',eqqc,' ',eqthrougp
#                       print ' '
#               
                poolrtlist=home.getMBeansByType('JDBCConnectionPoolRuntime')
                print ' '
                print ' '
                print 'JDBC CONNECTION POOLS'
                print ' '
                print 'Name Maxcapacity ActiveCurrent ActiveHighCount WaitSecondsHighCount WaitingCurrentCount State'
                print ' '
                for poolRT in poolrtlist:
                        pname = poolRT.getName()
                        pmaxcapacity = poolRT.getAttribute("MaxCapacity")
                        paccc = poolRT.getAttribute("ActiveConnectionsCurrentCount")
                        pachc = poolRT.getAttribute("ActiveConnectionsHighCount")
                        pwshc = poolRT.getAttribute("WaitSecondsHighCount")
                        pwfccc = poolRT.getAttribute("WaitingForConnectionCurrentCount")
                        pstate = poolRT.getAttribute("State")
                        print pname,' ',pmaxcapacity,' ',paccc,' ',pachc,' ', pwshc,' ',pwfccc,' ',pstate
                        print ' '
                        print '-------------------------------------------------------------'

                domainRuntime()                                                             
                #cd('ServerRuntimes/'+svr+'/WorkManagerRuntimes/weblogic.kernel.Default')
                cd('ServerRuntimes/'+svr+'/ThreadPoolRuntime/ThreadPoolRuntime')
                print ls()                                                                  
                print '-----------------------------------------------------------------'
                
                jmsrtlist=home.getMBeansByType('JMSDestinationRuntime')
                print ' '
                print ' '
                print 'JMS DESTINATIONS'
                print ' '
                print 'Name ByteCurr Pending Received High MsgCurr Pending High Received ConsumersTotal' 
                print ' '
                for jmsRT in jmsrtlist:
                        jmsname = jmsRT.getAttribute("Name")
                        jmsbcc = jmsRT.getAttribute("BytesCurrentCount")
                        jmsbpc = jmsRT.getAttribute("BytesPendingCount")
                        jmsbrc = jmsRT.getAttribute("BytesReceivedCount")
                        jmsbhc = jmsRT.getAttribute("BytesHighCount")
                        jmsmcc = jmsRT.getAttribute("MessagesCurrentCount")
                        jmsmpc = jmsRT.getAttribute("MessagesPendingCount")
                        jmsmhc = jmsRT.getAttribute("MessagesHighCount")
                        jmsmrc = jmsRT.getAttribute("MessagesReceivedCount")
                        jmsctc = jmsRT.getAttribute("ConsumersTotalCount")
                        print jmsname,' ',jmsbcc,' ',jmsbpc,' ',jmsbrc,' ',jmsbhc,' ',jmsmcc,' ',jmsmpc,' ',jmsmhc,' ', jmsmrc,' ',j
msctc
                        print ' '
                        print '-------------------------------------------------------------------'
                disconnect()
        except:
                print "Skipping "+svr
                continue

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值