Oracle 11g Grid: Using EMCLI , A command line Grid Control Interface

Posted By Sagar Patil

The Enterprise Manager Command Line Interface (EM CLI) enables you to access Enterprise Manager Grid Control functionality from text-based consoles (shells and command windows) for a variety of operating systems. You can call Enterprise Manager functionality using custom scripts, such as SQL*Plus, OS shell, Perl, or Tcl, thus easily integrating Enterprise Manager functionality with a company’s business process.

1. Requirements : Before installing EM CLI, you will need the following:
Java version 1.6.0 or greater
Workstation running Solaris, Linux, HPUX, Tru64, AIX, or Windows with NTFS (client installation)


2. Download the EM CLI Kit to your workstation.
If you have Grid control in place use URL http://%Gridcontrol%HOST%/em/console/emcli/download

3. Install EM CLI Client.

You can install client portion of EM CLI in any directory either on the same machine as the OMS or on any machine on your network (download the emclikit.jar to that machine).
Run “java -jar emclikit.jar client -install_dir=<emcli client dir>”

4. The CLI must be set up and connected to an OMS

Execute “emcli help setup” from the EM CLI Client for instructions on how to use the “setup” verb to configure client for a particular OMS. Setup emcli to work with the EM Management Server (OMS) specified by the -url argument. Issuing the “emcli setup” command with no arguments will show current OMS connection details.

C:\EMCLI>emcli setup -url=http://gridcontrol/em -username=sysman -dir=C:\EMCLI
Oracle Enterprise Manager 11g Release 11.1.0.1.0.
Enter password
Emcli setup successful

C:\EMCLI>emcli setup < Will flash Current Configuration>
Oracle Enterprise Manager 11g Release 11.1.0.1.0.
Copyright (c) 1996, 2010 Oracle Corporation and/or its affiliates. All rights re
served.
CONFIG DIRECTORY : C:\EMCLI\.emcli
OMS              : http://gridcontrol/em
EM USER          : sysman
TRUST ALL        : false

C:\EMCLI>emcli help setup

-url=”http[s]://host:port/em/”
[-username=<EM Console Username]>
[-ssousername=<EM SSO Username>]
[-ssopassword=<EM SSO Password>]
[-password=<EM Console Password>]
[-ssologinurl=<sso final login url>]
[-ssousernameparamname=<username text field name>]
[-ssopasswordparamname=<password text field name>]]
[-licans=YES|NO]
[-dir=<local emcli configuration directory>]
[-trustall]
[-novalidate]
[-noautologin]
[-custom_attrib_file=<Custom attribute file path>]
[-nocertvalidate]

C:\EMCLI>emcli create_group -name=”TEST_EMCLI_GROUP”
Group “TEST_EMCLI_GROUP:group” created successfully

C:\EMCLI>emcli get_targets -targets=”oracle_database”
Status  Status   Target Type      Target Name
ID
0       Down     oracle_database  spdtsta.gta.travel.lcl
1       Up       oracle_database  DEV2
1       Up       oracle_database  DEVDB
1       Up       oracle_database  DEV1
1       Up       oracle_database  GRIDB

The following example shows all targets. Critical and Warning columns are not included.
emcli get_targets

The following example shows all targets. Critical and Warning columns are shown.
emcli get_targets -alerts

The following example shows all oracle_database targets.
emcli get_targets -targets=”oracle_database”

The following example shows all targets whose type contains the string oracle.
emcli get_targets -targets=”%oracle%”

The following example shows all targets registered at OMS repository

emcli get_targets
Status  Statu  Target Type      Target Name
-9      n/a    group            RAC DataGuard Group
-9      n/a    metadata_reposi  /secFarm_GCDomain/GCDomain/EMGC_ADMINSERVER/mdstory             -sysman_mds
-9      n/a    oracle_ias_farm  secFarm_GCDomain
-9      n/a    weblogic_domain  /secFarm_GCDomain/GCDomain
0       Down   weblogic_j2eese  /secFarm_GCDomain/GCDomain/EMGC_OMS1
1       Up     j2ee_applicatio  /secFarm_GCDomain/GCDomain/EMGC_OMS1/OCMRepeaten
1       Up     netapp_filer
1       Up     oracle_database
1       Up     oracle_emd
1       Up     oracle_listener  LISTENER_
1       Up     rac_database
1       Up     host

Users and Credentials :

Create a new USER :

emcli create_user -name=CLI_TEST -desc=”This is a new superuser” -privilege=”SUPER_USER” -expire=”true” -password=”manager”

How to Delete User? : emcli delete_user -name=CLI_TEST

Creating BlackOuts :

Consider you don’t have access to GRID GUI or you want to embed creating blackout on fly as part of a shell script

emcli create_blackout -name=”Agent Install” -add_targets=”%TARGETNAME%:oracle_database” -reason=”Agent Install” -description=”Agent required for Monitoring” -schedule=”duration::30″

For all emcli command reference please see Oracle Documentation

Leave a Reply

You must be logged in to post a comment.

Top of Page

Top menu