My Oracle Support Banner

EM 12c, EM 13c: How to Create an emcli Script to Add Databases Based on the Targets Found in Auto Discovery Results in Enterprise Manager 12c and 13c Cloud Control (Doc ID 1543773.1)

Last updated on OCTOBER 05, 2020

Applies to:

Enterprise Manager for Oracle Database - Version and later
Information in this document applies to any platform.


Up to Enterprise Manager Cloud Control Release, there is no method of 'mass promotion' in Enterprise Manager 12c Cloud Control.  This means that if lots of databases are discovered on a particular node, it is necessary to go into auto discovery results, and promote each database individually.  This can be time consuming, and there is an internal Enhancement Request raised on this.

Beginning with Cloud Control and higher, you can mass promote database by selecting the option "Specify Common Monitoring Credential" from the page" Promote Database Discovered Targets". Then you can select 'all' or a set of discovered databases to be promoted in one operation.  

If you cannot upgrade to, the fastest way to promote a database would be to use the emcli add target command.  However, the user would have to manually create the script to add the database targets in the first place.  The script requires details such as hostname, port, sid,oracle_home of the database.

The goal of this document is to provide a quick way of creating the emcli add target script.   The relevant details of the databases which have been discovered in auto discovery results will be used to create the emcli script.  In this example the dbsnmp password will be hardcoded into the script as 'dbsnmp'.   It can be changed appropriately once the script has been created

New Update:

In addition to the method outlined in this article, Oracle now provides an example script '' which is documented in the Enterprise Manager Command Line Interface (emcli) guide, which is also able to promote the un-managed databases.  See:

for more information on this.  Please note that this only applies to the single instance database target and not to cluster databases or listeners.



To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document
 1) Perform "run discovery now" on the machine which hosts the databases which need to be added to Enterprise Manager Cloud Control. 
 2) Once the 'run discovery now' has finished, check the auto discovery results
 3) Connect to the repository database as the sysman user at sqlplus and run the following query
 4) Copy the results into a text script
 5) Call the script from emcli
 6) Query the databases in the console.
 7)  SQL to retrieve the listener information
 8) Check the output:
 9) View the listeners in the console
 10) SQL for additional target types
 a) SQL to add an ASM target
 b) SQL to add a Cluster Target
 c) SQL to add a cluster database (rac) database target.  
 d) Sql to add a cluster ASM target
 11) An Example script is attached here

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.