ODC Appreciation Day : EM CLI

When I first started as a DBA two years ago, the colleague in charge of my training thought that I would rather use several GUIs to complete most of the tasks. He said it was because of my age … But he quickly found out that I was more comfortable with CLIs.

For this very first blog post, I would like to participate in the ODC Appreciation Day and talk about a tool I really recommend : EM CLI.

In my organization, most of database tasks are fully automated with scripts based on CLI. And with EM CLI, this means I don’t have to worry about clicking in Enterprise Manager Cloud Control 12c to create or delete blackouts, or even to modify a target property, if needed.
As explained in the official documentation “EM CLI enables you to access Enterprise Manager Cloud Control functionality from text-based consoles (shells and command-line windows) for a variety of operating systems.
EM CLI is fully integrated with Enterprise Manager’s security and user administration functions, enabling you to carry out operations using EM CLI with the same security and confidentiality as the Enterprise Manager Cloud Control console.”

In this quick article, I would just like to show some of my favourites EM CLI commands.

First of all, I can easily retrieve the status of all targets that are managed :
# emcli get_targets

I can also retrieve the status of a specific target, for example an Oracle database, by specifying the name and type of the target :
# emcli get_targets -targets="mydb:oracle_database"

After an upgrade with Oracle Home change, I can change this property on a target :
# emcli modify_target -type="oracle_database" -name="mydb" -properties="OracleHome:/u01/app/oracle/product/"

But to me, the most useful commands are those concerning blackouts.

I can create a blackout on a database for an indefinite period of time (option “duration:-1”) on a specified timezone (option “tzinfo:specified;tzregion:Europe/Zurich”) :
# emcli create_blackout -name="mydb_blackout" -add_targets="mydb:oracle_database" -reason="DB: Database Patch/Maintenance" -schedule="duration:-1;tzinfo:specified;tzregion:Europe/Zurich"

I can do the same for a full host and I really like the “-propagate_targets” option that allows to apply the blackout to all targets on this host :

# emcli create_blackout -name="myserver_blackout" -add_targets="myserver:host" -reason="OS Configuration Change" -schedule="duration:-1;tzinfo:specified;tzregion:Europe/Zurich" -propagate_targets

And of course I can stop and delete those blackouts :
# emcli delete_blackout -name="mydb_blackout"
# emcli stop_blackout -name="mydb_blackout"

Finally, I always struggle to remember the different types of targets or blackout reasons, so I use the following commands :
# emcli get_target_types
# emcli get_blackout_reasons

I hope you can take advantage of these tips !

3 thoughts on “ODC Appreciation Day : EM CLI

  1. Pingback: Thanks ODC, Oracle WIT Edition #ThanksODC - DBA Kevlar

  2. Pingback: OGB Appreciation Day : SQLcl – Floo Bar

  3. Pingback: OGB Appreciation Day : SQLcl | Floo Bar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s