1 Reply Latest reply on Sep 27, 2018 1:03 AM by Gaz in Oz

    oradebug how to execute from python script

    3794542

      i want to achieve following command from python script

       

      oradebug setospid <process ID>

      oradebug unlimit

      oradebug dump processstate 10

        • 1. Re: oradebug how to execute from python script
          Gaz in Oz

          I have always accessed the oradebug utility through sqlplus.

          To make a wrapper to use sqlplus -> oradebug, you could for example:

          $ cat sqlplus.py
          import sys
          import os
          from subprocess import Popen, PIPE
          
          # oradebug requires sysdba privilege
          sqlplus = Popen(["sqlplus", "-S", "/", "as", "sysdba"], stdout=PIPE, stdin=PIPE)
          # get OS pid from somewhere, in this case argument passed in from commandline.
          sqlplus.stdin.write("oradebug setospid "            + sys.argv[1] + os.linesep +
                              "oradebug unlimit"              + os.linesep +
                              "oradebug dump processstate 10" + os.linesep)
          out, err = sqlplus.communicate()
          print out
          
          

          ...then to get a dump of an oradebug dump of an Oracle process:

          $ ps -ef | grep oracleora12c
          oracle   26339     1  0 Aug29 ?        00:00:00 oracleora12cr2 (LOCAL=NO)
          oracle   30124     1  0 10:34 ?        00:00:00 oracleora12c (LOCAL=NO)
          oracle   30354 26934  0 10:45 pts/0    00:00:00 grep oracleora12c
          $ python sqlplus.py 30124
          Oracle pid: 49, Unix process pid: 30124, image: oracle@x3200
          Statement processed.
          Statement processed.
          
          $
          

          You may also find this useful:

          https://www.oracle.com/technetwork/articles/dsl/mastering-oracle-python-dba-1392286.html