Skip Headers
Oracle® Enterprise Manager Command Line Interface
10g Release 5 (10.2.0.5)

Part Number B40004-09
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

1 Command Line Interface Concepts and Installation

This chapter discusses the following Enterprise Manager Command Line Interface (EM CLI) topics:

Overview

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.

Using EM CLI, you can perform Enterprise Manager Grid Control console-based operations, such as monitoring and managing targets, jobs, groups, blackouts, notifications, and alerts. EM CLI is intended for use by enterprise or system administrators writing scripts, such as shell/batch files, Perl, Tcl, or PHP, that provide workflow in the customer's business process. You can also use EM CLI commands interactively from an operating system console.

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 Grid Control console. For example, you can only see and operate on targets for which you are authorized.

Examples of EM CLI usage are as follows:

How the EM CLI Works

The EM CLI Client is a Java application that accepts a command as input. The EM CLI Client uses the input command to identify a Verb to execute the command. A Verb is a Java plug-in extension to the EM CLI Client. A Verb services the command with its specific options and posts the results to the standard output stream. Any errors are posted to the error output stream. The Verb also returns an integer exit value that the EM CLI Client sets as the exit value of the command in the Client's calling environment (the operating system console).

A Verb can perform its operations locally, but most of the verbs included with the EM CLI are covered by the remote Verb in the EM CLI Client. The remote Verb contacts the EM CLI OMS Extension in the Enterprise Manager Oracle Management Services (OMS) Console via HTTP/HTTPS and sends the command line through HTTP to the OMS for processing. The EM CLI OMS Extension is essentially a standard Enterprise Manager console page, and is installed in the OMS just as any other standard console page. As with the EMCLI Client, the EM CLI OMS Extension uses the input command to identify a Verb to execute the command. The Verb can access the Management Repository or Management Agents via OMS services as necessary in processing the command.

The remote Verb logs on to the OMS and establishes a session automatically, as necessary, to access the OMS-Side Controller. The remote Verb impersonates the Enterprise Manager user that invoked the command from the Client. The Enterprise Manager user credentials are established locally to the EM CLI Client during a one-time, interactive exchange when the Enterprise Manager administrator uses the EM CLI setup Verb. Figure 1–1 shows the high-level architecture of EM CLI.

Figure 1-1 EM CLI Architecture

Shows EM CLI architecture and operational flow.

For more information about any of these functional areas, see Oracle Enterprise Manager Concepts.

Preliminary Advisory Information

EM CLI Quick Start

Setting up and running EM CLI is simple. EM CLI consists of two components used to access the Enterprise Manager framework functionality:

You can install the EM CLI Client on any system within your managed network. The EM CLI Client is a command-line program (Java-based) that sends EM CLI Verbs to a specific OMS. In some respects, the EM CLI Client functions as a command-line equivalent of an Enterprise Manager Grid Control console. The EM CLI OMS Extension is automatically installed with the OMS and serves as the communication conduit between the EM CLI Client and the OMS.

Requirements

Before installing EM CLI, you will need the following items:

  • Enterprise Manager 10g 10.2.0.5 Grid Control framework

  • Java version 1.4.1 or greater

  • Workstation running Solaris, Linux, HPUX, Tru64, AIX, or Windows with NTFS (client installation)

Installation and Setup

As mentioned above, the EM CLI OMS Extension is automatically installed with the OMS. You must install and set up the client portion. The following instructions cover installation and setup procedures for the EM CLI Client.

Installing the EM CLI Client

  1. Obtain the EM CLI Client kit (emclikit.jar).

    You can download the EM CLI client kit from any 10.2 Grid Control installation at the following location:

    HTTP(S)://host:port/em/console/emcli/download
    

    The emclikit.jar file is physically located in the $ORACLE_HOME/sysman/jlib directory of the 10.2.0.5 Grid Control OMS home.

  2. Set your JAVA_HOME environment variable and ensure that it is part of your PATH. Make sure that this variable is set to the home of a JDK 1.4.1 or greater. For example:

    setenv JAVA_HOME /usr/local/packages/j2sdk1.4.1_02
    
    setenv PATH $JAVA_HOME/bin:$PATH
    
  3. Enter the following command to ensure that you have the correct Java in your PATH:

    which java
    

    This should show the Java in $JAVA_HOME/bin.

  4. Install the EM CLI Client. You can install the client portion of EM CLI in any directory either on the same system as the OMS or on any system in your network (download the emclikit.jar file to that system).

    Go to the directory where you have installed emclikit.jar:

    cd $HOME/<your emcli installation directory>
    
  5. Enter the following command:

    java -jar emclikit.jar client -install_dir=<emcli client dir>
    

After you have installed the EM CLI Client, you are ready to begin setting up the client.

Setting Up the EM CLI Client

After the EM CLI Client is installed, you are ready to begin using EM CLI. At this point, you can run the EM CLI Client out of the installation directory location, or alternatively, you can add it to your PATH.

Immediately after installation, only basic operational Verbs are installed:

  • argfile — Execute an EM CLI Verb where the Verb and any arguments are contained in a file.

  • help — Access command-line help for EM CLI Verbs.

  • login — Log in and establish a session with the OMS.

  • logout — Log out of EM CLI client from Enterprise Manager.

  • setup — Configure EM CLI to function with a specific OMS.

  • sync — Synchronize the EM CLI Client with an OMS.

  • add_mp_to_mpa — Create (or add to) the Management Plug-in Archive. The Management Plug-in Archive is available for adding new target types to Enterprise Manager.

  • add_group_to_mpa — Add a Management Plug-in group to a Management Plug-in Archive.

Running Setup

You must run setup to connect the EM CLI Client to the OMS running the EM CLI Management Services. Running the setup Verb installs all available Verb-associated command-line help from the EM CLI Management Service. You must run setup each time you want to connect to a different OMS.

  1. Understand the syntax of the setup Verb and its options by entering the following command or referring to the setup Verb in the verb reference chapter of this guide:

    ./emcli help setup

  2. Enter the setup Verb with at least the minimum required parameters as shown in the following example:

    ./emcli setup -url=http://myworkstation.us.oracle.com:em_port/em    -username=em_user
    

    As you observed from step 1, the setup Verb has several options, including the following important options:

    • ssousername and ssopassword

    • noautologin

    • custom_attrib_file

  3. Enter your user password when prompted after the EM CLI client connects with the EM CLI Management Services.

After running the setup Verb, the message "Emcli Setup Successful" appears, and you are ready to begin using EM CLI.

Tip:

For complete information on the Setup verb and its options, including ssousername, ssopassword, noautologin, and custom_attrib_file referenced in step 2, see the setup Verb.

To configure the EM CLI Client to function with multiple OMSes by implementing multiple setups, see the Examples section for the Setup verb.

Using EM CLI Log Files

EM CLI creates log files to record informational and error messages generated during operation. Not all of the logs in the following examples are necessarily present. Logs are created as needed and are append-based — they are preserved between invocations of EM CLI. You can safely delete log files any time without affecting EM CLI operation. The logs contain stack traces, which may not be useful for the casual user, but may benefit you with a high level of system knowledge.

The following examples show possible log file locations:

CONFIG_DIR/.emcli.log
CONFIG_DIR/.emcli.log.1

CONFIG_DIR refers to the directory specified by the -dir option in the latest running of the setup Verb (with an appended .emcli subdirectory). The current CONFIG_DIR directory can be identified by executing the setup Verb with no options to display the setup summary.

Log files are limited to a maximum of 0.5 MB. EM CLI alternates between the two log files — as each file reaches the 0.5 MB limit, EM CLI begins writing to the other file, overwriting the oldest log file after emcli.log.1 has been filled for the first time.

The following examples show possible log file locations:

Example 1-1 No configuration directory is specified with the setup Verb (Default location)

user.home/.emcli/.emcli.log
user.home/.emcli/.emcli.log.1

If you do not specify a configuration directory when you run the setup Verb (-dir option is omitted), EM CLI assumes the .emcli configuration directory is located within the your local home directory. The log files are placed at the root level of the .emcli directory. The .emcli directory must be local (not mounted remotely).

Example 1-2 Local configuration directory is specified with the setup Verb (-dir=<local directory>

local.dir/.emcli/.emcli.log
local.dir/.emcli/.emcli.log.1

In this example, the configuration directory is specified using the -dir option when the setup Verb is run. This allows you to specify a local configuration directory if the user home directory is mounted remotely (through NFS, for example).

Configuring an HTTP Proxy Environment

If you are planning to use EM CLI through an HTTP proxy server, you need to set an additional environment variable (EMCLI_OPTS) that supplies EM CLI with the requisite proxy host and port information. The following examples illustrate setting the EMCLI_OPTS environment variable for both Windows and UNIX operating systems.

Example 1-3 Setting EMCLI_OPTS in a Microsoft Windows Environment

>set EMCLI_OPTS=-Dhttp.proxyHost=<proxy host> -Dhttp.proxyPort=<proxy port>

Example 1-4 Setting EMCLI_OPTS in a UNIX Environment (TCSH)

>setenv EMCLI_OPTS "-Dhttp.proxyHost=<proxy host> -Dhttp.proxyPort=<proxy port>"

EM CLI Command-line Help

EM CLI incorporates a comprehensive command-line help system that provides various levels of assistance. Available from any EM CLI Client installation, the help system provides a listing of all available verbs, descriptive overviews for each verb, syntax, as well as usage examples. The command-line help is the definitive EM CLI information source.

To access command-line help, enter the following command for an overview of all available verbs ...

./emcli help

... or enter the following command for a detailed Verb description, Verb arguments and options, and usage examples.

./emcli help <verb>

Security and Authentication

Each operating system user must execute a one-time EM CLI initialization that locally defines the location of the Oracle Management Services and the Enterprise Manager credentials to be used whenever this user invokes EM CLI.

Example 1-5 CLI-Enterprise Manager Authentication

>emcli setup –url="http[s]://host:port/em/" –username="<username>"  [-trustall] [-novalidate]>please enter password: 

Note:

You can find out the OMS connection information from any EM CLI Client by issuing the setup Verb without any options. For example:

>emcli setup

Oracle Enterprise Manager 10g Release 10.2.0.5

Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved.

CONFIG DIRECTORY: /home/emcli_install_dir/.emcli

OMS : http://my_system.my_co.com:port/em/

EM USER : username

TRUST ALL : false

HTTPS Trusted Certificate Management

For authenticating an OMS during the SSL server authentication phase of an HTTPS connection handshake, EM CLI searches for trusted certificates in the following key stores:

CONFIG_DIR/.emcli/.localkeystore
user.home/.emcli/.keystore
JRE_HOME/lib/security/cacerts

CONFIG_DIR is the directory specified by the -dir option in the latest running of the setup Verb (with an appended .emcli subdirectory). See "Using EM CLI Log Files" for more information about the CONFIG_DIR parameter.

JRE_HOME in a JDK installation is typically JAVA_HOME/jre.

The JDK keytool command can manage the key stores. For more information about this tool, see the security documentation for your Java VM installation, or at the time of this writing:

http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/keytool.html

Not all of the key stores in the list above will necessarily be present.

Secure Clients

You can provide credentials to EM CLI in one of two ways:

  • Provide credentials at the time of use. See the login and logout verbs for information on credentials.

  • Make credentials persistent on the host system where the EM CLI client is running, as might be the case when executing EM CLI verbs from a shell script.

Caution:

You should only make credentials persistent on hosts when the host is a secure client, since the only protection available for credentials is the file-system security of the OS.

Oracle also recommends not using persistent credentials if the EM CLI user's home directory is mounted over NFS or any other insecure file system.

Secure Mode for the EM CLI Setup

The EM CLI client installs certain configuration files and a client-side implementation of verbs on the client system. The EM CLI client configuration files contain information such as OMS URL, Enterprise Manager user name, Enterprise Manager password, and SSO user name and password (if EM is SSO-enabled). The default mode stores these credentials, which is inherently insecure because of backward compatibility reasons.

To eliminate this security risk, a secure mode EM CLI setup does not store any EM or SSO passwords on the client disk. For a secure setup, you need to specify the noautologin option for the Setup verb. You provide the credentials once during setup, after which a session is established between the client and OMS. All subsequent verbs use this session. Inactivity or an explicit logout (using the Logout verb) terminates this session, and a re-setup or an explicit login (using the Login verb) is required before invoking any new verb.

  • For information on the noautologin option, see the setup verb on page 2-217.

  • For information on logging in, see the login verb on page 2-154.

  • For information on logging out, see the logout verb on page 2-156.

Script Availability for Output Data Verbs

For easy parsing of Verb output by scripts, a script argument is available for all verbs that generate output data. If the -script argument is used, all output columns become tab-separated (with non-null values), and all rows become newline-separated. You can override the default column and row separators by using the -format argument in place of -script.

[-script|-format="name:<format type>;column_separator:<separator_text>;row_separator:<separator_text>"]

Supported -format arguments are shown in Table 1–1.

Table 1-1 Supported "-format" Arguments

Argument Explanation

-format="name:pretty"

Pretty-print the output. This is the default when both -script and -format are not specified.

-format="name:script"

Identical to just specifying –script. Columns are tab-separated, and rows are newline- separated.

-format="name:script;column_separator:<column_sep_string>"

Causes the Verb output to be column-separated by <column_sep_string>. Rows are separated by the newline character.

-format="name:script;row_separator:<row_sep_string>"

Causes the Verb output to be row-separated by <row_sep_string>. Columns are separated by the tab character.

-format="name:script;column_separator:<column_sep_string>;row_separator:<row_sep_string>"

Causes the Verb output to be column-separated by <column_sep_string> and row- separated by <row_sep_string>.

-format="name:csv"

Produces a table with the columns separated by commas and the rows by newlines.