Skip to main content

AUDIT in ORACLE 10g




Auditing is disabled by default, but can enable by setting the AUDIT_TRAIL static parameter, which has the following allowed values.

AUDIT_TRAIL = { none | os | db | db_extended | xml | xml_extended }

The following list provides a description of each setting:

none or false - Auditing is disabled.
db or true - Auditing is enabled, with all audit records stored in the database audit trial (SYS.AUD$).
db_extended - As db, but the SQL_BIND and SQL_TEXT columns are also populated.
xml- Auditing is enabled, with all audit records stored as XML format OS files.
Xml_extended - As xml, but the SQL_BIND and SQL_TEXT columns are also populated.
os- Auditing is enabled, with all audit records directed to the operating system's audit trail.


The AUDIT_SYS_OPERATIONS static parameter enables or disables the auditing of operations issued by users connecting with SYSDBA or SYSOPER privileges, including the SYS user. All audit records are written to the OS audit trail.

The AUDIT_FILE_DEST parameter specifies the OS directory used for the audit trail when the os, xml and xml,extended options are used. It is also the location for all mandatory auditing specified by the AUDIT_SYS_OPERATIONS parameter.



SQL> ALTER SYSTEM SET audit_trail=db_extended SCOPE=SPFILE;


SQL> AUDIT INSERT, UPDATE, DELETE ON ultimus.temp_tab BY ACCESS;

(Note: setting BY ACCESS you tell oracle to audit statement by statement where by SESSION provides info as bundle)

Next we audit all operations by the AUDIT_TEST user.

CONNECT sys/password AS SYSDBA

AUDIT ALL BY audit_test BY ACCESS;
AUDIT SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE BY audit_test BY ACCESS;
AUDIT EXECUTE PROCEDURE BY audit_test BY ACCESS;



The audit trail is stored in the SYS.AUD$ table. Its contents can be viewed directly or via the following views.

SELECT view_name
FROM   dba_views
WHERE  view_name LIKE 'DBA%AUDIT%'
ORDER BY view_name;

VIEW_NAME
------------------------------
DBA_AUDIT_EXISTS
DBA_AUDIT_OBJECT
DBA_AUDIT_POLICIES
DBA_AUDIT_POLICY_COLUMNS
DBA_AUDIT_SESSION
DBA_AUDIT_STATEMENT
DBA_AUDIT_TRAIL
DBA_COMMON_AUDIT_TRAIL
DBA_FGA_AUDIT_TRAIL
DBA_OBJ_AUDIT_OPTS
DBA_PRIV_AUDIT_OPTS
DBA_REPAUDIT_ATTRIBUTE
DBA_REPAUDIT_COLUMN
DBA_STMT_AUDIT_OPTS

14 rows selected.

DBA_AUDIT_TRAIL - Standard auditing only (from AUD$).
DBA_FGA_AUDIT_TRAIL - Fine-grained auditing only (from FGA_LOG$).
DBA_COMMON_AUDIT_TRAIL - Both standard and fine-grained auditing.
The most basic view of the database audit trail is provided by the DBA_AUDIT_TRAIL view, which contains a wide variety of information. The following query displays the some of the information from the database audit trail.

COLUMN username FORMAT A10
COLUMN owner    FORMAT A10
COLUMN obj_name FORMAT A10
COLUMN extended_timestamp FORMAT A35

SELECT username,
       extended_timestamp,
       owner,
       obj_name,
       action_name
FROM   dba_audit_trail
WHERE  owner = 'AUDIT_TEST'
ORDER BY timestamp;


The following query lists audit records generated by statement and object audit options:

SQL> SELECT * FROM DBA_AUDIT_OBJECT where obj_name='TEMP_TAB';

To turn audit option off, issue the following command:
SQL> NOAUDIT INSERT, UPDATE, DELETE ON ultimus.temp_tab BY ACCESS;





We can also query the dba_audit_trail view.  Here are the column descriptions from the Oracle documentation:


ColumnDatatypeNULLDescription
OS_USERNAMEVARCHAR2(255)Operating system login username of the user whose actions were audited
USERNAMEVARCHAR2(30)Name (not ID number) of the user whose actions were audited
USERHOSTVARCHAR2(128)Client host machine name
TERMINALVARCHAR2(255)Identifier of the user's terminal
TIMESTAMPDATEDate and time of the creation of the audit trail entry (date and time of user login for entries created by AUDIT SESSION) in the local database session time zone
OWNERVARCHAR2(30)Creator of the object affected by the action
OBJ_NAMEVARCHAR2(128)Name of the object affected by the action
ACTIONNUMBERNOT NULLNumeric action type code. The corresponding name of the action type is in theACTION_NAME column.
ACTION_NAMEVARCHAR2(28)Name of the action type corresponding to the numeric code in the ACTIONcolumn
NEW_OWNERVARCHAR2(30)Owner of the object named in the NEW_NAME column
NEW_NAMEVARCHAR2(128)New name of the object after a RENAME or the name of the underlying object
OBJ_PRIVILEGEVARCHAR2(16)Object privileges granted or revoked by a GRANT or REVOKE statement
SYS_PRIVILEGEVARCHAR2(40)System privileges granted or revoked by a GRANT or REVOKE statement
ADMIN_OPTIONVARCHAR2(1)Indicates whether the role or system privilege was granted with the ADMINoption
GRANTEEVARCHAR2(30)Name of the grantee specified in a GRANT or REVOKE statement
AUDIT_OPTIONVARCHAR2(40)Auditing option set with the AUDIT statement
SES_ACTIONSVARCHAR2(19)Session summary (a string of 16 characters, one for each action type in the order ALTERAUDITCOMMENTDELETEGRANTINDEXINSERTLOCK,RENAMESELECTUPDATEREFERENCES, and EXECUTE. Positions 14, 15, and 16 are reserved for future use. The characters are:
  • - - None
  • S - Success
  • F - Failure
  • B - Both
LOGOFF_TIMEDATEDate and time of user log off
LOGOFF_LREADNUMBERLogical reads for the session
LOGOFF_PREADNUMBERPhysical reads for the session
LOGOFF_LWRITENUMBERLogical writes for the session
LOGOFF_DLOCKVARCHAR2(40)Deadlocks detected during the session
COMMENT_TEXTVARCHAR2(4000)Text comment on the audit trail entry, providing more information about the statement auditedAlso indicates how the user was authenticated. The method can be one of the following:
  • DATABASE - Authentication was done by password
  • NETWORK - Authentication was done by Oracle Net Services or the Advanced Security option
  • PROXY - Client was authenticated by another user; the name of the proxy user follows the method type
SESSIONIDNUMBERNOT NULLNumeric ID for each Oracle session
ENTRYIDNUMBERNOT NULLNumeric ID for each audit trail entry in the session
STATEMENTIDNUMBERNOT NULLNumeric ID for each statement run
RETURNCODENUMBERNOT NULLOracle error code generated by the action. Some useful values:
  • 0 - Action succeeded
  • 2004 - Security violation
PRIV_USEDVARCHAR2(40)System privilege used to execute the action
CLIENT_IDVARCHAR2(64)Client identifier in each Oracle session
SESSION_CPUNUMBERAmount of CPU time used by each Oracle session
EXTENDED_TIMESTAMPTIMESTAMP(6) WITH TIME ZONETimestamp of the creation of the audit trail entry (timestamp of user login for entries created by AUDIT SESSION) in UTC (Coordinated Universal Time) time zone
PROXY_SESSIONIDNUMBERProxy session serial number, if an enterprise user has logged in through the proxy mechanism
GLOBAL_UIDVARCHAR2(32)Global user identifier for the user, if the user has logged in as an enterprise user
INSTANCE_NUMBERNUMBERInstance number as specified by the INSTANCE_NUMBER initialization parameter
OS_PROCESSVARCHAR2(16)Operating System process identifier of the Oracle process
TRANSACTIONIDRAW(8)Transaction identifier of the transaction in which the object is accessed or modified
SCNNUMBERSystem change number (SCN) of the query
SQL_BINDNVARCHAR2(2000)Bind variable data of the query
SQL_TEXTNVARCHAR2(2000)SQL text of the query


This query by Arup Nanda, co-author of "Oracle Privacy Security Auditing", shows a sample query against dba_audit_trail for standard Oracle auditing.


select 'standard audit', sessionid,
    proxy_sessionid, statementid, entryid, extended_timestamp, global_uid,
    username, client_id, null, os_username, userhost, os_process, terminal,
    instance_number, owner, obj_name, null, new_owner,
    new_name, action, action_name, audit_option, transactionid, returncode,
    scn, comment_text, sql_bind, sql_text,
    obj_privilege, sys_privilege, admin_option, grantee, priv_used,
    ses_actions, logoff_time, logoff_lread, logoff_pread, logoff_lwrite,
    logoff_dlock, session_cpu
  from 
  dba_audit_trail;


-------------------------------------------------------------------------------------------
tHANKS fOR rEADING tHIS aRTICLE.










Comments

Popular posts from this blog

ORACLE FLASH RECOVERY AREA USAGE QUERY

FINDING ORACLE FLASH RECOVERY AREA USAGE SELECT NAME,        (SPACE_LIMIT / 1024 / 1024 / 1024) SPACE_LIMIT_GB,          ((SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE) / 1024 / 1024 / 1024) AS SPACE_AVAILABLE_GB,        ROUND((SPACE_USED - SPACE_RECLAIMABLE) / SPACE_LIMIT * 100, 1) AS PERCENT_FULL   FROM V$RECOVERY_FILE_DEST;

Shared Pool Tuning: Cursor Tuning (Tuning Open_Cursors, Session_Cached_Cursors, Cursor_Space_For_Time)

Shared Pool Tuning: Cursor Tuning The three most important parameter for shared pool tuning are OPEN_CURSORS , SESSION_CACHED_CURSORS and CURSOR_SPACE_FOR_TIME. But most of the time we see that these two parameters SESSION_CACHED_CURSORS and CURSOR_SPACE_FOR_TIME are ignored or unused . OPEN CURSORS Open cursors take up space in the shared pool, in the library cache. OPEN_CURSORS sets the maximum number of cursors each session can have open, per session. For example, if OPEN_CURSORS is set to 1000, then each session can have up to 1000 cursors open at one time. V$open_cursor shows cached cursors, not currently open cursors, by session. If you’re wondering how many cursors a session has open, don’t look in v$open_cursor. It shows the cursors in the session cursor cache for each session, not cursors that are actually open.  To monitor open cursors, query v$sesstat where name= ’opened cursors current’ . This will give the number of currently opened cursors, by session:

How to delete/remove Management Agent from Oracle Enterprise Manager 12C

  1. Before you deinstall a Management Agent, do the following:     a. Stop the Agent using command from Management Agent home:                 cd /u01/oemcc_latest/core/12.1.0.2.0/bin/                 $ emctl stop agent     b. Wait for the Management Agent to go to the unreachable state in the Cloud Control console.     c. It is mandatory to delete the Management Agent and their monitored targets using any of the following methods: Remove the Agent target manually from the console: 1. Login to 12C Cloud Control 2. Navigate to Setup => Manage Cloud Control => Agents 3. Go to the Home page of the Agent that you want to remove 4. Expand the drop-down menu near the " Agent " 5. Expand the " Target Setup " option 6. Select " Remove Target "            In Cloud Control Release 12.1.0.2, the following dialog box will be displayed if the Agent is still monitoring targets. Click Continue. You can then remove all targets (usin