有一个日志显示了Weblogic标记的卡住线程:
<Apr 23, 2013 7:48:25 AM CST> <Error> <WebLogicServer> <BEA-000337> <[STUCK] ExecuteThread: '276' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "668" seconds working on the request "weblogic.servlet.internal.ServletRequestImpl@23ba221b[
GET /XXX/saveInfo.do?fx=duration&info=25159,0,0,0,0,0,0,25153 HTTP/1.1
在我的例子中,我们观察到如果卡住的线程太多,我们的服务器会变得更慢的响应时间并且消耗越来越多的内存。
我想让卡住线程的计数成为我的自动报告机器人的健康指数。除了日志文件如何计算它?是否有任何命令或 api 帮助我计算卡住的线程?
从@viccari总结了解决方案(wlst 示例代码):
from tempfile import mktemp
connect('your_account', 'your_account_pass', 'localhost:7001')
# dump thread details to a temp file
file = mktemp()
threadDump(writeToFile="true", serverName="your_server_name", fileName=file)
# count the string token "[STUCK]" by line
count = 0
f = open(file, "r")
for line in f.readlines():
if line.find("STUCK") > 0:
count = count + 1
print "NUM_OF_STUCK_THREADS: ", count