SlideShare a Scribd company logo
ENTERPRISE MANAGER:

WRITE POWERFUL
SCRIPTS WITH EMCLI
GOKHAN ATIL
INTRODUCTION
GOKHAN ATIL
▸ DBA Team Lead with 15+ years of experience
▸ Oracle ACE (since 2011)
▸ 10g/11g and R12 OCP
▸ Founding Member and Vice President of TROUG
▸ Co-author of Expert Oracle Enterprise Manager 12c
▸ Blogger (since 2008) gokhanatil.com
▸ Twitter: @gokhanatil
2
INTRODUCTION
AGENDA
▸ Introduction to EM CLI
▸ EM CLI Verbs
▸ Sample Verbs
▸ Fundamentals of Python
▸ EM CLI and Python
▸ Sample Scripts
▸ Summary
3
INTRODUCTION TO EM CLI
4
INTRODUCTION TO EM CLI
WHAT IS EM CLI?
EMCLI is an alternative for the web interface. It enables you to access
OEM functionality from a text-based console.
Repository
EM CLI
Agent
OMS
Web Console
5
INTRODUCTION TO EM CLI
ALREADY INSTALLED
EM CLI is already installed and configured on OMS server:
cd $MIDDLEWARE_HOME/bin
./emcli (or emcli.bat on Windows servers)
6
INTRODUCTION TO EM CLI
YOU CAN INSTALL EM CLI TO YOUR PC
▸ Requires Java version 1.7.0_80 or greater
▸ Supported Operating Systems: Windows, Linux, Solaris,
HPUX, Tru64, AIX
▸ Go to “command line interface” page under “setup” page
to download the installation JAR file.
▸ Login is not required to download, so it’s possible to
download the JAR file with “wget”.
To run EM CLI on Java 1.8 or higher, you need apply patch 17555224 to
the weblogic server. Use"-no-check-certificate" parameter with wget.
7
INTRODUCTION TO EM CLI
EM CLI DOWNLOAD PAGE
8
INTRODUCTION TO EM CLI
EM CLI STANDARD KIT VS ADVANCED KIT
There are two different installation kits for EM CLI:
▸ EM CLI Standard Kit: This kit supports only the Standard
(command line) mode.
▸ EM CLI with Scripting mode (option): This “advanced”
kit supports Interactive and Script modes in addition to
standard mode.
9
INTRODUCTION TO EM CLI
3 MODES OF EM CLI:
▸ Standard mode: 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 get_targets
▸ Interactive mode: This mode enables you to create a single interactive
session with OMS. It is a Jython shell.
emcli
▸ Scripting mode: In Scripting mode, EM CLI runs Jython scripts containing EM
CLI verbs.
emcli @scriptname.py
10
INTRODUCTION TO EM CLI
SOMEONE SAID JYTHON?
Jython is an implementation of the Python programming
language designed to run on the Java platform.
11
INTRODUCTION TO EM CLI
SO WHAT’S PYTHON?
▸ Widely used general-purpose, 

high-level programming language
▸ Supports multiple programming paradigms, including
OOP, imperative and functional programming
▸ Dynamic type system and automatic memory
management
▸ Batteries Included (!)
12
INTRODUCTION TO EM CLI
INSTALL AND CONFIGURE:
▸ After you download, set JAVA_HOME and install the JAR
file:
java -jar emcliadvancedkit.jar -install_dir=<home>
▸ Configure EM CLI:
emcli help setup
emcli setup -url="https://host:port/em" 

-username=<emuser> -dir=<instancedir> -trustall
13
EM CLI VERBS
14
EM CLI VERBS
400+ VERBS IN 75+ CATEGORIES
▸ Add Host Verbs
▸ Agent Administration Verbs
▸ Agent Upgrade Verbs
▸ BI Publisher Reports Verbs
▸ Blackout Verbs
▸ Credential Verbs
▸ Incident Rules Verbs
▸ Job Verbs
▸ Metric Extension Verbs
▸ Monitoring Templates Verbs
▸ Oracle Cloud Verbs
▸ Provisioning Verbs
▸ Self Update Verbs
▸ User Administration Verbs
15
EM CLI VERBS
GET QUICK HELP
You can get the list of available verbs using “help”:
emcli help
emcli help get_targets
16
EM CLI VERBS
EM CLI VERBS IN STANDARD MODE
In standard mode, EM CLI expect you enter a verb as the first
parameter. Verbs may take zero or more arguments as input.
emcli verb -1st_argument="value" 

[ -2nd_ argument="value" ]

[ -3rd_ argument="value" ] 

[ -4th_ argument ]

…
17
EM CLI VERBS
EM CLI VERBS IN SCRIPTING MODE
▸ Verbs are defined as Python functions
▸ Arguments are entered as function parameters
verb( argument_name="value", 2nd_ argument="value")
▸ Results of verbs are formatted as JSON
18
SAMPLE VERBS
LOGIN
Login verb is used to log into Enterprise Manager with the
given credentials.
login( username="SYSMAN", password="123456",
force=true)
login( username="SYSMAN", password="123456" )
login( username=“SYSMAN" )
The EM CLI client should be logged in to OMS before other
EM CLI verbs are executed.
19
SAMPLE VERBS
GET_TARGETS
get_targets verb lists the targets (their names and their types) which are
discovered or monitored by Enterprise Manager.
get_targets()
get_targets( targets="targetname:targettype" )
get_targets( targets="targetname:%" )
get_targets( targets="targettype" )
get_targets( "unmanaged", targets="targettype" )
Target names, target types and even “verbs” are case sensitive, so be sure
that you use the exact name of a target and target type!
20
SAMPLE VERBS
ADD_TARGET
add_target verb adds a target to Enterprise Manager.
add_target( name="TESTDB",

type="oracle_database",

host="testdb.gokhanatil.com",

credentials="...", 

properties="..." )
You must specify any required properties of a target type
when adding a new target of this type
21
SAMPLE VERBS
CLEAR_STATELESS_ALERTS
clear_stateless_alerts verb clears the stateless alerts associated
with the specified target. Stateless alerts are not cleared
automatically by the Enterprise Manager.
clear_stateless_alerts( 

target_name="TESTDB", 

target_type="oracle_database",

metric_internal_name="...",

older_than="0" )
To find the metric internal name associated with a stateless alert,
use the get_metrics_for_stateless_alerts verb.
22
SAMPLE VERBS
UPDATE_DB_PASSWORD
update_db_password verb updates the target database password
stored in the Enterprise Manager Credential sub-system and can
change the password on the target database as well.
update_db_password (target_name="TESTDB",

user_name="DBSNMP",

target_type="oracle_database",

change_at_target="yes",

old_password="oldone",

new_password="newone",

retype_new_password="newone" )
23
SAMPLE VERBS
LIST
▸ Although there are more than 85+ verbs to help you fetch
a specific information from OMS such as list of targets, list
of jobs etc, you may still need a more powerful verb which
can fetch information from the repository database.
▸ This command will show all resources that you can query:
emcli list -help
24
SAMPLE VERBS
LIST
▸ The following command will list the users defined in EM:
emcli list -resource="Administrators"
▸ This command shows the columns of the specified resource:
emcli list -resource="Administrators" -help
25
SAMPLE VERBS
LIST
▸ This command will list the EM users and their last logins:
emcli list -resource="Administrators" 

-columns="USER_NAME,LAST_AUTHENTICATED_TS"
▸ The following command will list the EM users which are logged in at least one time:
emcli list -resource="Administrators"

-columns="USER_NAME,LAST_AUTHENTICATED_TS"

-search=“LAST_AUTHENTICATED_TS IS NOT NULL"
26
SAMPLE VERBS
LIST
Latest version of the “list” verb can query 30+ resources. If you
can not find the data you need among these resources, you
can even run SQL on repository database using list verb:
emcli list -sql="<query>"
You need ACCESS_EMCLI_SQL_LIST_VERB privilege to be
able to run query using “the list verb”.
27
FUNDAMENTALS OF PYTHON
28
FUNDAMENTALS OF PYTHON
VARIABLES
Python supports dynamic type variables. You don’t need to
declare a variable but you need to initialise it before you use:
▸ myvar = "TESTDB"
▸ myvar = myvar + ":oracle_database"
▸ myvar = 10
▸ myvar = myvar + 10
▸ myvar = 10 + "10"
TYPE ERROR:
UNSUPPORTED
OPERAND TYPE(S) FOR 

+: 'INT' AND 'STR'
29
FUNDAMENTALS OF PYTHON
CONVERSIONS
You can convert numbers to string using “str” function, and
string variables to numbers using “int” function:
‣ myvar = int("2")

‣ myvar = int("5") + 10

‣ myvar = str(2)

‣ myvar = str(2) + "nd century"

30
FUNDAMENTALS OF PYTHON
CONDITIONAL STATEMENTS AND CODE BLOCKS
The indented block of code is executed if the condition is
true. You should use indents to create code blocks.

myvar = int("2")

myvar = myvar + 10

myvar = "2"

if ( myvar >= 10 ):

print "myvar is " + str(myvar)

else:

print "lower than 10"
CODE BLOCKS ARE IDENTIFIED
BY “INDENTATION”
THE COLON (:) SIGN
31
FUNDAMENTALS OF PYTHON
DICTIONARY AND LIST OBJECTS
Dictionary objects, list objects and iterations:
mydict = { 'Name':'Gokhan', 'Age':40 }

mydict['Name'] = "Gokhan"
mylist = ["Joe","William","Jack","Averell"] 

mylist[0] = "Joe"
for i in mylist:

print i
SIMILAR TO

JSON. KEY=VALUE
IT WILL PRINT ALL ELEMENTS IN “MYLIST”
ARRAY. USE INDEX TO REACH VALUE
32
EM CLI AND PYTHON
33
EM CLI AND PYTHON
EM CLI RESPONSE OBJECT
emcli.response represents the response object which
returned from invocation of a emcli verb from python script.
emcli.response.Response
error() error text

exit_code() error code (0=success)

isJson() is JSON? true/false

out() JSON or text
34
EM CLI AND PYTHON
EM CLI RESPONSE OBJECT
In scripting mode, default output format type is JSON. In
interactive mode, to change the output format to JSON, you
need to run the following command:
set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
It’s recommended to use JSON format because it directly
matches with Python “dictionary” object. There’s no need for
extra effort to parse the output.
35
EM CLI AND PYTHON
EM CLI RESPONSE OBJECT
Let’s get the response from a verb:
mytargets = get_targets( target="oracle_database" )
type(mytargets.out())

<type 'dict'>
mytargets.out()
{'data': [{'Status': 'Up', 'Warning': '6', 'Status ID': '0', 'Target
Type': 'oracle_database', 'Critical': '64', 'Target Name':
'TESTDB'}, {…}, {…}, {…}] }
36
EM CLI AND PYTHON
EM CLI RESPONSE OBJECT
A response always contain a “data” item which is a list object:
type(mytargets.out()['data'])

<type ‘list'>
mytargets.out()['data']
[ {'Status': 'Up', 'Warning': '6', 'Status ID': '0', 'Target Type':
'oracle_database', 'Critical': '64', 'Target Name': 'TESTDB'},{…},
{…}, {…} ]
type(mytargets.out()['data'][0])

<type 'dict'>
37
EM CLI AND PYTHON
EM CLI RESPONSE OBJECT
We can iterate over the items of the list:
for DB in mytargets.out()['data']:

print DB['Target Name'], DB['Status']
DICT / JSON
LIST (DATA)
DICT
DICT
DICT
DICT
DICT
38
SAMPLE SCRIPTS
39
SAMPLE SCRIPTS
CLEAR STATELESS ALERTS
Save the following code in a file (clearalerts.py) and run it as
“emcli @clearalerts.py”:
if login( username="GOKHAN" ).exit_code()==0:
mytargets=get_targets( targets="oracle_database" )
for DB in mytargets.out()['data']:

clear_stateless_alerts( 

target_name=DB['Target Name'], 

target_type=DB['Target Type'], older_than="0" )
40
SAMPLE SCRIPTS
CHANGE DBSNMP PASSWORDS
if len(sys.argv) <> 2:

print "Usage: emcli @change_dbsnmp_passwords.py oldpwd newpwd"

exit()

if login( username="GOKHAN" ).exit_code()==0:

mytargets=get_targets( targets="%_database" )

for DB in mytargets.out()['data']:

try: 

update_db_password (target_name=DB['Target Name'],

target_type=DB['Target Type'] ,

change_at_target="yes",user_name="dbsnmp",

old_password=sys.argv[0],

new_password=sys.argv[1],

retype_new_password=sys.argv[1])

except emcli.exception.VerbExecutionError, e:

print e.error()
41
SAMPLE SCRIPTS
PROMOTE UNMANAGED DATABASES
lg = login( username="SYSMAN" )
if lg.exit_code() <> 0:

print lg.error()

exit()
utargets=get_targets( "unmanaged", properties=True,
targets="oracle_database" )
for target in utargets.out()['data']:

add_target( name=target['Target Name'], type=target['Target Type'],

host=target['Host Info'].split(';')[0].split(':')[1],

credentials="UserName:dbsnmp;password:xyz;Role:Normal", 

properties=target['Properties'] )
POSITIONAL PARAMETERS
42
SUMMARY
43
SUMMARY
WHY NOT BASH SCRIPTING WITH EM CLI STANDARD KIT?
▸ BASH scripting supports
environment variables, if
conditions, loops
▸ Linux tools (grep, awk
etc…) to parse output of
EM CLI
▸ Python is cross-platform
▸ Python scripts are easy to
be read and maintain
▸ Python scripts perform
better
44
SUMMARY
FURTHER READING
▸ OEM 12c Command-Line Interface
▸ My blog:

http://www.gokhanatil.com
▸ Kellyn Pot'Vin-Gorman

http://dbakevlar.com
▸ Ray Smith

https://oramanageability.wordpress.com
▸ Seth Miller

http://sethmiller.org
▸ The Definitive Guide to Jython

http://www.jython.org/jythonbook/en/1.0/
45
THANK YOU FOR ATTENDING! 

ANY QUESTIONS?
46

More Related Content

What's hot

Oracle 12c PDB insights
Oracle 12c PDB insightsOracle 12c PDB insights
Oracle 12c PDB insights
Kirill Loifman
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuningSimon Huang
 
What’s New in Oracle Database 19c - Part 1
What’s New in Oracle Database 19c - Part 1What’s New in Oracle Database 19c - Part 1
What’s New in Oracle Database 19c - Part 1
Satishbabu Gunukula
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
Mauro Pagano
 
What to Expect From Oracle database 19c
What to Expect From Oracle database 19cWhat to Expect From Oracle database 19c
What to Expect From Oracle database 19c
Maria Colgan
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360
Carlos Sierra
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Tanel Poder
 
Oracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API ExamplesOracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API Examples
Bobby Curtis
 
Chasing the optimizer
Chasing the optimizerChasing the optimizer
Chasing the optimizer
Mauro Pagano
 
Migration to Oracle Multitenant
Migration to Oracle MultitenantMigration to Oracle Multitenant
Migration to Oracle Multitenant
Jitendra Singh
 
Oracle data guard for beginners
Oracle data guard for beginnersOracle data guard for beginners
Oracle data guard for beginners
Pini Dibask
 
15 Troubleshooting tips and Tricks for Database 21c - KSAOUG
15 Troubleshooting tips and Tricks for Database 21c - KSAOUG15 Troubleshooting tips and Tricks for Database 21c - KSAOUG
15 Troubleshooting tips and Tricks for Database 21c - KSAOUG
Sandesh Rao
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
Maria Colgan
 
How to Use EXAchk Effectively to Manage Exadata Environments
How to Use EXAchk Effectively to Manage Exadata EnvironmentsHow to Use EXAchk Effectively to Manage Exadata Environments
How to Use EXAchk Effectively to Manage Exadata Environments
Sandesh Rao
 
Understanding oracle rac internals part 1 - slides
Understanding oracle rac internals   part 1 - slidesUnderstanding oracle rac internals   part 1 - slides
Understanding oracle rac internals part 1 - slides
Mohamed Farouk
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
Guy Harrison
 
Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratop
Sandesh Rao
 
Oracle 12c and its pluggable databases
Oracle 12c and its pluggable databasesOracle 12c and its pluggable databases
Oracle 12c and its pluggable databases
Gustavo Rene Antunez
 
Maximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19cMaximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19c
Glen Hawkins
 

What's hot (20)

Oracle 12c PDB insights
Oracle 12c PDB insightsOracle 12c PDB insights
Oracle 12c PDB insights
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
 
What’s New in Oracle Database 19c - Part 1
What’s New in Oracle Database 19c - Part 1What’s New in Oracle Database 19c - Part 1
What’s New in Oracle Database 19c - Part 1
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
What to Expect From Oracle database 19c
What to Expect From Oracle database 19cWhat to Expect From Oracle database 19c
What to Expect From Oracle database 19c
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
Oracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API ExamplesOracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API Examples
 
Chasing the optimizer
Chasing the optimizerChasing the optimizer
Chasing the optimizer
 
Migration to Oracle Multitenant
Migration to Oracle MultitenantMigration to Oracle Multitenant
Migration to Oracle Multitenant
 
Oracle data guard for beginners
Oracle data guard for beginnersOracle data guard for beginners
Oracle data guard for beginners
 
15 Troubleshooting tips and Tricks for Database 21c - KSAOUG
15 Troubleshooting tips and Tricks for Database 21c - KSAOUG15 Troubleshooting tips and Tricks for Database 21c - KSAOUG
15 Troubleshooting tips and Tricks for Database 21c - KSAOUG
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
 
How to Use EXAchk Effectively to Manage Exadata Environments
How to Use EXAchk Effectively to Manage Exadata EnvironmentsHow to Use EXAchk Effectively to Manage Exadata Environments
How to Use EXAchk Effectively to Manage Exadata Environments
 
Understanding oracle rac internals part 1 - slides
Understanding oracle rac internals   part 1 - slidesUnderstanding oracle rac internals   part 1 - slides
Understanding oracle rac internals part 1 - slides
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratop
 
Oracle 12c and its pluggable databases
Oracle 12c and its pluggable databasesOracle 12c and its pluggable databases
Oracle 12c and its pluggable databases
 
Convert single instance to RAC
Convert single instance to RACConvert single instance to RAC
Convert single instance to RAC
 
Maximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19cMaximum Availability Architecture - Best Practices for Oracle Database 19c
Maximum Availability Architecture - Best Practices for Oracle Database 19c
 

Similar to Enterprise Manager: Write powerful scripts with EMCLI

Oracle Enterprise Manager 12c: EMCLI Crash Course
Oracle Enterprise Manager 12c: EMCLI Crash CourseOracle Enterprise Manager 12c: EMCLI Crash Course
Oracle Enterprise Manager 12c: EMCLI Crash Course
Gokhan Atil
 
EMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyEMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG Germany
Gokhan Atil
 
Kscope emcli kpotvin
Kscope emcli kpotvinKscope emcli kpotvin
Kscope emcli kpotvin
Kellyn Pot'Vin-Gorman
 
The Enterprise Manager Command Line by Kellyn Pot'Vin
The Enterprise Manager Command Line by Kellyn Pot'VinThe Enterprise Manager Command Line by Kellyn Pot'Vin
The Enterprise Manager Command Line by Kellyn Pot'VinEnkitec
 
The enterprise manager command line interface2
The enterprise manager command line interface2The enterprise manager command line interface2
The enterprise manager command line interface2
Kellyn Pot'Vin-Gorman
 
The enterprise manager command line interface2
The enterprise manager command line interface2The enterprise manager command line interface2
The enterprise manager command line interface2
Kellyn Pot'Vin-Gorman
 
Clean Code
Clean CodeClean Code
Clean Code
Nascenia IT
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
Paras Mendiratta
 
Clean code
Clean codeClean code
Clean code
Arturo Herrero
 
JavaScript lesson 1.pptx
JavaScript lesson 1.pptxJavaScript lesson 1.pptx
JavaScript lesson 1.pptx
MuqaddarNiazi1
 
Power shell training
Power shell trainingPower shell training
Power shell training
David Brabant
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
ClojureScript: The Good Parts
ClojureScript: The Good PartsClojureScript: The Good Parts
ClojureScript: The Good Parts
Kent Ohashi
 
Python advance
Python advancePython advance
Python advance
Deepak Chandella
 
Different type of shells In Netapp Cluster mode 8.X and how to access them t...
Different type of shells In Netapp Cluster mode 8.X  and how to access them t...Different type of shells In Netapp Cluster mode 8.X  and how to access them t...
Different type of shells In Netapp Cluster mode 8.X and how to access them t...
Saroj Sahu
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196
Mahmoud Samir Fayed
 
Power Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhPower Shell for System Admins - By Kaustubh
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex codeEdwinOstos
 
VB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptVB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.ppt
BhuvanaR13
 

Similar to Enterprise Manager: Write powerful scripts with EMCLI (20)

Oracle Enterprise Manager 12c: EMCLI Crash Course
Oracle Enterprise Manager 12c: EMCLI Crash CourseOracle Enterprise Manager 12c: EMCLI Crash Course
Oracle Enterprise Manager 12c: EMCLI Crash Course
 
EMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyEMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG Germany
 
Kscope emcli kpotvin
Kscope emcli kpotvinKscope emcli kpotvin
Kscope emcli kpotvin
 
The Enterprise Manager Command Line by Kellyn Pot'Vin
The Enterprise Manager Command Line by Kellyn Pot'VinThe Enterprise Manager Command Line by Kellyn Pot'Vin
The Enterprise Manager Command Line by Kellyn Pot'Vin
 
The enterprise manager command line interface2
The enterprise manager command line interface2The enterprise manager command line interface2
The enterprise manager command line interface2
 
The enterprise manager command line interface2
The enterprise manager command line interface2The enterprise manager command line interface2
The enterprise manager command line interface2
 
Clean Code
Clean CodeClean Code
Clean Code
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 
Clean code
Clean codeClean code
Clean code
 
JavaScript lesson 1.pptx
JavaScript lesson 1.pptxJavaScript lesson 1.pptx
JavaScript lesson 1.pptx
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
ClojureScript: The Good Parts
ClojureScript: The Good PartsClojureScript: The Good Parts
ClojureScript: The Good Parts
 
Python advance
Python advancePython advance
Python advance
 
Different type of shells In Netapp Cluster mode 8.X and how to access them t...
Different type of shells In Netapp Cluster mode 8.X  and how to access them t...Different type of shells In Netapp Cluster mode 8.X  and how to access them t...
Different type of shells In Netapp Cluster mode 8.X and how to access them t...
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196
 
Power Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhPower Shell for System Admins - By Kaustubh
Power Shell for System Admins - By Kaustubh
 
Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex code
 
VB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptVB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.ppt
 

More from Gokhan Atil

Introduction to Spark with Python
Introduction to Spark with PythonIntroduction to Spark with Python
Introduction to Spark with Python
Gokhan Atil
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
Gokhan Atil
 
SQL or noSQL - Oracle Cloud Day Istanbul
SQL or noSQL - Oracle Cloud Day IstanbulSQL or noSQL - Oracle Cloud Day Istanbul
SQL or noSQL - Oracle Cloud Day Istanbul
Gokhan Atil
 
Oracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsOracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAs
Gokhan Atil
 
Essential Linux Commands for DBAs
Essential Linux Commands for DBAsEssential Linux Commands for DBAs
Essential Linux Commands for DBAs
Gokhan Atil
 
TROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yolu
TROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yoluTROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yolu
TROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yolu
Gokhan Atil
 
Oracle 12c Database In Memory DBA SIG
Oracle 12c Database In Memory DBA SIGOracle 12c Database In Memory DBA SIG
Oracle 12c Database In Memory DBA SIG
Gokhan Atil
 
Oracle 12c Database In-Memory
Oracle 12c Database In-MemoryOracle 12c Database In-Memory
Oracle 12c Database In-Memory
Gokhan Atil
 
Oracle DB Standard Edition: Başka Bir Arzunuz?
Oracle DB Standard Edition: Başka Bir Arzunuz?Oracle DB Standard Edition: Başka Bir Arzunuz?
Oracle DB Standard Edition: Başka Bir Arzunuz?
Gokhan Atil
 
Enterprise Manager 12c ASH Analytics
Enterprise Manager 12c ASH AnalyticsEnterprise Manager 12c ASH Analytics
Enterprise Manager 12c ASH Analytics
Gokhan Atil
 
Using APEX to Create a Mobile User Interface for Enterprise Manager 12c
Using APEX to Create a Mobile User Interface for Enterprise Manager 12cUsing APEX to Create a Mobile User Interface for Enterprise Manager 12c
Using APEX to Create a Mobile User Interface for Enterprise Manager 12c
Gokhan Atil
 

More from Gokhan Atil (11)

Introduction to Spark with Python
Introduction to Spark with PythonIntroduction to Spark with Python
Introduction to Spark with Python
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
SQL or noSQL - Oracle Cloud Day Istanbul
SQL or noSQL - Oracle Cloud Day IstanbulSQL or noSQL - Oracle Cloud Day Istanbul
SQL or noSQL - Oracle Cloud Day Istanbul
 
Oracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsOracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAs
 
Essential Linux Commands for DBAs
Essential Linux Commands for DBAsEssential Linux Commands for DBAs
Essential Linux Commands for DBAs
 
TROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yolu
TROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yoluTROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yolu
TROUG & Turkey JUG Semineri: Veriye erişimin en hızlı yolu
 
Oracle 12c Database In Memory DBA SIG
Oracle 12c Database In Memory DBA SIGOracle 12c Database In Memory DBA SIG
Oracle 12c Database In Memory DBA SIG
 
Oracle 12c Database In-Memory
Oracle 12c Database In-MemoryOracle 12c Database In-Memory
Oracle 12c Database In-Memory
 
Oracle DB Standard Edition: Başka Bir Arzunuz?
Oracle DB Standard Edition: Başka Bir Arzunuz?Oracle DB Standard Edition: Başka Bir Arzunuz?
Oracle DB Standard Edition: Başka Bir Arzunuz?
 
Enterprise Manager 12c ASH Analytics
Enterprise Manager 12c ASH AnalyticsEnterprise Manager 12c ASH Analytics
Enterprise Manager 12c ASH Analytics
 
Using APEX to Create a Mobile User Interface for Enterprise Manager 12c
Using APEX to Create a Mobile User Interface for Enterprise Manager 12cUsing APEX to Create a Mobile User Interface for Enterprise Manager 12c
Using APEX to Create a Mobile User Interface for Enterprise Manager 12c
 

Recently uploaded

Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 

Recently uploaded (20)

Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 

Enterprise Manager: Write powerful scripts with EMCLI

  • 2. INTRODUCTION GOKHAN ATIL ▸ DBA Team Lead with 15+ years of experience ▸ Oracle ACE (since 2011) ▸ 10g/11g and R12 OCP ▸ Founding Member and Vice President of TROUG ▸ Co-author of Expert Oracle Enterprise Manager 12c ▸ Blogger (since 2008) gokhanatil.com ▸ Twitter: @gokhanatil 2
  • 3. INTRODUCTION AGENDA ▸ Introduction to EM CLI ▸ EM CLI Verbs ▸ Sample Verbs ▸ Fundamentals of Python ▸ EM CLI and Python ▸ Sample Scripts ▸ Summary 3
  • 5. INTRODUCTION TO EM CLI WHAT IS EM CLI? EMCLI is an alternative for the web interface. It enables you to access OEM functionality from a text-based console. Repository EM CLI Agent OMS Web Console 5
  • 6. INTRODUCTION TO EM CLI ALREADY INSTALLED EM CLI is already installed and configured on OMS server: cd $MIDDLEWARE_HOME/bin ./emcli (or emcli.bat on Windows servers) 6
  • 7. INTRODUCTION TO EM CLI YOU CAN INSTALL EM CLI TO YOUR PC ▸ Requires Java version 1.7.0_80 or greater ▸ Supported Operating Systems: Windows, Linux, Solaris, HPUX, Tru64, AIX ▸ Go to “command line interface” page under “setup” page to download the installation JAR file. ▸ Login is not required to download, so it’s possible to download the JAR file with “wget”. To run EM CLI on Java 1.8 or higher, you need apply patch 17555224 to the weblogic server. Use"-no-check-certificate" parameter with wget. 7
  • 8. INTRODUCTION TO EM CLI EM CLI DOWNLOAD PAGE 8
  • 9. INTRODUCTION TO EM CLI EM CLI STANDARD KIT VS ADVANCED KIT There are two different installation kits for EM CLI: ▸ EM CLI Standard Kit: This kit supports only the Standard (command line) mode. ▸ EM CLI with Scripting mode (option): This “advanced” kit supports Interactive and Script modes in addition to standard mode. 9
  • 10. INTRODUCTION TO EM CLI 3 MODES OF EM CLI: ▸ Standard mode: 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 get_targets ▸ Interactive mode: This mode enables you to create a single interactive session with OMS. It is a Jython shell. emcli ▸ Scripting mode: In Scripting mode, EM CLI runs Jython scripts containing EM CLI verbs. emcli @scriptname.py 10
  • 11. INTRODUCTION TO EM CLI SOMEONE SAID JYTHON? Jython is an implementation of the Python programming language designed to run on the Java platform. 11
  • 12. INTRODUCTION TO EM CLI SO WHAT’S PYTHON? ▸ Widely used general-purpose, 
 high-level programming language ▸ Supports multiple programming paradigms, including OOP, imperative and functional programming ▸ Dynamic type system and automatic memory management ▸ Batteries Included (!) 12
  • 13. INTRODUCTION TO EM CLI INSTALL AND CONFIGURE: ▸ After you download, set JAVA_HOME and install the JAR file: java -jar emcliadvancedkit.jar -install_dir=<home> ▸ Configure EM CLI: emcli help setup emcli setup -url="https://host:port/em" 
 -username=<emuser> -dir=<instancedir> -trustall 13
  • 15. EM CLI VERBS 400+ VERBS IN 75+ CATEGORIES ▸ Add Host Verbs ▸ Agent Administration Verbs ▸ Agent Upgrade Verbs ▸ BI Publisher Reports Verbs ▸ Blackout Verbs ▸ Credential Verbs ▸ Incident Rules Verbs ▸ Job Verbs ▸ Metric Extension Verbs ▸ Monitoring Templates Verbs ▸ Oracle Cloud Verbs ▸ Provisioning Verbs ▸ Self Update Verbs ▸ User Administration Verbs 15
  • 16. EM CLI VERBS GET QUICK HELP You can get the list of available verbs using “help”: emcli help emcli help get_targets 16
  • 17. EM CLI VERBS EM CLI VERBS IN STANDARD MODE In standard mode, EM CLI expect you enter a verb as the first parameter. Verbs may take zero or more arguments as input. emcli verb -1st_argument="value" 
 [ -2nd_ argument="value" ]
 [ -3rd_ argument="value" ] 
 [ -4th_ argument ]
 … 17
  • 18. EM CLI VERBS EM CLI VERBS IN SCRIPTING MODE ▸ Verbs are defined as Python functions ▸ Arguments are entered as function parameters verb( argument_name="value", 2nd_ argument="value") ▸ Results of verbs are formatted as JSON 18
  • 19. SAMPLE VERBS LOGIN Login verb is used to log into Enterprise Manager with the given credentials. login( username="SYSMAN", password="123456", force=true) login( username="SYSMAN", password="123456" ) login( username=“SYSMAN" ) The EM CLI client should be logged in to OMS before other EM CLI verbs are executed. 19
  • 20. SAMPLE VERBS GET_TARGETS get_targets verb lists the targets (their names and their types) which are discovered or monitored by Enterprise Manager. get_targets() get_targets( targets="targetname:targettype" ) get_targets( targets="targetname:%" ) get_targets( targets="targettype" ) get_targets( "unmanaged", targets="targettype" ) Target names, target types and even “verbs” are case sensitive, so be sure that you use the exact name of a target and target type! 20
  • 21. SAMPLE VERBS ADD_TARGET add_target verb adds a target to Enterprise Manager. add_target( name="TESTDB",
 type="oracle_database",
 host="testdb.gokhanatil.com",
 credentials="...", 
 properties="..." ) You must specify any required properties of a target type when adding a new target of this type 21
  • 22. SAMPLE VERBS CLEAR_STATELESS_ALERTS clear_stateless_alerts verb clears the stateless alerts associated with the specified target. Stateless alerts are not cleared automatically by the Enterprise Manager. clear_stateless_alerts( 
 target_name="TESTDB", 
 target_type="oracle_database",
 metric_internal_name="...",
 older_than="0" ) To find the metric internal name associated with a stateless alert, use the get_metrics_for_stateless_alerts verb. 22
  • 23. SAMPLE VERBS UPDATE_DB_PASSWORD update_db_password verb updates the target database password stored in the Enterprise Manager Credential sub-system and can change the password on the target database as well. update_db_password (target_name="TESTDB",
 user_name="DBSNMP",
 target_type="oracle_database",
 change_at_target="yes",
 old_password="oldone",
 new_password="newone",
 retype_new_password="newone" ) 23
  • 24. SAMPLE VERBS LIST ▸ Although there are more than 85+ verbs to help you fetch a specific information from OMS such as list of targets, list of jobs etc, you may still need a more powerful verb which can fetch information from the repository database. ▸ This command will show all resources that you can query: emcli list -help 24
  • 25. SAMPLE VERBS LIST ▸ The following command will list the users defined in EM: emcli list -resource="Administrators" ▸ This command shows the columns of the specified resource: emcli list -resource="Administrators" -help 25
  • 26. SAMPLE VERBS LIST ▸ This command will list the EM users and their last logins: emcli list -resource="Administrators" 
 -columns="USER_NAME,LAST_AUTHENTICATED_TS" ▸ The following command will list the EM users which are logged in at least one time: emcli list -resource="Administrators"
 -columns="USER_NAME,LAST_AUTHENTICATED_TS"
 -search=“LAST_AUTHENTICATED_TS IS NOT NULL" 26
  • 27. SAMPLE VERBS LIST Latest version of the “list” verb can query 30+ resources. If you can not find the data you need among these resources, you can even run SQL on repository database using list verb: emcli list -sql="<query>" You need ACCESS_EMCLI_SQL_LIST_VERB privilege to be able to run query using “the list verb”. 27
  • 29. FUNDAMENTALS OF PYTHON VARIABLES Python supports dynamic type variables. You don’t need to declare a variable but you need to initialise it before you use: ▸ myvar = "TESTDB" ▸ myvar = myvar + ":oracle_database" ▸ myvar = 10 ▸ myvar = myvar + 10 ▸ myvar = 10 + "10" TYPE ERROR: UNSUPPORTED OPERAND TYPE(S) FOR 
 +: 'INT' AND 'STR' 29
  • 30. FUNDAMENTALS OF PYTHON CONVERSIONS You can convert numbers to string using “str” function, and string variables to numbers using “int” function: ‣ myvar = int("2") ‣ myvar = int("5") + 10 ‣ myvar = str(2) ‣ myvar = str(2) + "nd century"
 30
  • 31. FUNDAMENTALS OF PYTHON CONDITIONAL STATEMENTS AND CODE BLOCKS The indented block of code is executed if the condition is true. You should use indents to create code blocks. myvar = int("2")
 myvar = myvar + 10
 myvar = "2" if ( myvar >= 10 ):
 print "myvar is " + str(myvar)
 else:
 print "lower than 10" CODE BLOCKS ARE IDENTIFIED BY “INDENTATION” THE COLON (:) SIGN 31
  • 32. FUNDAMENTALS OF PYTHON DICTIONARY AND LIST OBJECTS Dictionary objects, list objects and iterations: mydict = { 'Name':'Gokhan', 'Age':40 }
 mydict['Name'] = "Gokhan" mylist = ["Joe","William","Jack","Averell"] 
 mylist[0] = "Joe" for i in mylist:
 print i SIMILAR TO
 JSON. KEY=VALUE IT WILL PRINT ALL ELEMENTS IN “MYLIST” ARRAY. USE INDEX TO REACH VALUE 32
  • 33. EM CLI AND PYTHON 33
  • 34. EM CLI AND PYTHON EM CLI RESPONSE OBJECT emcli.response represents the response object which returned from invocation of a emcli verb from python script. emcli.response.Response error() error text
 exit_code() error code (0=success)
 isJson() is JSON? true/false
 out() JSON or text 34
  • 35. EM CLI AND PYTHON EM CLI RESPONSE OBJECT In scripting mode, default output format type is JSON. In interactive mode, to change the output format to JSON, you need to run the following command: set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') It’s recommended to use JSON format because it directly matches with Python “dictionary” object. There’s no need for extra effort to parse the output. 35
  • 36. EM CLI AND PYTHON EM CLI RESPONSE OBJECT Let’s get the response from a verb: mytargets = get_targets( target="oracle_database" ) type(mytargets.out())
 <type 'dict'> mytargets.out() {'data': [{'Status': 'Up', 'Warning': '6', 'Status ID': '0', 'Target Type': 'oracle_database', 'Critical': '64', 'Target Name': 'TESTDB'}, {…}, {…}, {…}] } 36
  • 37. EM CLI AND PYTHON EM CLI RESPONSE OBJECT A response always contain a “data” item which is a list object: type(mytargets.out()['data'])
 <type ‘list'> mytargets.out()['data'] [ {'Status': 'Up', 'Warning': '6', 'Status ID': '0', 'Target Type': 'oracle_database', 'Critical': '64', 'Target Name': 'TESTDB'},{…}, {…}, {…} ] type(mytargets.out()['data'][0])
 <type 'dict'> 37
  • 38. EM CLI AND PYTHON EM CLI RESPONSE OBJECT We can iterate over the items of the list: for DB in mytargets.out()['data']:
 print DB['Target Name'], DB['Status'] DICT / JSON LIST (DATA) DICT DICT DICT DICT DICT 38
  • 40. SAMPLE SCRIPTS CLEAR STATELESS ALERTS Save the following code in a file (clearalerts.py) and run it as “emcli @clearalerts.py”: if login( username="GOKHAN" ).exit_code()==0: mytargets=get_targets( targets="oracle_database" ) for DB in mytargets.out()['data']:
 clear_stateless_alerts( 
 target_name=DB['Target Name'], 
 target_type=DB['Target Type'], older_than="0" ) 40
  • 41. SAMPLE SCRIPTS CHANGE DBSNMP PASSWORDS if len(sys.argv) <> 2:
 print "Usage: emcli @change_dbsnmp_passwords.py oldpwd newpwd"
 exit()
 if login( username="GOKHAN" ).exit_code()==0:
 mytargets=get_targets( targets="%_database" )
 for DB in mytargets.out()['data']:
 try: 
 update_db_password (target_name=DB['Target Name'],
 target_type=DB['Target Type'] ,
 change_at_target="yes",user_name="dbsnmp",
 old_password=sys.argv[0],
 new_password=sys.argv[1],
 retype_new_password=sys.argv[1])
 except emcli.exception.VerbExecutionError, e:
 print e.error() 41
  • 42. SAMPLE SCRIPTS PROMOTE UNMANAGED DATABASES lg = login( username="SYSMAN" ) if lg.exit_code() <> 0:
 print lg.error()
 exit() utargets=get_targets( "unmanaged", properties=True, targets="oracle_database" ) for target in utargets.out()['data']:
 add_target( name=target['Target Name'], type=target['Target Type'],
 host=target['Host Info'].split(';')[0].split(':')[1],
 credentials="UserName:dbsnmp;password:xyz;Role:Normal", 
 properties=target['Properties'] ) POSITIONAL PARAMETERS 42
  • 44. SUMMARY WHY NOT BASH SCRIPTING WITH EM CLI STANDARD KIT? ▸ BASH scripting supports environment variables, if conditions, loops ▸ Linux tools (grep, awk etc…) to parse output of EM CLI ▸ Python is cross-platform ▸ Python scripts are easy to be read and maintain ▸ Python scripts perform better 44
  • 45. SUMMARY FURTHER READING ▸ OEM 12c Command-Line Interface ▸ My blog:
 http://www.gokhanatil.com ▸ Kellyn Pot'Vin-Gorman
 http://dbakevlar.com ▸ Ray Smith
 https://oramanageability.wordpress.com ▸ Seth Miller
 http://sethmiller.org ▸ The Definitive Guide to Jython
 http://www.jython.org/jythonbook/en/1.0/ 45
  • 46. THANK YOU FOR ATTENDING! 
 ANY QUESTIONS? 46