Guest User

Untitled

a guest
Jan 22nd, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.06 KB | None | 0 0
  1. #======================================
  2. from java.io import FileInputStream
  3. import java.lang
  4. import os
  5. import string
  6. import sys
  7.  
  8. sys.stdout = file('currentAppState_file_DEL','w')
  9.  
  10. #propertiesFile = raw_input('Please enter path of properties file (e.g. /u01/app/oracle/domains/oms01/oms01.properties) : ')
  11. #propInputStream = FileInputStream(propertiesFile)
  12.  
  13. propInputStream = FileInputStream('oms01.properties')
  14. #propInputStream = FileInputStream('osb02.properties')
  15. configProps = Properties()
  16. configProps.load(propInputStream)
  17.  
  18. ServerUrl = configProps.get('datasource.targetServer.url')
  19. #UserName = configProps.get('admin.username')
  20. #Password = configProps.get('admin.password')
  21.  
  22. UserFile = configProps.get('keyfile.username')
  23. KeyFile = configProps.get('keyfile.password')
  24.  
  25. distroList = configProps.get('distroList.email')
  26.  
  27. # This module for managed Servers list
  28. def getRunningServerNames():
  29. domainConfig()
  30. serverNames = cmo.getServers()
  31. return serverNames
  32.  
  33. # This module is for sending email
  34. def sendMailString():
  35. connect(userConfigFile=UserFile,userKeyFile=KeyFile,url=ServerUrl)
  36. domainName = cmo.getName()
  37. #mailCommand = 'cat currentAppState_file_DEL | /bin/mail -s \"WLS HEALTH CHECK: \"' + domainName + '\" domain \" \"email@domain.com\" '
  38. mailCommand = 'cat currentAppState_file_DEL | /bin/mail -s \"WLS HEALTH CHECK: \"' + domainName + '\" domain \" \"' + distroList + '\" '
  39.  
  40. #serverNames = getRunningServerNames()
  41. os.system(mailCommand)
  42. print '********* ALERT MAIL HAS BEEN SENT ***********'
  43.  
  44. #This module is for retrieve the JVM statistics------------
  45. def monitorJVMHeapSize():
  46. # connect(UserName,Password,ServerUrl)
  47. connect(userConfigFile=UserFile,userKeyFile=KeyFile,url=ServerUrl)
  48.  
  49. serverNames = getRunningServerNames()
  50. domainRuntime()
  51. domainName = cmo.getName()
  52.  
  53. print 'WLS domain ' , domainName , ' server instances JVM statistics:'
  54. print ' TotalJVM FreeJVM UsedJVM'
  55. print ' '
  56. print '=========================================================================='
  57. for name in serverNames:
  58. try:
  59. cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName())
  60. freejvm = int(get('HeapFreeCurrent'))/(1024*1024)
  61. totaljvm = int(get('HeapSizeCurrent'))/(1024*1024)
  62. usedjvm = (totaljvm - freejvm)
  63. # writeInFile0 = '%14s %4d MB %4d MB %4d MB ' % (name.getName(),totaljvm, freejvm, usedjvm)
  64. writeInFile0 = '%29s %6d MB %6d MB %6d MB ' % (name.getName(),totaljvm, freejvm, usedjvm)
  65. print '', writeInFile0
  66. # cmd = "echo " + writeInFile0 + " >> currentAppState_file"
  67. # os.system(cmd)
  68.  
  69. except WLSTException,e:
  70. pass
  71.  
  72. print ' '
  73.  
  74. #This module is for retrieve the JMS statistics------------
  75. def monitorJMSQueue():
  76. connect(userConfigFile=UserFile,userKeyFile=KeyFile,url=ServerUrl)
  77. serverNames = domainRuntimeService.getServerRuntimes();
  78. domainRuntime()
  79.  
  80. if (len(serverNames) > 0):
  81. for server in serverNames:
  82. print '=========================================================================='
  83. print 'JMS statistics on ' , server.getName() , ' @ ' , server.getCurrentMachine()
  84. print server.getListenAddress()
  85. print '=========================================================================='
  86. jmsRuntime = server.getJMSRuntime();
  87. jmsServers = jmsRuntime.getJMSServers();
  88. for jmsServer in jmsServers:
  89. destinations = jmsServer.getDestinations();
  90. for destination in destinations:
  91. print ' DestinationName ' , destination.getName()
  92. print ' DestinationType ' , destination.getDestinationType()
  93. # print ' Type ' , destination.getType()
  94. # print ' BytesCurrentCount ' , destination.getBytesCurrentCount()
  95. # print ' BytesHighCount ' , destination.getBytesHighCount()
  96. # print ' BytesPendingCount ' , destination.getBytesPendingCount()
  97. # print ' BytesReceivedCount ' , destination.getBytesReceivedCount()
  98. # print ' BytesThresholdTime ' , destination.getBytesThresholdTime()
  99. print ' ConsumersCurrentCount ' , destination.getConsumersCurrentCount()
  100. print ' ConsumersHighCount ' , destination.getConsumersHighCount()
  101. # print ' ConsumersTotalCount ' , destination.getConsumersTotalCount()
  102. print ' ConsumptionPausedState ' , destination.getConsumptionPausedState()
  103. # print ' '
  104. # print ' DestinationInfo ' , destination.getDestinationInfo()
  105. # print ' '
  106. print ' MessagesCurrentCount ' , destination.getMessagesCurrentCount()
  107. print ' MessagesDeletedCurrentCount ' , destination.getMessagesDeletedCurrentCount()
  108. print ' MessagesHighCount ' , destination.getMessagesHighCount()
  109. print ' MessagesMovedCurrentCount ' , destination.getMessagesMovedCurrentCount()
  110. print ' MessagesPendingCount ' , destination.getMessagesPendingCount()
  111. print ' MessagesReceivedCount ' , destination.getMessagesReceivedCount()
  112. print ' MessagesThresholdTime ' , destination.getMessagesThresholdTime()
  113. # print ' Parent ' , destination.getParent()
  114. print ' Paused ' , destination.isPaused()
  115. # print ' InsertionPaused ' , destination.isInsertionPaused()
  116. print ' InsertionPausedState ' , destination.getInsertionPausedState()
  117. # print ' ProductionPaused ' , destination.isProductionPaused()
  118. print ' ProductionPausedState ' , destination.getProductionPausedState()
  119. print ' State ' , destination.getState()
  120. print ' ---------------------------------------------'
  121. print ' '
  122.  
  123.  
  124. if __name__== "main":
  125. monitorJVMHeapSize()
  126. print '=========================================================================='
  127. monitorJMSQueue()
  128. disconnect()
  129. #Application state monitoring-------------------
  130. print '=========================================================================='
  131. redirect('wlst.log','false')
  132. #connect(UserName,Password,ServerUrl)
  133. connect(userConfigFile=UserFile,userKeyFile=KeyFile,url=ServerUrl)
  134. cd ('AppDeployments')
  135. myapps=cmo.getAppDeployments()
  136. print '=========================================================================='
  137. print 'Following Applications are not in STATE_ACTIVE'
  138. print ' '
  139. print '=========================================================================='
  140. for appName in myapps:
  141. domainConfig()
  142. cd ('/AppDeployments/'+appName.getName()+'/Targets')
  143. mytargets = ls(returnMap='true')
  144. domainRuntime()
  145. cd('AppRuntimeStateRuntime/AppRuntimeStateRuntime')
  146. for targetinst in mytargets:
  147. currentAppState=cmo.getCurrentState(appName.getName(),targetinst)
  148. if currentAppState != "STATE_ACTIVE":
  149. writeInFile ='Applicaiton = "'+ appName.getName() +'" // Targeted Server = "'+str(mytargets)+'" // Current STATE = "'+ currentAppState +'"'
  150. print '', writeInFile
  151. # cmd = "echo " + writeInFile + " >> currentAppState_file"
  152. # os.system(cmd)
  153.  
  154. #connect(UserName,Password,ServerUrl)
  155. connect(userConfigFile=UserFile,userKeyFile=KeyFile,url=ServerUrl)
  156. serverNames=domainRuntimeService.getServerRuntimes();
  157. if (len(serverNames) > 0):
  158. for server in serverNames:
  159. jdbcServiceRT = server.getJDBCServiceRuntime();
  160. dataSources = jdbcServiceRT.getJDBCDataSourceRuntimeMBeans();
  161.  
  162. print '=========================================================================='
  163. print 'DataSource statistics on ' , server.getName() , ' @ ' , server.getCurrentMachine()
  164. print server.getListenAddress()
  165. print '=========================================================================='
  166. if (len(dataSources) > 0):
  167. for dataSource in dataSources:
  168. print ' ModuleId ' , dataSource.getModuleId()
  169. print ' Name ' , dataSource.getName()
  170. print ' State ' , dataSource.getState()
  171. print ' Properties ' , dataSource.getProperties()
  172. print ' ActiveConnectionsAverageCount ' , dataSource.getActiveConnectionsAverageCount()
  173. print ' ActiveConnectionsCurrentCount ' , dataSource.getActiveConnectionsCurrentCount()
  174. print ' ActiveConnectionsHighCount ' , dataSource.getActiveConnectionsHighCount()
  175. print ' ConnectionDelayTime ' , dataSource.getConnectionDelayTime()
  176. print ' ConnectionsTotalCount ' , dataSource.getConnectionsTotalCount()
  177. print ' CurrCapacity ' , dataSource.getCurrCapacity()
  178. print ' CurrCapacityHighCount ' , dataSource.getCurrCapacityHighCount()
  179. print ' DeploymentState ' , dataSource.getDeploymentState()
  180. print ' FailedReserveRequestCount ' , dataSource.getFailedReserveRequestCount()
  181. print ' FailuresToReconnectCount ' , dataSource.getFailuresToReconnectCount()
  182. print ' HighestNumAvailable ' , dataSource.getHighestNumAvailable()
  183. print ' HighestNumUnavailable ' , dataSource.getHighestNumUnavailable()
  184. print ' LeakedConnectionCount ' , dataSource.getLeakedConnectionCount()
  185. print ' NumAvailable ' , dataSource.getNumAvailable()
  186. print ' NumUnavailable ' , dataSource.getNumUnavailable()
  187. print ' Parent ' , dataSource.getParent()
  188. # print ' PrepStmtCacheAccessCount ' , dataSource.getPrepStmtCacheAccessCount()
  189. # print ' PrepStmtCacheAddCount ' , dataSource.getPrepStmtCacheAddCount()
  190. # print ' PrepStmtCacheCurrentSize ' , dataSource.getPrepStmtCacheCurrentSize()
  191. # print ' PrepStmtCacheDeleteCount ' , dataSource.getPrepStmtCacheDeleteCount()
  192. # print ' PrepStmtCacheHitCount ' , dataSource.getPrepStmtCacheHitCount()
  193. # print ' PrepStmtCacheMissCount ' , dataSource.getPrepStmtCacheMissCount()
  194. print ' ReserveRequestCount ' , dataSource.getReserveRequestCount()
  195. print ' Type ' , dataSource.getType()
  196. print ' VersionJDBCDriver ' , dataSource.getVersionJDBCDriver()
  197. print ' WaitingForConnectionCurrentCount ' , dataSource.getWaitingForConnectionCurrentCount()
  198. # print ' WaitingForConnectionFailureTotal ' , dataSource.getWaitingForConnectionFailureTotal()
  199. # print ' WaitingForConnectionHighCount ' , dataSource.getWaitingForConnectionHighCount()
  200. # print ' WaitingForConnectionSuccessTotal ' , dataSource.getWaitingForConnectionSuccessTotal()
  201. # print ' WaitingForConnectionTotal ' , dataSource.getWaitingForConnectionTotal()
  202. # print ' WaitSecondsHighCount ' , dataSource.getWaitSecondsHighCount()
  203. print ' ---------------------------------------------'
  204. print ' '
  205.  
  206. sendMailString()
  207. cmd = "rm -f wlst.log currentAppState_file_DEL"
  208. os.system(cmd)
  209. disconnect()
  210. #======================================
Add Comment
Please, Sign In to add comment