Forum Stats

  • 3,768,537 Users
  • 2,252,807 Discussions
  • 7,874,614 Comments

Discussions

oradebug how to execute from python script

3794542
3794542 Member Posts: 1
edited Sep 26, 2018 9:03PM in Python

i want to achieve following command from python script

oradebug setospid <process ID>

oradebug unlimit

oradebug dump processstate 10

clcarter

Answers

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,784 Bronze Crown
    edited Sep 26, 2018 9:03PM

    I have always accessed the oradebug utility through sqlplus.

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

    $ cat sqlplus.pyimport sysimport osfrom subprocess import Popen, PIPE# oradebug requires sysdba privilegesqlplus = 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 oracleora12coracle   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 30124Oracle pid: 49, Unix process pid: 30124, image: [email protected] processed.Statement processed.$

    You may also find this useful:

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

    clcarter
This discussion has been closed.