免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4991 | 回复: 2

[WebLogic] WLST脚本监控WebLogic的stuck thread [复制链接]

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
发表于 2012-12-28 19:26 |显示全部楼层
最近学习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()
复制代码

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
发表于 2013-01-04 08:30 |显示全部楼层
不错,加点备注啊。

顺便看看这个。
http://middlewaremagic.com/weblogic/?p=5582

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
发表于 2013-01-04 10:32 |显示全部楼层
回复 2# rdcwayx


    之前学习WLST的时候也看过这篇文章,挺不错的。不过那个代码获取的是hogging thread,并非stuck thread。前者可以通过getHoggingThreadCount()直接获取到,而后者只能想办法自己计算。所以才有了顶楼的代码。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP