2013-04-23 32 views
1

有證據顯示受WebLogic標誌着阻塞線程日誌:如何計算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 "[email protected][ 
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 

回答

1

您可以訪問使用WLST(WebLogic腳本工具)腳本線程池的健康細節(如果你熟悉Python,它應該不是問題),或者通過使用Java訪問JMX計數器。

This post包含一個示例腳本,每當存在卡住的線程時都會發送警報電子郵件,並且在評論部分中,您將找到一些Java代碼訪問JMX計數器的示例。網絡上有更多這兩種方法的例子。