0 Replies Latest reply on May 10, 2019 1:50 PM by Anindya G

    Taking thread dumps at certain intervals

    Anindya G

      Hi,

       

      I am trying to call the below python script from shell script but I am getting error. Can anyone please help me out:

      Shell Script:

      #!/bin/bash

       

       

      export WL_HOME=/u01/app/oracle/Middleware/wlserver_10.3

      export DOMAIN_HOME=/u01/app/oracle/Middleware/user_projects/domains/base_domain

       

       

      . $WL_HOME/server/bin/setWLSEnv.sh

      . $DOMAIN_HOME/bin/setDomainEnv.sh

       

       

      java weblogic.WLST $DOMAIN_HOME/ThreadDumps.py

       

       

      #python $DOMAIN_HOME/ThreadDumps.py

       

       

       

      Python Script:

      import thread

      import time

      import shutil

      import os

      #wlsUserID = java.lang.System.getenv('wlsUserID')

      #pwd = java.lang.System.getenv('wlsPassword')

      wlsUserID = "weblogic"

      pwd = "welcome1"

      url = "t3://localhost:7010"

      counter = 0

      def monitorJVMHeapSize():

          connect(wlsUserID, pwd, url)

          while 1:

              serverNames = getRunningServerNames()

              domainRuntime()

              for name in serverNames:

                  print 'Now checking '+name.getName()

                  try:

      for counter in range(10):

                    #cd('/ServerRuntimes/soa_serverb2b/JVMRuntime/soa_serverb2b')

                    cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName())

          print 'WARNING: The HEAPSIZE is Greater than the FREESIZE OR Taking Thread Dumps'

          fileName = 'dump' + name.getName() + '_' + str(java.util.Calendar.getInstance().getTime()) +'.dmp'

                                  threadDump()

                  except WLSTException,e:

                      print "Ignoring exception as the server is not active" + e.getMessage()

                  java.lang.Thread.sleep(10800)

       

       

       

      def getRunningServerNames():

              # only returns the currently running servers in the domain

              return domainRuntimeService.getServerRuntimes()

       

      if __name__== "main":

          monitorJVMHeapSize()

       

       

       

      Error:

      Now checking AdminServer

      WARNING: The HEAPSIZE is Greater than the FREESIZE

      Problem invoking WLST – Traceback (innermost last):

      File “/u01/app/oracle/Middleware/user_projects/domains/base_domain/ThreadDumps.py”, line 42, in ?

      File “/u01/app/oracle/Middleware/user_projects/domains/base_domain/ThreadDumps.py”, line 26, in monitorJVMHeapSize

      File “”, line 820, in threadDump

      at java.io.DataOutputStream.writeBytes(DataOutputStream.java:274)

      at weblogic.management.scripting.InformationHandler.threadDump(InformationHandler.java:1572)

      at weblogic.management.scripting.WLScriptContext.threadDump(WLScriptContext.java:663)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.lang.reflect.Method.invoke(Method.java:601)

       

      java.lang.NullPointerException: java.lang.NullPointerException

       

       

      Thanks,

      Anindya.