Chinaunix

标题: WLST脚本监控WebLogic的stuck thread [打印本页]

作者: Shell_HAT    时间: 2012-12-28 19:26
标题: WLST脚本监控WebLogic的stuck thread
最近学习WLST,随便写了个,分享一下。
  1. import os

  2. userName = 'weblogic'
  3. passWord = 'welcome1'
  4. Url = 't3://192.168.0.2:7001'

  5. connect(userName,passWord,Url)
  6. serverAll = cmo.getServers()
  7. domainRuntime()

  8. fdAllStuck = open('stuckAll.log', 'w')
  9. for serverEach in serverAll:
  10.     monitorServer = serverEach.getName()
  11.     cd('ServerRuntimes/' + monitorServer + '/ThreadPoolRuntime/ThreadPoolRuntime')
  12.     stuckThreadFile = "stuck" + monitorServer + ".log"
  13.     redirect(stuckThreadFile)
  14.     ls()
  15.     stopRedirect()
  16.     fdEachServer = open(stuckThreadFile)
  17.     allLineServer = fdEachServer.readlines()
  18.     fdEachServer.close()
  19.     stuckCounter = 0
  20.     for i in allLineServer:
  21.         if i.count('STUCK') != 0:
  22.             stuckCounter += 1
  23.     print >> fdAllStuck, ' '.join([monitorServer, str(stuckCounter)])
  24. fdAllStuck.close()

  25. stuckThreshold = 10
  26. fdAllStuck = open('stuckAll.log')
  27. allLineDomain = fdAllStuck.readlines()
  28. fdAllStuck.close()
  29. for i in allLineDomain:
  30.     stuckNum = i.split(' ')
  31.     if int(stuckNum[1]) > stuckThreshold:
  32.         os.system('mailx -s  "Stuck thread count exceeded the threshold" Shell_HAT@ChinaUnix.net < stuckAll.log')
  33.         break

  34. 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