8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

EMCLI : Manage Agents using Enterprise Manager Command Line Interface (Cloud Control)

The Enterprise Manager Command Line Interface (EMCLI) allows you to script your Cloud Control setup, rather than using the Cloud Control console. This article describes how to manage agents in Cloud Control using EMCLI, rather than using the web interface.

For more information see:

Setup

You can perform these actions from anywhere with an EMCLI client, but for this example we're going to use the EMCLI client on the Cloud Control server. We use the following commands to connect to the OMS and sync the EMCLI client.

unset SSH_ASKPASS
export OMS_HOME=/u01/app/oracle/middleware
export AGENT_HOME=/u01/app/oracle/agent/agent_inst
alias emcli='${OMS_HOME}/bin/emcli'

emcli login -username=sysman
emcli sync

Add Agent

Make sure the AGENT_BASE_DIR directory is present on the AGENT_HOST server before attempting to push an agent to it. Use the submit_add_host verb to push the agent to the server to be monitored.

AGENT_HOST="my-host.localdomain"
AGENT_HOST_CREDENTIAL="NC_HOST_MY_HOST"
AGENT_PORT="3872"
AGENT_BASE_DIR="/u01/app/oracle/product/agent13c"
AGENT_PLATFORM="226"

emcli submit_add_host \
  -host_names="${AGENT_HOST}" \
  -platform="${AGENT_PLATFORM}" \
  -installation_base_directory="${AGENT_BASE_DIR}" \
  -credential_name="${AGENT_HOST_CREDENTIAL}" \
  -port="${AGENT_PORT}" \
  -wait_for_completion

Run the "root.sh" file on the monitored server. For example.

/u01/app/oracle/product/agent13c/agent_13.3.0.0.0/root.sh

You need to know "Platform ID" of the destination server. The available IDs can be listed using the list_add_host_platforms verb.

emcli list_add_host_platforms -all
Platform ID  Platform Name
226          Linux x86-64
197          HP-UX Itanium
...

After adding the agent, you should set the preferred credentials, as described here.

Remove Agent

You can only remove an agent if it is stopped, so you may want to issue a stop command before attempting to remove the agent. The following example uses the stop_agent and delete_target verbs to achieve this.

AGENT_HOST="my-host.localdomain"
AGENT_HOST_CREDENTIAL="NC_HOST_MY_HOST"
AGENT_PORT="3872"

emcli stop_agent \
  -agent_name="${AGENT_HOST}:${AGENT_PORT}" \
  -credential_name="${AGENT_HOST_CREDENTIAL}"
 
emcli delete_target \
  -name="${AGENT_HOST}:${AGENT_PORT}" \
  -type="oracle_emd" \
  -delete_monitored_targets \
  -async

Remember to delete the contents of the AGENT_BASE_DIR on the host.

Upgrade Agent

You can create an upgrade job for an existing agent using the upgrade_agents verb. The following example assumes the preferred credential are set for the host the agent is running on. You can read how to do that here.

AGENT_HOST="my-host.localdomain"
AGENT_PORT="3872"
UPGRADE_JOB_NAME="UPG_MY_HOST_AGENT_1"

emcli upgrade_agents \
  -agents="${AGENT_HOST}:${AGENT_PORT}"\
  -job_name="${UPGRADE_JOB_NAME}"

Once the job is created it will tell you how to monitor the job in cloud control. Alternatively you can monitor it using the get_agent_upgrade_status verb, as shown below.

emcli get_agent_upgrade_status -job_name="${UPGRADE_JOB_NAME}"

If the preferred credential doesn't have sudo access, you will have to run the "root.sh" file on the monitored server. For example.

/u01/app/oracle/product/agent13c/agent_13.3.0.0.0/root.sh

Help

The usage of the commands referenced in this article can displayed using the following commands.

emcli help list_add_host_platforms
emcli help submit_add_host
emcli help stop_agent
emcli help delete_target
emcli help upgrade_agents

You can also check out all the other agent verbs in the Help Command Output.

emcli help

For more information see:

Hope this helps. Regards Tim...

Back to the Top.