Chinaunix
标题:
WLST脚本监控WebLogic的stuck thread
[打印本页]
作者:
Shell_HAT
时间:
2012-12-28 19:26
标题:
WLST脚本监控WebLogic的stuck thread
最近学习WLST,随便写了个,分享一下。
import os
userName = 'weblogic'
passWord = 'welcome1'
Url = 't3://192.168.0.2:7001'
connect(userName,passWord,Url)
serverAll = cmo.getServers()
domainRuntime()
fdAllStuck = open('stuckAll.log', 'w')
for serverEach in serverAll:
monitorServer = serverEach.getName()
cd('ServerRuntimes/' + monitorServer + '/ThreadPoolRuntime/ThreadPoolRuntime')
stuckThreadFile = "stuck" + monitorServer + ".log"
redirect(stuckThreadFile)
ls()
stopRedirect()
fdEachServer = open(stuckThreadFile)
allLineServer = fdEachServer.readlines()
fdEachServer.close()
stuckCounter = 0
for i in allLineServer:
if i.count('STUCK') != 0:
stuckCounter += 1
print >> fdAllStuck, ' '.join([monitorServer, str(stuckCounter)])
fdAllStuck.close()
stuckThreshold = 10
fdAllStuck = open('stuckAll.log')
allLineDomain = fdAllStuck.readlines()
fdAllStuck.close()
for i in allLineDomain:
stuckNum = i.split(' ')
if int(stuckNum[1]) > stuckThreshold:
os.system('mailx -s "Stuck thread count exceeded the threshold" Shell_HAT@ChinaUnix.net < stuckAll.log')
break
exit()
复制代码
作者:
rdcwayx
时间:
2013-01-04 08:30
不错,加点备注啊。
顺便看看这个。
http://middlewaremagic.com/weblogic/?p=5582
作者:
Shell_HAT
时间:
2013-01-04 10:32
回复
2#
rdcwayx
之前学习WLST的时候也看过这篇文章,挺不错的。不过那个代码获取的是hogging thread,并非stuck thread。前者可以通过getHoggingThreadCount()直接获取到,而后者只能想办法自己计算。所以才有了顶楼的代码。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2