Пример #1
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    # BEWARE: There is an implicit dependency on the structure of Oracle schema URI.
    ora_schema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'PACKAGE' AND OWNER = '" + ora_schema + "'"
    logging.debug("sql_query=%s", sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, ora_schema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        package_name = str(row[0])
        node_package = oracle_package.MakeUri(cgiEnv.m_oraDatabase, ora_schema,
                                              package_name)
        grph.add((node_oraschema, pc.property_oracle_package, node_package))

        lib_oracle.AddLiteralNotNone(grph, node_package, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, node_package, "Creation", row[2])

    # It cannot work if there are too many tables.
    # cgiEnv.OutCgiRdf("LAYOUT_RECT")
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_package])
Пример #2
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'SYNONYM' AND OWNER = '" + oraSchema + "'"
    DEBUG("sql_query=%s", sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        synonymName = str(row[0])
        nodeSynonym = oracle_synonym.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                             synonymName)
        grph.add((node_oraschema, pc.property_oracle_synonym, nodeSynonym))

        lib_oracle.AddLiteralNotNone(grph, nodeSynonym, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, nodeSynonym, "Creation", row[2])

    # It cannot work if there are too many views.
    # cgiEnv.OutCgiRdf("LAYOUT_RECT")
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_synonym])
Пример #3
0
def _list_dba_users(cgiEnv, node_oradb, grph):
    # SQL> desc dba_users
    #  Name                                      Null?    Type
    #  ----------------------------------------- -------- ----------------------------
    #  USERNAME                                  NOT NULL VARCHAR2(30)
    #  USER_ID                                   NOT NULL NUMBER
    #  PASSWORD                                           VARCHAR2(30)
    #  ACCOUNT_STATUS                            NOT NULL VARCHAR2(32)
    #  LOCK_DATE                                          DATE
    #  EXPIRY_DATE                                        DATE
    #  DEFAULT_TABLESPACE                        NOT NULL VARCHAR2(30)
    #  TEMPORARY_TABLESPACE                      NOT NULL VARCHAR2(30)
    #  CREATED                                   NOT NULL DATE
    #  PROFILE                                   NOT NULL VARCHAR2(30)
    #  INITIAL_RSRC_CONSUMER_GROUP                        VARCHAR2(30)
    #  EXTERNAL_NAME                                      VARCHAR2(4000)
    #  PASSWORD_VERSIONS                                  VARCHAR2(8)
    #  EDITIONS_ENABLED                                   VARCHAR2(1)
    #  AUTHENTICATION_TYPE                                VARCHAR2(8)

    qry_dba_users = "select username, user_id, account_status, lock_date, expiry_date from dba_users"
    result = lib_oracle.ExecuteQueryThrow(cgiEnv.ConnectStr(), qry_dba_users)

    for row in result:
        # row=('ORACLE_OCM', 21, 'EXPIRED & LOCKED')
        logging.debug("row=" + str(row))
        node_schema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, str(row[0]))
        grph.add((node_oradb, pc.property_oracle_schema, node_schema))

        lib_oracle.AddLiteralNotNone(grph, node_schema, "Schema-id", row[1])
        lib_oracle.AddLiteralNotNone(grph, node_schema, "Status", row[2])
        lib_oracle.AddLiteralNotNone(grph, node_schema, "Lock date", row[3])
        lib_oracle.AddLiteralNotNone(grph, node_schema, "Expiry date", row[4])
Пример #4
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER = '" + oraSchema + "'"
    sys.stderr.write("sql_query=%s\n" % sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        tableName = str(row[0])
        # sys.stderr.write("tableName=%s\n" % tableName )
        nodeTable = oracle_table.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                         tableName)
        grph.add((node_oraschema, pc.property_oracle_table, nodeTable))

        lib_oracle.AddLiteralNotNone(grph, nodeTable, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, nodeTable, "Creation", row[2])

    # It cannot work if there are too many tables.
    # cgiEnv.OutCgiRdf("LAYOUT_RECT")
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_table])
Пример #5
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    ora_schema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TYPE' AND OWNER = '" + ora_schema + "'"
    logging.debug("sql_query=%s", sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, ora_schema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        type_name = str(row[0])
        node_type = oracle_type.MakeUri(cgiEnv.m_oraDatabase, ora_schema,
                                        type_name)
        grph.add((node_oraschema, pc.property_oracle_type, node_type))

        lib_oracle.AddLiteralNotNone(grph, node_type, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, node_type, "Creation", row[2])

    # Display in lines.
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_type])
Пример #6
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraPackage = cgiEnv.m_entity_id_dict["Package"]
    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    node_oraPackage = oracle_package.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                             oraPackage)

    node_oraSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema)
    grph.add((node_oraSchema, pc.property_oracle_package, node_oraPackage))

    # TODO: This is problematic as these could also be functions.
    # TODO: But when joining with ALL_OBJECTS, most rows are gone. So what to do ?
    sql_query = "select distinct procedure_name from all_procedures where object_type='PACKAGE' " \
       "and owner='" + oraSchema + "' and object_name='" + oraPackage + "'"
    DEBUG("sql_query=%s", sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    propProcToPackage = lib_common.MakeProp("Package")
    for row in result:
        procedureName = row[0]
        procedureNode = oracle_procedure.MakeUri(cgiEnv.m_oraDatabase,
                                                 oraSchema, procedureName)
        grph.add((node_oraPackage, propProcToPackage, procedureNode))

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE", [propProcToPackage])
Пример #7
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraTable = cgiEnv.m_entity_id_dict["Table"]
    oraSchema = cgiEnv.m_entity_id_dict["Schema"]
    oraDatabase = cgiEnv.m_entity_id_dict["Db"]

    grph = cgiEnv.GetGraph()

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY" etc...
    sql_query = "select owner,name,type from all_dependencies where REFERENCED_TYPE = 'TABLE' AND REFERENCED_NAME = '" + oraTable + "' and referenced_owner='" + oraSchema + "'"

    DEBUG("sql_query=%s", sql_query)

    node_oraTable = oracle_table.MakeUri(oraDatabase, oraSchema, oraTable)

    node_oraSchema = oracle_schema.MakeUri(oraDatabase, oraSchema)
    grph.add((node_oraSchema, pc.property_oracle_table, node_oraTable))

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        lib_oracle.AddDependency(grph, row, node_oraTable, oraDatabase, True)

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
Пример #8
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    ora_schema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'SEQUENCE' AND OWNER = '" + ora_schema + "'"
    logging.debug("sql_query=%s", sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, ora_schema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        sequence_name = str(row[0])
        node_sequence = oracle_sequence.MakeUri(cgiEnv.m_oraDatabase,
                                                ora_schema, sequence_name)
        grph.add((node_oraschema, pc.property_oracle_sequence, node_sequence))

        lib_oracle.AddLiteralNotNone(grph, node_sequence, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, node_sequence, "Creation", row[2])

    # "Collapsing", clustering nodes is needed if there are many objects.
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_sequence])
Пример #9
0
def AddInfo(grph, node, entity_ids_arr):
    # TODO: Ca serait quand meme mieux de passer au AddInfo un dict plutot qu un tableau.
    dbNam = entity_ids_arr[0]
    schemaNam = entity_ids_arr[1]
    nodeSchema = oracle_schema.MakeUri(dbNam, schemaNam)

    grph.add((nodeSchema, pc.property_oracle_table, node))
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    ora_schema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'PACKAGE BODY' AND OWNER = '" + ora_schema + "'"
    logging.debug("sql_query=%s", sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, ora_schema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)
    num_package_bodies = len(result)
    logging.debug("num_package_bodies=%d", num_package_bodies)

    for row in result:
        package_body_name = str(row[0])
        node_package_body = oracle_package_body.MakeUri(
            cgiEnv.m_oraDatabase, ora_schema, package_body_name)
        grph.add((node_oraschema, pc.property_oracle_package_body,
                  node_package_body))

        lib_oracle.AddLiteralNotNone(grph, node_package_body, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, node_package_body, "Creation",
                                     row[2])

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_package_body])
Пример #11
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraView = cgiEnv.m_entity_id_dict["View"]
    oraSchema = cgiEnv.m_entity_id_dict["Schema"]
    oraDatabase = cgiEnv.m_entity_id_dict["Db"]

    grph = cgiEnv.GetGraph()

    node_oraView = oracle_view.MakeUri(oraDatabase, oraSchema, oraView)

    node_oraSchema = oracle_schema.MakeUri(oraDatabase, oraSchema)
    grph.add((node_oraSchema, pc.property_oracle_view, node_oraView))

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY"
    sql_query = "select owner,name,type from all_dependencies where REFERENCED_TYPE = 'VIEW' AND REFERENCED_NAME = '" + oraView + "' and referenced_owner='" + oraSchema + "'"
    sys.stderr.write("sql_query=%s\n" % sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        lib_oracle.AddDependency(grph, row, node_oraView, oraDatabase, True)

    sql_query_inv = "select referenced_owner,referenced_name,referenced_type from all_dependencies where type='VIEW' and NAME = '" + oraView + "' and OWNER='" + oraSchema + "'"
    sys.stderr.write("sql_query_inv=%s\n" % sql_query_inv)
    result_inv = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query_inv)

    for row in result_inv:
        lib_oracle.AddDependency(grph, row, node_oraView, oraDatabase, False)

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
Пример #12
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraPackage = cgiEnv.m_entity_id_dict["Package"]
    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    node_oraPackage = oracle_package.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                             oraPackage)

    node_oraSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema)
    grph.add((node_oraSchema, pc.property_oracle_package, node_oraPackage))

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY"
    sql_query = "select owner,name,type from dba_dependencies where REFERENCED_TYPE = 'PACKAGE' AND REFERENCED_NAME = '"\
       + oraPackage + "' and referenced_owner='" + oraSchema + "'"
    DEBUG("sql_query=%s", sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        lib_oracle.AddDependency(grph, row, node_oraPackage,
                                 cgiEnv.m_oraDatabase, True)

    sql_query_inv = "select referenced_owner,referenced_name,referenced_type from dba_dependencies where type='PACKAGE' and NAME = '"\
        + oraPackage + "' and OWNER='" + oraSchema + "'"
    DEBUG("sql_query_inv=%s", sql_query_inv)
    result_inv = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query_inv)

    for row in result_inv:
        lib_oracle.AddDependency(grph, row, node_oraPackage,
                                 cgiEnv.m_oraDatabase, False)

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
Пример #13
0
def AddInfo(grph, node, entity_ids_arr):
    # TODO: SPECIAL. Imported here to avoid circular inclusions, see oracle/package_body/__init__.py
    from sources_types.oracle import schema as oracle_schema

    argDb = entity_ids_arr[0]
    argSchema = entity_ids_arr[1]

    node_oraschema = oracle_schema.MakeUri(argDb, argSchema)
    grph.add((node_oraschema, lib_common.MakeProp("Oracle synonym"), node))
Пример #14
0
def AddInfo(grph,node, entity_ids_arr):
    # TODO: SPECIAL. Imported here to avoid circular inclusions, see oracle/package_body/__init__.py
    from sources_types.oracle import schema as oracle_schema

    arg_db = entity_ids_arr[0]
    arg_schema = entity_ids_arr[1]

    node_oraschema = oracle_schema.MakeUri(arg_db, arg_schema)
    grph.add((node_oraschema, pc.property_oracle_function, node))
Пример #15
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()
    oraSession = cgiEnv.m_entity_id_dict["Session"]
    grph = cgiEnv.GetGraph()
    node_oraSession = oracle_session.MakeUri(cgiEnv.m_oraDatabase, oraSession)

    # TYPE = "VIEW", "TABLE", "PACKAGE BODY"
    sql_query = "select SID,STATUS,USERNAME,SERVER,SCHEMANAME,COMMAND,MACHINE,PORT,OSUSER,PROCESS,SERVICE_NAME,ACTION from V$SESSION where SID='%s'" % oraSession
    sys.stderr.write("sql_query=%s\n" % sql_query)
    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    # There should be only one.
    for row in result:
        sys.stderr.write("SID=%s\n" % row[0])

        grph.add((node_oraSession, lib_common.MakeProp("Status"),
                  lib_common.NodeLiteral(row[1])))
        grph.add((node_oraSession, lib_common.MakeProp("Username"),
                  lib_common.NodeLiteral(row[2])))
        grph.add((node_oraSession, lib_common.MakeProp("Server"),
                  lib_common.NodeLiteral(row[3])))

        # grph.add( ( node_oraSession, lib_common.MakeProp("Schema"), lib_common.NodeLiteral(row[4]) ) )
        nodeSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, str(row[4]))
        grph.add((node_oraSession, pc.property_oracle_schema, nodeSchema))

        grph.add((node_oraSession, lib_common.MakeProp("Command"),
                  lib_common.NodeLiteral(row[5])))

        # This returns an IP address from "WORKGROUP\RCHATEAU-HP"
        user_machine = lib_oracle.OraMachineToIp(row[6])
        nodeMachine = lib_common.gUriGen.HostnameUri(user_machine)
        grph.add((nodeMachine, pc.property_information,
                  lib_common.NodeLiteral(row[6])))

        grph.add((node_oraSession, lib_common.MakeProp("Port"),
                  lib_common.NodeLiteral(row[7])))
        grph.add((node_oraSession, lib_common.MakeProp("OsUser"),
                  lib_common.NodeLiteral(row[8])))
        # grph.add( ( node_oraSession, lib_common.MakeProp("Process"), lib_common.NodeLiteral(row[9]) ) )
        sessPidTid = row[9]  # 7120:4784
        sessPid = sessPidTid.split(":")[0]
        node_process = lib_common.RemoteBox(user_machine).PidUri(sessPid)
        grph.add((node_process, lib_common.MakeProp("Pid"),
                  lib_common.NodeLiteral(sessPid)))
        grph.add((node_oraSession, pc.property_oracle_session, node_process))

        grph.add(
            (node_oraSession, lib_common.MakeProp("Hostname"), nodeMachine))

        grph.add((node_oraSession, lib_common.MakeProp("ServiceName"),
                  lib_common.NodeLiteral(row[10])))
        grph.add((node_oraSession, lib_common.MakeProp("Action"),
                  lib_common.NodeLiteral(row[11])))

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
Пример #16
0
def AddInfo(grph, node, entity_ids_arr):
    arg_db = entity_ids_arr[0]
    arg_schema = entity_ids_arr[1]
    arg_package_body = entity_ids_arr[2]

    node_package = oracle_package.MakeUri(arg_db, arg_schema, arg_package_body)
    grph.add((node, lib_common.MakeProp("Associated package"), node_package))

    node_oraschema = oracle_schema.MakeUri(arg_db, arg_schema)
    grph.add((node_oraschema, pc.property_oracle_package, node))
Пример #17
0
def AddInfo(grph, node, entity_ids_arr):

    # TODO: SPECIAL. Imported here to avoid circular inclusions, see oracle/package_body/__init__.py
    from sources_types.oracle import schema as oracle_schema
    from sources_types.oracle import package_body as oracle_package_body

    argDb = entity_ids_arr[0]
    argSchema = entity_ids_arr[1]
    argPackage = entity_ids_arr[2]

    # TODO: PROBLEM, WHAT IF THE PACKAGE BODY DOES NOT EXIST ???
    nodePackageBody = oracle_package_body.MakeUri(argDb, argSchema, argPackage)
    grph.add((node, lib_common.MakeProp("Associated package body"),
              nodePackageBody))

    node_oraschema = oracle_schema.MakeUri(argDb, argSchema)
    grph.add((node_oraschema, pc.property_oracle_package, node))
Пример #18
0
def ListAllUsers(cgiEnv, node_oradb, grph):
    # SQL> desc all_users
    #  Name                                      Null?    Type
    #  ----------------------------------------- -------- ----------------------------
    #  USERNAME                                  NOT NULL VARCHAR2(30)
    #  USER_ID                                   NOT NULL NUMBER
    #  CREATED                                   NOT NULL DATE

    qryDbaUsers = "select username, user_id, created from all_users"
    result = lib_oracle.ExecuteQueryThrow(cgiEnv.ConnectStr(), qryDbaUsers)

    for row in result:
        DEBUG("row=" + str(row))
        nodeSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, str(row[0]))
        grph.add((node_oradb, pc.property_oracle_schema, nodeSchema))

        lib_oracle.AddLiteralNotNone(grph, nodeSchema, "Schema-id", row[1])
        lib_oracle.AddLiteralNotNone(grph, nodeSchema, "Created", row[2])
Пример #19
0
def Main():
	cgiEnv = lib_oracle.OracleEnv()

	oraSchema = cgiEnv.m_entity_id_dict["Schema"]

	grph = cgiEnv.GetGraph()

	sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'PROCEDURE' AND OWNER = '" + oraSchema + "'"
	DEBUG("sql_query=%s", sql_query )

	node_oraschema = oracle_schema.MakeUri( cgiEnv.m_oraDatabase, oraSchema )

	result = lib_oracle.ExecuteQuery( cgiEnv.ConnectStr(), sql_query)

	for row in result:
		procedureName = str(row[0])
		nodeProcedure = oracle_procedure.MakeUri( cgiEnv.m_oraDatabase , oraSchema, procedureName )
		grph.add( ( node_oraschema, pc.property_oracle_procedure, nodeProcedure ) )

		lib_oracle.AddLiteralNotNone(grph,nodeProcedure,"Status",row[1])
		lib_oracle.AddLiteralNotNone(grph,nodeProcedure,"Creation",row[2])

	cgiEnv.OutCgiRdf("LAYOUT_RECT",[pc.property_oracle_procedure])
Пример #20
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    oraSchema = cgiEnv.m_entity_id_dict["Schema"]

    grph = cgiEnv.GetGraph()

    sql_query = "SELECT OBJECT_NAME,STATUS,CREATED FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'FUNCTION' AND OWNER = '" + oraSchema + "'"
    sys.stderr.write("sql_query=%s\n" % sql_query)

    node_oraschema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase, oraSchema)

    result = lib_oracle.ExecuteQuery(cgiEnv.ConnectStr(), sql_query)

    for row in result:
        functionName = str(row[0])
        nodeFunction = oracle_function.MakeUri(cgiEnv.m_oraDatabase, oraSchema,
                                               functionName)
        grph.add((node_oraschema, pc.property_oracle_function, nodeFunction))

        lib_oracle.AddLiteralNotNone(grph, nodeFunction, "Status", row[1])
        lib_oracle.AddLiteralNotNone(grph, nodeFunction, "Creation", row[2])

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_oracle_function])
Пример #21
0
def AddInfo(grph, node, entity_ids_arr):
    db_nam = entity_ids_arr[0]
    schema_nam = entity_ids_arr[1]
    node_schema = oracle_schema.MakeUri(db_nam, schema_nam)

    grph.add((node_schema, pc.property_oracle_view, node))
Пример #22
0
def Main():
    cgiEnv = lib_oracle.OracleEnv()

    grph = cgiEnv.GetGraph()

    #v$process
    #PID	NUMBER	Oracle process identifier
    #SPID	VARCHAR2(12)	Operating system process identifier
    #USERNAME	VARCHAR2(15)	Operating system process username. Any two-task user coming across the network has "-T" appended to the username.
    #TERMINAL	VARCHAR2(30)	Operating system terminal identifier
    #PROGRAM	VARCHAR2(48)	Program in progress
    #
    #v$session
    #SID	NUMBER	Session identifier
    #USER#	NUMBER	Oracle user identifier
    #USERNAME	VARCHAR2(30)	Oracle username
    #COMMAND	NUMBER	Command in progress (last statement parsed); for a list of values, see Table 7-5. These values also appear in the AUDIT_ACTIONS table.
    #SCHEMA#	NUMBER	Schema user identifier
    #SCHEMANAME	VARCHAR2(30)	Schema user name
    #OSUSER	VARCHAR2(30)	Operating system client user name
    #PROCESS	VARCHAR2(12)	Operating system client process ID
    #MACHINE	VARCHAR2(64)	Operating system machine name
    #TERMINAL	VARCHAR2(30)	Operating system terminal name
    #PROGRAM	VARCHAR2(48)	Operating system program name

    sql_query = """
	SELECT distinct sess.sid, sess.username, sess.schemaname, proc.spid,pid,sess.osuser,sess.machine,sess.process,
	sess.port,proc.terminal,sess.program,proc.tracefile
	  FROM v$session sess,
		   v$process proc
	 WHERE sess.type     = 'USER'
	   and sess.paddr = proc.addr
	"""

    node_oradb = oracle_db.MakeUri(cgiEnv.m_oraDatabase)

    try:
        result = lib_oracle.ExecuteQueryThrow(cgiEnv.ConnectStr(), sql_query)
    except:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("ExecuteQuery exception:%s in %s" %
                                    (str(exc), sql_query))

    for row in result:
        if row[0] == None:
            continue
        # print("\nUser="******"WORKGROUP\RCHATEAU-HP"
        user_machine = lib_oracle.OraMachineToIp(row[6])
        theMachineBox = lib_common.MachineBox(user_machine)

        # Process and Thread id of the CLIENT program, executing sqlplus.exe for example.
        sessPidTid = row[7]  # 7120:4784
        sessPid = sessPidTid.split(":")[0]
        procTerminal = row[9]
        sessProgram = row[10]

        nodeSession = oracle_session.MakeUri(cgiEnv.m_oraDatabase, str(row[0]))
        grph.add((nodeSession, lib_common.MakeProp("Oracle user"),
                  lib_common.NodeLiteral(oraUsername)))
        grph.add((nodeSession, lib_common.MakeProp("Schema"),
                  lib_common.NodeLiteral(schemaName)))
        grph.add((nodeSession, lib_common.MakeProp("Program"),
                  lib_common.NodeLiteral(sessProgram)))

        if schemaName != None:
            nodeSchema = oracle_schema.MakeUri(cgiEnv.m_oraDatabase,
                                               str(schemaName))
            grph.add((nodeSession, pc.property_oracle_schema, nodeSchema))
            grph.add((node_oradb, pc.property_oracle_db, nodeSchema))

        sys.stderr.write("user_proc_id=%s user_machine=%s\n" %
                         (user_proc_id, user_machine))
        # node_process = lib_common.RemoteBox(user_machine).PidUri( sessPid )
        node_process = theMachineBox.PidUri(sessPid)
        grph.add((node_process, lib_common.MakeProp("SystemPid"),
                  lib_common.NodeLiteral(user_proc_id)))
        grph.add((node_process, lib_common.MakeProp("OraclePid"),
                  lib_common.NodeLiteral(process_pid)))
        grph.add((node_process, lib_common.MakeProp("Terminal"),
                  lib_common.NodeLiteral(procTerminal)))
        grph.add((nodeSession, pc.property_oracle_session, node_process))

        if sessOsuser != None:
            sys.stderr.write("user_machine=%s sessOsuser=%s\n" %
                             (user_machine, sessOsuser))
            nodeOsUser = theMachineBox.UserUri(sessOsuser)
            grph.add((nodeOsUser, lib_common.MakeProp("OsUser"),
                      lib_common.NodeLiteral(sessOsuser)))
            grph.add((node_process, pc.property_user, nodeOsUser))

    cgiEnv.OutCgiRdf()