- 论坛徽章:
- 0
|
一个监控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 |
|