Enterprise Manager EMCLI

emcli is the Enterprise Manager Command Line Interface

emcli is located in the $OMS_HOME/bin directory. For these examples:

OMS_HOME=/usr/oracle/EM/middleware/oms

Help

For a summary of available options

$OMS_HOME/bin/emcli help

For help on a specific topic e.g. get_targets:

$OMS_HOME/bin/emcli help get_targets

Log In To OMS

To login to EM Management Server (OMS) as SYSMAN use:

$OMS_HOME/bin/emcli -login -username=SYSMAN
Enter password <password>

Login successful

Using the above syntax EMCLI will prompt for a password

Alternatively:

$OMS_HOME/bin/emcli -login -username=SYSMAN -password=PASSWORD1
Enter password <password>

Login successful

The above command is less secure because the password may be stored in the shell history

Logout from OMS

To logout from the EM Management Server (OMS) use:

$OMS_HOME/bin/emcli -logout

Synchronize with OMS

To synchronize with the EM Management Server

$OMS_HOME/bin/emcli sync

If called without arguments emcli is synchronized with the OMS that was specified in a previous emcli setup call

If called with arguments target OMS and username can be specified

EMCLI Status

To list EMCLI configuration details:

$OMS_HOME/bin/emcli status 

Example output:

Oracle Enterprise Manager 12c Release 4 EM CLI

Instance Home          : /usr/oracle/EM/gc_inst/em/EMGC_OMS1/sysman/emcli/setup/.emcli
Verb Jars Home         : /usr/oracle/EM/middleware/oms/bin/./bindings/12.1.0.4.0/.emcli
Status                 : Configured
EM CLI Home            : /usr/oracle/EM/middleware/oms/bin
EM CLI Version         : 12.1.0.4.0
Java Home              : /usr/oracle/EM/middleware/jdk16/jdk/jre
Java Version           : 1.6.0_43
Log file               : /usr/oracle/EM/gc_inst/em/EMGC_OMS1/sysman/emcli/setup/.emcli/.emcli.log
EM URL                 : https://server1.juliandyke.com:7802/em
EM user                : SYSMAN
Auto login             : false
Trust all certificates : true

EMCLI Verson

To determine the current version of EMCLI:

$OMS_HOME/bin/emcli version 

Example output:

Oracle Enterprise Manager 12c EM CLI Version 12.1.0.4.0

EMCLI Supported Platforms

To list currently configured platforms use:

$OMS_HOME/bin/emcli get_supported_platforms 

Example output:

-----------------------------------------------
Version = 12.1.0.4.0
Platform = Linux x86-64
-----------------------------------------------
Platforms list displayed successfully.

To list all supported platforms use:

[oracle@server1]$ $OMS_HOME/bin/emcli list_add_host_platforms -all 
Platform ID  Platform Name
226          Linux x86-64
23           Oracle Solaris on SPARC (64-bit) [Agent Software Unavailable]
46           Linux x86 [Agent Software Unavailable]
59           HP-UX PA-RISC (64-bit) [Agent Software Unavailable]
197          HP-UX Itanium [Agent Software Unavailable]
211          IBM S/390 Based Linux (31-bit) [Agent Software Unavailable]
212          IBM AIX on POWER Systems (64-bit) [Agent Software Unavailable]
227          IBM: Linux on POWER Systems [Agent Software Unavailable]
233          Microsoft Windows x64 (64-bit) [Agent Software Unavailable]
267          Oracle Solaris on x86-64 (64-bit) [Agent Software Unavailable]
912          Microsoft Windows (32-bit) [Agent Software Unavailable]
209          IBM: Linux on System z [Agent Software Unavailable]

Listing Targets

To list targets use:

$OMS_HOME/bin/emcli get_targets

For the extended syntax see:

$OMS_HOME/bin/emcli help get_targets

Examples

To list all hosts:

$OMS_HOME/bin/emcli get_targets -targets=host -format=name:csv
Status ID,Status,Target Type,Target Name
1,Up,host,server1.juliandyke.com
1,Up,host,server2.juliandyke.com
1,Up,host,server3.juliandyke.com

To list all databases:

$OMS_HOME/bin/emcli get_targets -targets=oracle_database -format=name:csv
 ID,Status,Target Type,Target Name
0,Down,oracle_database,DB1P
1,Up,oracle_database,DB2P
0,Down,oracle_database,DB1T
1,Up,oracle_database,DB2T
1,Up,oracle_database,DB3T

Deleting Targets

When deleting targets both the target name and target type must be specified

For example to delete a database:

$OMS_HOME/bin/emcli delete_target -name="DB3T" -type="oracle_database"
Target "DB3T:oracle_database" deleted successfully

Active Sessions

For a summary of active OMS sessions use:

$OMS_HOME/bin/emcli list_active_sessions

For example:

$OMS_HOME/bin/emcli list_active_sessions

OMS                                       Sessions
server1:4889_Management_Service    15

For a detailed list of active OMS sessions use:

$OMS_HOME/bin/emcli list_active_sessions -details

For example:

$OMS_HOME/bin/emcli list_active_sessions -details

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@client2
Session: 18164BB3D3EC11FBE0530C9AC90A4D4F
Login Time: 2015-06-09 14:22:50.927492

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3EF11FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:06:57.871877

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3F111FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:07:31.824997

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3F311FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:21:57.209992

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3F511FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:22:28.80007

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3F711FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:31:07.778916

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3F911FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:31:40.956878

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3FB11FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:37:27.242279

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3FD11FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:37:59.554329

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D3FF11FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:45:56.102636

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server4
Session: 18164BB3D40111FBE0530C9AC90A4D4F
Login Time: 2015-06-09 15:46:27.682465

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server2
Session: 18213BB79D7B47D2E0530C9AC90A58A5
Login Time: 2015-06-10 14:52:17.125739

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@server2
Session: 18213BB79D7D47D2E0530C9AC90A58A5
Login Time: 2015-06-10 14:52:51.343261

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: EMCLI@server1
Session: 182DC9ADE84206D2E0530C9AC90AC2C4
Login Time: 2015-06-10 17:58:44.801507

OMS Name: server1:4889_Management_Service
Administrator: SYSMAN
Logged in from: Browser@client1
Session: 183F7D0EBC7F36E7E0530C9AC90AEEE4
Login Time: 2015-06-11 17:53:38.378172

The above example shows details of the 15 SYSMAN sessions active in the OMS at the time the command was executed.

Details can also be listed in tabular format using:

$OMS_HOME/bin/emcli list_active_sessions -details -table

For example:

$OMS_HOME/bin/emcli list_active_sessions -details -table

OMS Name        Administrator   Logged in from  Session         Login Time
server1:4889_M  SYSMAN          Browser@client  18164BB3D3EC11  2015-06-09 14:
anagement_Serv                  1               FBE0530C9AC90A  22:50.927492
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3EF11  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  06:57.871877
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3F111  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  07:31.824997
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3F311  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  21:57.209992
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3F511  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  22:28.80007
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3F711  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  31:07.778916
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3F911  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  31:40.956878
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3FB11  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  37:27.242279
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3FD11  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  37:59.554329
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D3FF11  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  45:56.102636
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18164BB3D40111  2015-06-09 15:
anagement_Serv                  4               FBE0530C9AC90A  46:27.682465
ice                                             4D4F
server1:4889_M  SYSMAN          Browser@server  18213BB79D7B47  2015-06-10 14:
anagement_Serv                  2               D2E0530C9AC90A  52:17.125739
ice                                             58A5
server1:4889_M  SYSMAN          Browser@server  18213BB79D7D47  2015-06-10 14:
anagement_Serv                  2               D2E0530C9AC90A  52:51.343261
ice                                             58A5
server1:4889_M  SYSMAN          EMCLI@server1   182DC9ADE84206  2015-06-10 17:
anagement_Serv                                  D2E0530C9AC90A  58:44.801507
ice                                             C2C4
server1:4889_M  SYSMAN          Browser@client  183F7D0EBC7F36  2015-06-11 17:
anagement_Serv                  2               E7E0530C9AC90A  53:38.378172
ice                                             EEE4

An alternative format can be generated using the -script option:

$OMS_HOME/bin/emcli list_active_sessions -details -table -script
OMS Name        Administrator   Logged in from  Session Login Time
server1:4889_Management_Service  SYSMAN  Browser@client1  18164BB3D3EC11FBE0530C9AC90A4D4F   2015-06-09 14:22:50.927492
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3EF11FBE0530C9AC90A4D4F   2015-06-09 15:06:57.871877
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3F111FBE0530C9AC90A4D4F   2015-06-09 15:07:31.824997
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3F311FBE0530C9AC90A4D4F   2015-06-09 15:21:57.209992
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3F511FBE0530C9AC90A4D4F   2015-06-09 15:22:28.80007
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3F711FBE0530C9AC90A4D4F   2015-06-09 15:31:07.778916
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3F911FBE0530C9AC90A4D4F   2015-06-09 15:31:40.956878
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3FB11FBE0530C9AC90A4D4F   2015-06-09 15:37:27.242279
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3FD11FBE0530C9AC90A4D4F   2015-06-09 15:37:59.554329
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D3FF11FBE0530C9AC90A4D4F   2015-06-09 15:45:56.102636
server1:4889_Management_Service  SYSMAN  Browser@server4  18164BB3D40111FBE0530C9AC90A4D4F   2015-06-09 15:46:27.682465
server1:4889_Management_Service  SYSMAN  Browser@server2  18213BB79D7B47D2E0530C9AC90A58A5   2015-06-10 14:52:17.125739
server1:4889_Management_Service  SYSMAN  Browser@server2  18213BB79D7D47D2E0530C9AC90A58A5   2015-06-10 14:52:51.343261
server1:4889_Management_Service  SYSMAN  EMCLI@server1    182DC9ADE84206D2E0530C9AC90AC2C4   2015-06-10 17:58:44.801507
server1:4889_Management_Service  SYSMAN  Browser@client2  183F7D0EBC7F36E7E0530C9AC90AEEE4   2015-06-11 17:53:38.378172