Oracle Enterprise Manager Audit

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0

Why you should read this blog post? You need to take care of the Audit function from OEM CC even if you don’t want to use it. It’s enabled by default and needs to be managed!

Housekeeping for audit

Per default the audit function of oem is configured with very basic audit rules but as example every login or logout creates an audit record inside the database. The audit table is configured quite well as it’s daily range partitioned. But an overhead is always there and the space consumption was more then 10% of the whole sysman schema. Cloud Control has a very conventional way to manage audit settings… emcli. The default configuration looks like:

emcli show_audit_settings
User Activity Audit : Disabled (11 out of 171 operations)
Externalization Switch : Disabled
Directory :
File Prefix : em_audit
File Size : 5000000 Bytes
Data Retention Period : 365 Days
*Infrastructure Audit is always enabled

Before going more in details for the configuration, I’ll summarize the solution provided by Oracle. In the documentation it’s only rarely described the way it works, but the concept can be found there. The OEM writes the audit to a table inside the sysman schema and if configured well it will be unloaded to a database directory in xml format. This happens daily managed by a database job. I will go into more detail below. The view described in the documentation is called SYSMAN.MGMT$AUDIT_LOG. Underlying you find the tables SYSMAN.MGMT_AUDIT_LOGS_E and SYSMAN.MGMT_OPERATIONS_MASTER. I expect it’s called SYSMAN.MGMT_AUDIT_LOGS in versions before 13. I’m sorry but I don’t have a test environment older 13.2 available. To check the oldest entry:


You can and should keep some days available in OEM, but the other audit records should be removed. To have this done automatically each night you can use the export function of OEM. To prepare the export you need to create a directory and grant permissions to sysman:

create directory audit as '/audit';
grant read,write on directory audit to sysman ;

And dont’t forget to create the directory also on the filesystem:

mkdir /audit

To enable the daily export and keep the last 7 days inside the database run the following command on the OMS server or every other emcli installation you have.

emcli update_audit_settings -directory="AUDIT" -data_retention_period="7" -externalization_switch="ENABLE"

If the default size of 5M per file is to small for you, it’s possible to adjust also this parameter with the option -file_size=”50000000″. The value is in Bytes. Now it’s done. But I won’t wait until tomorrow and check if everything is working. So I was searching for the way it’s done. Until here everything is well described in the documentation. The Job, which exports all audit records is named EM_AUDIT_EXT_SCHED_JOB and independent from the file_size parameter the records are separated per day even if the size is not reached.


PL/SQL procedure successfully completed.

Elapsed: 00:00:00.02

If you list the directory now you find a lot of files, with the naming schema: _YYYY-MM-DD_xxxxx.xml where xxxxx is an increasing number starting with 00001.
The table is still the same size and the audit records are still in the table.
Did we configure something wrong? … NO! There is a second job managing the cleanup and the partitioning: EM_DAILY_MAINTENANCE.


After this job execution everything is fine, partitions are deleted and space is freed. At the end I want to give you an example how such an audit record looks like.

 Logged on successfully

Please don’t forget also the housekeeping for the xml files in the database directory. For example with a cron entry:

22 00 * * 0 find /audit -mtime +365 -type f -name "em_audit_????-??-??_?????.xml" -exec rm {} \; 2>&1 1>/dev/null

Add audit policies

If you want to change the audit policies what is audited, you can run

emcli update_audit_settings -operations_to_enable="XXX"
emcli update_audit_settings -operations_to_disable="XXX"

Which policies are existing, can be listed with: emcli show_operations_list This command lists all the 171 audit policies.
Be careful: The policy name can include spaces 😉
Finally I want to describe, how to check the audit data with the browser. Navigate to Setup –> Security –> Audit Data.

Leave a Reply

Your email address will not be published. Required fields are marked *