Skip Headers
Oracle® Enterprise Manager Command Line Interface
10g Release 4 (10.2.0.4)

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

Go to previous page
Previous
Go to next page
Next
View PDF

1 Command Line Interface

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

Overview

The Enterprise Manager Command Line Interface (EM CLI) allows you to access Enterprise Manager Grid Control functionality from text-based consoles (shells and command windows) for a variety of operating systems. This capability enables administrators to 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, like monitoring/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. EM CLI commands can also be used interactively from an operating system console.

EM CLI is fully integrated with Enterprise Manager's security and user administration functions, thus allowing administrators to carry out operations using EM CLI with the same security and confidentiality as the Enterprise Manager Grid Control console. For example, the EM CLI user can only see and operate on targets for which they 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 then 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 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 local 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 machine within your managed network. The EM CLI Client is a command-line program (Java-based) that sends EM CLI Verbs to a specific Oracle Management Service (OMS). In some respects, the EM CLI Client functions as a command-line equivalent of an Enterprise Manager Grid Control console. The EM CLI Oracle Management Service 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:

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).

    The EM CLI client kit is downloadable 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.4 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.2 or greater. For example:

    setenv JAVA_HOME /usr/local/packages/j2sdk1.4.2_02
    
    setenv PATH $JAVA_HOME/bin:$PATH
    
  3. Install the EM CLI Client. You can install the client in any directory either on the same machine as the EM CLI Management Services or on any machine in your network (download the emclikit.jar file to that machine). Run 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 client setup.

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 "install_dir" 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.

  • setup — Configure EM CLI to work with a specific Enterprise Manager Management Service (OMS).

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

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

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

You must run "setup" to connect the EM CLI Client to the OMS running the EM CLI Management Services. For information on how to use the setup Verb, see the command-line help by entering the following command:

> emcli help setup

Example 1-1 Setting Up the EM CLI Client

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

When the EM CLI Client connects with the EM CLI Management Services, you are prompted at the command line to enter the user password. 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.

After running the setup Verb, you are ready to begin using EM CLI.

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 will necessarily be present. Logs are created as needed and are append-based—they are preserved between invocations of EM CLI. You can safely delete log files at any time without affecting EM CLI operation.

The logs contain stack traces, which may not be useful for the casual user, but may benefit users 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-2 No configuration directory is specified with the setup Verb (Default location)

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

If no configuration directory is specified when the setup Verb is run (-dir option is omitted), EM CLI assumes the .emcli configuration directory is located within the user's 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-3 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-4 Setting EMCLI_OPTS in a Microsoft Windows Environment

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

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

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

EM CLI Command-line Help

The 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, type the following:

>emcli help

Provides an overview of all available verbs.

OR

>emcli help <verb>

Provides a detailed description of the Verb, Verb arguments and options, and usage examples.

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-6 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.4

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

CONFIG DIRECTORY: /home/emcli_install_dir/.emcli

OMS : http://my_machine.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 "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.

  • Make credentials persistent on the host machine 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.

EM CLI General Behavior

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.


Using EM CLI

As mentioned previously, the EM CLI provides programmatic access to the functions of the Enterprise Manager Grid Control framework. You can access a subset of framework functions from the Enterprise Manager console through the command line using the EM CLI Verbs. See Chapter 2, "Verb Reference" for more information on available verbs.