weblogic 服务器状态控制脚本

weblogic server state control script

这是 weblogic 控制脚本,但脚本结束失败并出现此错误 -- |临时|调用 WLST 时出现问题 - Traceback(最内层的最后一个):文件“/appdata/weblogic/scripts/checkInstanceByWlst.py”,第 63 行,在 sValueError 中:int 的无效文字:临时 - 但没有问题在代码中 你能帮帮我吗?

`def serverStatus(server):
 try:
 cd('/ServerLifeCycleRuntimes/' + server.getName())
 return cmo.getState()
 except ConnectionException,e:
 return "NOT_REACHABLE"

adminName = sys.argv[1]
URL= "t3://" + sys.argv[2]
date = sys.argv[3]
unixDate = sys.argv[4]

temp_list = []

username = str(sys.argv[5])
password = str(sys.argv[6])

try:
connect(username,password,URL) 
except ConnectionException,e:
print '3[1;31m Unable to find admin server...3[0m'
exit()

#domainRuntime()

#servers=cmo.getServerLifeCycleRuntimes()
webVer = version
webVer = webVer.split(' ')[2].split('.')[0]

servers = cmo.getServers()
domainRuntime()

print '|' + webVer + '|'

for server in servers:
    openSocketCount = "0"
    idleTC = "0"
    executeTC = "0"
    hoggerTC = "0"
    stuckTC = "0"
    serverName = str(server.getName())
    if serverName != adminName:
       f2 = open( '.servers.donotdelete', 'a' )
       f2.writelines( str(server.getName()) + "\n" )
       f2.close()

       serverState = serverStatus(server)

       if serverState != "RUNNING":
          serverHealth = "NOT_REACHABLE" 
       else:
          #cd('/ServerRuntimes/' + serverName)
         # serverHealth = str(cmo.getHealthState())
          try:
             cd('/ServerRuntimes/' + str(server.getName()))
             serverHealth = str(cmo.getOverallHealthState())
             serverHealth = serverHealth.split('State:')[1].split(',')[0]
             openSocketCount = str(get('OpenSocketsCurrentCount'))
             cd('ThreadPoolRuntime/ThreadPoolRuntime/')
             idleTC = str(get('ExecuteThreadIdleCount'))
             executeTC = str(get('ExecuteThreadTotalCount') - get('StandbyThreadCount'))
             hoggerTC = str(get('HoggingThreadCount'))
             if int(webVer) > 11:
                stuckTC = str(get('StuckThreadCount'))

             cd('/ServerRuntimes/' + str(server.getName()))
             dataSources = cmo.getJDBCServiceRuntime().getJDBCDataSourceRuntimeMBeans()
             if (len(dataSources) > 0):
                for dataSource in dataSources:
                   if  str(dataSource.getState()) != "Running":
                      f1 = open( '.datasources.donotdelete', 'a' )
                      f1.writelines( str(server.getName()) + ' | ' + str(dataSource.getName()) + ' | 
    ' + str(dataSource.getState()) + "\n" )
                      f1.close()

          except Exception,e:
             serverHealth = "NOT_REACHABLE"
             #continue

          #serverHealth = str(cmo.getOverallHealthState())
          #serverHealth = serverHealth.split('State:')[1].split(',')[0]
          #openSocketCount = str(get('OpenSocketsCurrentCount'))
          #cd('ThreadPoolRuntime/ThreadPoolRuntime/')
          #idleTC = str(get('ExecuteThreadIdleCount'))
          #executeTC = str(get('ExecuteThreadTotalCount') - get('StandbyThreadCount'))
          #hoggerTC = str(get('HoggingThreadCount'))
          #if int(webVer) > 11:
          #   stuckTC = str(get('StuckThreadCount'))

          #cd('/ServerRuntimes/' + server.getName())
          #dataSources = cmo.getJDBCServiceRuntime().getJDBCDataSourceRuntimeMBeans()
          #if (len(dataSources) > 0):
          #   for dataSource in dataSources:
          #      if  str(dataSource.getState()) != "Running":
          #          f1 = open( '.datasources.donotdelete', 'a' )
          #          f1.writelines( str(server.getName()) + ' | ' + str(dataSource.getName()) + ' | ' 
       + str(dataSource.getState()) + "\n" )
          #          f1.close()
       f = open( '.' + str(server.getName()) + '.donotdelete', 'a' )
       f.writelines( date + '|' + unixDate + '|' + serverState + '|' + serverHealth + '|' + 
       openSocketCount + '|' + idleTC + '|' + executeTC + '|' + hoggerTC + '|' + stuckTC + "\n")
       f.close()`

这可以在 Weblogic 版本 12.2.1.1.0 上成功运行,但不能在 10.3.3 上运行。

您好,我解决如下。

Python 文件; connect('user','pass','t3://**.**.**.**:7001') x=ls('Servers',returnMap='true') for i in x: state(i,'Server')