转:监控WLS 的py脚本_Tomcat, WebLogic及J2EE讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Tomcat, WebLogic及J2EE讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 3854 | 回复: 0   主题: 转:监控WLS 的py脚本        下一篇 
John
注册用户
等级:大元帅
经验:90444
发帖:136
精华:2
注册:2011-7-21
状态:离线
发送短消息息给John 加好友    发送短消息息给John 发消息
发表于: IP:您无权察看 2011-8-1 16:12:53 | [全部帖] [楼主帖] 楼主

转自:http://fm928.blog.163.com/blog/static/748135201011944636522/

作则:fm928

下面是一个py脚本,主要可以监控WLS的资源,HEAP JVM JMS。。。,我这主要是监控JMS的东西,把其他注释掉了,如需要打开注释
即可:

# WLST WebLogic Server Monitoring Script
# Author: Madan M Noru
# Update by: Botao Zheng
# 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())
Now = time.strftime(‘%Y%m%d-%H:%M:%S’,time.localtime(time.time()))
print Now
username=’weblogic’
password=’weblogic’
url=’t3://11.137.76.80:7791′
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(‘weblogic’,'weblogic’,'t3://11.137.76.80:7791′)
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 ‘ ‘
#
#下面注释是去掉JDBC和domainRuntime thre监控
#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 ‘Now Time:’,Now
print ‘-=-=-=-=-=-=-=-=-=-=-=-=-=Name——-MsgCurr–Pending–High–Received–ConsumersTotal–ConsumersHigh’
print ‘ ‘
for jmsRT in jmsrtlist:
jmsname = jmsRT.getAttribute("Name")
jmschc = jmsRT.getAttribute("ConsumersHighCount")
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,’ ‘,jmsctc
print Now,”,jmsname,’——’,jmsmcc,’– ‘,jmsmpc,’– ‘,jmsmhc,’– ‘, jmsmrc,’– ‘,jmsctc,’–’,jmschc
print ‘ ‘
print ‘——————————————————————-’
disconnect()
except:
print "Skipping "+svr
continue




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论