免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3288 | 回复: 1
打印 上一主题 下一主题

[WebLogic] 一个监控weblogic运行状态的脚本执行报错,请高手帮忙看看,谢谢。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-05-25 23:37 |只看该作者 |倒序浏览
一个监控weblogic运行状态的脚本执行报错,请高手帮忙看看,谢谢。
# WLST WebLogic Server Monitoring Script
# Author: Madan M Noru
# Update by: XIANG
# This script can be used to monitor JVM, EXECUTE QUEUE, JDBC and JMS Resources
# of all the WebLogic Instances running in a domain.

# NOTE: If you are unable to run this script, it could be an indentation problem. Please post your E-mail Id, I can send you the script.

import time
i = 0
while ( i < 1 ) :
    import time
    print "atime:%s" % time.ctime()
    i = i + 1

    import os
    APP_ADM_SVR_IP=os.getenv("APP_SVR_IP")
    APP_SVR_PORT=os.getenv("APP_SVR_PORT")
    print 'ip:', APP_ADM_SVR_IP,' port:',APP_SVR_PORT
   
    username='weblogic'
    password='weblogic'
    url='%s%s%s%s' %('t3://', APP_ADM_SVR_IP, ':', APP_SVR_PORT)
    print 'url:', url
    urldict={}
    connect(username,password,url)
    #serverlist=adminHome.getMBeansByType('Server')
    #print serverlist

    print '==================================================================='
    try:
            print ' '
            count = 0
            while ( count < 1 ) :
            print ' '
            print 'count:',count, 'time:','.........................................................'
            connect('weblogic','weblogic',url)
            print '#########################[ JDBC CONNECTION POOLS ]#########################'
            poolrtlist=home.getMBeansByType('JDBCConnectionPoolRuntime')
            for poolRT in poolrtlist:
                    pname = poolRT.getName()
                    pmaxcapacity = poolRT.getAttribute("MaxCapacity")
                    paccc = poolRT.getAttribute("ActiveConnectionsCurrentCount")
                    pachc = poolRT.getAttribute("ActiveConnectionsHighCount")
                    pwshc = poolRT.getAttribute("WaitSecondsHighCount")
                    pwfccc = poolRT.getAttribute("WaitingForConnectionCurrentCount")
                    pstate = poolRT.getAttribute("State")
                    print 'Name    Maxcapacity    ActiveCurrent    ActiveHighCount    WaitSecondsHighCount    WaitingCurrentCount    State'
                    print ' '
                    print pname,'   ',pmaxcapacity,'    ',paccc,'    ',pachc,'     ', pwshc,'     ',pwfccc,'      ',pstate
                    print ' '
                    print '-------------------------------------------------------------------------'
                    print ' '
                    size = pmaxcapacity * 0.7
                    print 'monitor jdbcpool size:', size
                    if paccc >= size :
                       import os
                       os.system('sh kill3.sh')
            
            print '#########################[ JMS DESTINATIONS ]#########################'         
            jmsrtlist=home.getMBeansByType('JMSDestinationRuntime')
            for jmsRT in jmsrtlist:
                    jmsname = jmsRT.getAttribute("Name")
                    jmschc = jmsRT.getAttribute("ConsumersHighCount")
                    #jmsbcc = jmsRT.getAttribute("BytesCurrentCount")
                    #jmsbpc = jmsRT.getAttribute("BytesPendingCount")
                    #jmsbrc = jmsRT.getAttribute("BytesReceivedCount")
                    #jmsbhc = jmsRT.getAttribute("BytesHighCount")
                    jmsmcc = jmsRT.getAttribute("MessagesCurrentCount")
                    jmsmpc = jmsRT.getAttribute("MessagesPendingCount")
                    jmsmhc = jmsRT.getAttribute("MessagesHighCount")
                    jmsmrc = jmsRT.getAttribute("MessagesReceivedCount")
                    jmsctc = jmsRT.getAttribute("ConsumersTotalCount")
                    print 'Name   ConsumersHighCount   MessagesCurrentCount   MessagesPendingCount   MessagesHighCount   MessagesReceivedCount   ConsumersTotalCount'
                    print jmsname,'   ',jmschc,'   ',jmsmcc,'   ',jmsmpc,'   ',jmsmhc,'   ',jmsmrc,'   ',jmsctc
                    print ' '
                    print '-------------------------------------------------------------------------'
                    print ' '
            
            print '#########################[ JVM DESTINATIONS ]#########################'
            jvmrtlist=home.getMBeansByType('JVMRuntime')
            for jvmRT in jvmrtlist:
                    freejvm = jvmRT.getAttribute("HeapFreeCurrent")
                    totaljvm = jvmRT.getAttribute("HeapSizeCurrent")
                    usedjvm = (totaljvm - freejvm)
                    print freejvm,'   ',totaljvm,'   ',usedjvm
                    print ' '
                    print '-------------------------------------------------------------------------'
                    print ' '
            
            print '#########################[ EXECUTE QUEUES ]#########################'
            eqrtlist=home.getMBeansByType('ExecuteQueueRuntime')
            for eqRT in eqrtlist:
                  eqname = eqRT.getAttribute("Name")
                  eqtthreads = eqRT.getAttribute("ExecuteThreadTotalCount")
                  eqithreads = eqRT.getAttribute("ExecuteThreadCurrentIdleCount")
                  eqqc = eqRT.getAttribute("PendingRequestCurrentCount")
                  eqthrougp = eqRT.getAttribute("ServicedRequestTotalCount")
                  print 'ExecuteQueueName TotalCount CurrIdleCount PendRequestCurrCount ServicedRequestTotalCount'
                  print 'ExecuteQueueName   TotalCount   CurrIdleCount   PendRequestCurrCount   ServicedRequestTotalCount'
                  print eqname,'   ',eqtthreads,'   ',eqithreads,'   ',eqqc,'   ',eqthrougp
                  print ' '
                  print '-------------------------------------------------------------------------'
                  print ' '
            disconnect()
            count = count + 1
            print '==================================================================='
                                  
    except:
            print "Skipping "
            continue


报错信息如下:
Problem invoking WLST - Traceback (innermost last):
  (no code object) at line 0
  File "/app/pay1/pay/monitor/monitor_wls.py", line 34
                    print ' '
                    ^
SyntaxError: invalid syntax

论坛徽章:
0
2 [报告]
发表于 2012-05-26 05:19 |只看该作者
  File "test.py", line 28
    print ' '
        ^
IndentationError: expected an indented block
  1. ...
  2. while ( count < 1 ) :
  3. print ' '
  4. ...
复制代码
while下面的print没有缩进...
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP