This chapter provides the following topics:
The Enterprise Manager Command Line Interface (EM CLI) enables users to access Enterprise Manager functionality through a command-line interface or scripts. It is accessible through classic programming language constructs, enabling tasks to be created and run either from the command-line or programatically. 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. For example, you can only see and operate on targets for which you are authorized.
Create a new Enterprise Manager administrator account.
Monitor and manage targets, jobs, groups, and blackouts.
Enable batch/complex tasks on multiple Agents or targets.
Integrate Enterprise Manager with third-party or custom software through scripts. Actions that are part of a customer's business model can be performed through scripts.
EM CLI offers the following modes of operation:
In Standard mode, each EM CLI verb entered is a single operating system command. Each command launches EM CLI, executes the command, then terminates.
Interactive mode is ideal for adhoc queries or commands for real-time diagnostics or debugging. In this mode, EM CLI is started as a shell and all commands entered on the command line are executed immediately to enable several commands to be executed at will in the same shell.
In Script mode, an administrator can create a single Python script that includes a sequence of EM CLI commands to be executed with a single invocation.
Each mode uses the same verbs. A verb is a task or action in the form of a user command which exposes Enterprise Manager functionality. Some verbs can include one or more parameters, which are arguments to the specified command. Some of the parameters are required and some are optional.In the following examples of the
create_group verb syntax, only the
-name parameter is required. The other parameters are optional.
Standard mode example
$ emcli create_group -name="name" [-type=<group>] [-add_targets="name1:type1;name2:type2;..."] [-is_propagating="true/false";
Interactive mode example
$ emcli emcli> … other commands… emcli> create_group(name="name" [;type=<group>] [;add_targets="name1:type1;name2:type2;..."] [;is_propagating="true/false"); emcli> … other commands … emcli> exit() $
Script mode example
$ emcli @create_group.py;
This is the traditional and exclusive mode prior to Enterprise Manager Cloud Control version 18.104.22.168. This mode provides a simple command-line interface to Enterprise Manager, and supports the execution of one verb at a time from the command line.
emcli create_group -name=my_group -add_targets="mymachine.myco.com:host"
This mode enables you to create a single interactive session with the server (Oracle Management Services), where you can type in commands, view the output, and potentially respond to or manipulate the output. Interactive mode opens a Jython shell, where you can provide Jython scripts using EM CLI verbs as Jython functions. Jython is a Java implementation of the Python programming language.
Note that when calling a verb in Interactive mode, the arguments are placed inside parentheses. For example:
Script mode is especially effective when performing tasks in bulk mode or many tasks at once. Scripts are useful for accomplishing several tasks, including:
Listing or setting global target properties
Listing or setting Agent properties
Updating database passwords
Listing group members
This mode enables you to create Jython scripts, store them as files, and then pass these files to EM CLI as an argument, such as ...
... where createuser.py is the name of a file containing the Python code to be sent to EM CLI.
You can create reusable, functional modules using existing EM CLI verbs to generate complex tasks. This intuitive, object-oriented programming model supports encapsulation, loops, functions, exception and error handling, and so forth. These abilities enable you to benefit from all of the powerful features that the Jython programming language offers.
See Also:For more information about using the different modes, see Chapter 3, "Using EM CLI".
Figure 1-1 shows the high-level architecture of EM CLI.
A typical verb may take zero or more arguments as input. The EM CLI client passes the input to OMS for processing. The EM CLI client connects to OMS and establishes a user session, which is used across verb executions until a logout is initiated.