SlideShare a Scribd company logo
1 of 34
Download to read offline
ORACLE ENTERPRISE MANAGER

WRITE POWERFUL SCRIPTS
WITH EMCLI
Gökhan Atıl
GÖKHAN ATIL
➤ DBA Team Lead with 15+ years of experience
➤ Oracle ACE Director (2016)

ACE (2011)
➤ 10g/11g and R12 OCP
➤ Founding Member and Vice President of TROUG
➤ Blogger (since 2008) gokhanatil.com
➤ Twitter: @gokhanatil
➤ Co-author of “Expert Oracle Enterprise Manager 12c”
AGENDA
➤ Introduction to EMCLI
➤ EMCLI Verbs
➤ How much Python do I need to know? (Python Cheatsheet)
➤ Sample Scripts
➤ Further Reading
EMCLI is an alternative for the web interface. It enables you to access OEM functionality from
a text-based console.
WHAT IS EMCLI?
Repository
EMCLI
Agents
Web Console
Management Server
Connectors
ALREADY INSTALLED
EMCLI is already installed and configured on OMS server:
$OMS_HOME/bin/emcli
INSTALL EMCLI TO YOUR WORKSTATION
➤ Requires Java version 1.7.0_80 or greater
➤ Supported: Windows, Linux, Solaris, HPUX, Tru64, AIX
➤ Setup >> Command Line Interface
To run EMCLI on Java 1.8 or higher, you need apply patch 17555224 to the weblogic server.
EMCLI with Scripting Mode aka ADVANCED KIT
INSTALL AND CONFIGURE
➤ Download the JAR file, set JAVA_HOME and execute the JAR file:
java -jar emcliadvancedkit.jar -install_dir=<home>
➤ Configure EM CLI:
emcli setup -url="https://host:port/em" -username=<emuser> -trustall
WHY ADVANCED KIT?
➤ 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, EMCLI runs Jython scripts containing EMCLI
verbs.
emcli @scriptname.py
Jython is an implementation of the Python designed to run on the Java
EMCLI VERBS
and Python
EMCLI VERBS
➤ A verb is a task or action in the form of a user command that exposes Enterprise
Manager functionality.
➤ In Standard mode, EMCLI 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" ]

[ -3th_ argument ]
➤ In Scripting mode, EMCLI verbs are defined as Python functions, and arguments
are entered as function parameters:
verb( 1st_argument="value", 2nd_ argument="value")
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
GET QUICK HELP
You can get the list of available verbs using “help”:
emcli help
emcli help get_targets
➤ EMCLI verbs returns emcli.response.Response object:
result = emcli.response.Response
.error()

.exit_code()

.isJson()

.out()
➤ In scripting mode, default output format type is JSON for the verbs resulting a list of
items. In interactive mode, to change the output format to JSON, you need to run the
following command:
set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
JSON - DICT
EMCLI RESPONSE OBJECT
error text

error code (0=success)

is JSON? true/false

JSON or text
[“data”] - LIST
DICT
DICT
DICT
result.out():

{ 'data':
[{'Status': 'Up', 'Warning': '2', 'Status ID': '1',
'Target Type': 'oracle_database', 'Critical':
'1', 'Target Name': 'db000002'},
{'Status': 'Up', 'Warning': '2', 'Status ID': '1',
'Target Type': 'oracle_database', 'Critical': '2',
'Target Name': 'db000001'},
{'Status': 'Up', 'Warning': '2', 'Status ID': '1',
'Target Type': 'oracle_database', 'Critical': '0',
'Target Name': 'db000000'}] }
PYTHON DICTIONARY AND LIST OBJECTS, AND EMCLI RESPONSE
List:

L = [1000,1001,1002,1003]
L[0] is 1000
Dictionary:
D = { "keyA": "red", "keyB": "green" }
D["keyA"] is "red"
Dict containing List containing Dict:
R = { "car":
[ { "brand", "BMW" }, { "brand", "Audi" } ] }
R["car"][0]["brand"] is "BMW"
result.out()["data"][0]
HOW MUCH PYTHON DO I NEED TO KNOW?
➤ Variables (Scalar, List, Dictionary)
No = 10
Name = "Gokhan"
➤ Conditionals
if A == 10:
do_something_good
do_another_good_thing
➤ Loops
for A in list:
print A
➤ Various
print "LOWERCASE".lower()
print "uppercase".upper()
print "Henry " + str(5) + "th"
print 10 + int("5")
print "dbname;orcltest".split(";")
exit()
SAMPLE SCRIPTS
LET’S WRITE OUR FIRST EMCLI SCRIPT!
➤ Goal: Clear stateless alerts of all database targets
➤ Login to OMS (The EMCLI client should be logged in to OMS before executing other
EMCLI verbs)
login( username="GOKHAN", password="123456" )
➤ Get list of all database targets
get_targets( target="oracle_database" )
➤ Clear stateless alert of each database target
clear_stateless_alerts( target_name, target_type, older_than )
➤ Logout
logout()
.out()["data"]
loop
CLEAR STATELESS ALERTS
clearalerts.py
if login( username="GOKHAN", password="123456" ).exit_code()==0:
for target in get_targets( targets="oracle_database" ).out()["data"]:
print "Clearing stateless alerts for " + target["Target Name"]
clear_stateless_alerts(target_name= target["Target Name"],
target_type= target["Target Type"], older_than="0" )
logout()
SAMPLE EMCLI SCRIPT #2
➤ Goal: Apply default host template to all host targets
➤ Login to OMS
➤ Get list of all host templates to find the default template
list_templates(target_type="host")
➤ If it's "default" template, assign it to a variable
➤ Get list of all host targets
get_targets(target="hosts" ).out()["data"]
➤ Apply host tempate to all hosts
apply_template( name, targets, replace_metrics)
➤ Logout
loop
loop
APPLY DEFAULT TEMPLATE TO ALL HOSTS
applyhosttemplate.py
if login( username="GOKHAN", password="123456" ).exit_code()==0:
for template in list_templates( target_type="host" ).out()["data"]:
if template["Default Template"] == "yes":
defaulttemplate = template["Template Name"]
for host in get_targets( targets="host").out()["data"]:
apply_template( name=defaulttemplate, replace_metrics="1",
targets=host["Target Name"] + ":host")
logout()
APPLY DEFAULT TEMPLATE TO ALL HOSTS
applyhosttemplate.py
if login( username="GOKHAN", password="123456" ).exit_code()==0:
for template in list_templates( target_type="host" ).out()["data"]:
if template["Default Template"] == "yes":
defaulttemplate = template["Template Name"]
print defaulttemplate + " will be applied to the following hosts:"
for host in get_targets( targets="host").out()["data"]:
apply_template( name=defaulttemplate, replace_metrics="1",
targets=host["Target Name"] + ":host")
print host["Target Name"]
logout()
SAMPLE EMCLI SCRIPT #3
➤ Goal: Promote all discovered (but unmanaged) single database targets
➤ Login to OMS
➤ Get list of all unmanaged targets (with properties)
get_targets("unmanaged","properties",

target="oracle_database" ).out()["data"]
➤ Parse Hostname from host info
host:db01.server.com;timezone_region:Europe/Istanbul
➤ Promote the database target
add_target( name, type, host, properties,

credentials="UserName:dbsnmp;password:xyz;Role:Normal")
➤ Logout
loop
PROMOTE DATABASE TARGETS
promotetargets.py
if login( username="GOKHAN", password="mypassword" ).exit_code()==0:
for target in get_targets("unmanaged","properties",
targets="oracle_database").out()["data"]:
add_target( name=target['Target Name'], type=target['Target Type'],
host=target['Host Info'],
properties=target['Properties'],
credentials="UserName:dbsnmp;password:xyz;Role:Normal")
logout()
PROMOTE DATABASE TARGETS (PARSING HOSTNAME)
PROMOTE DATABASE TARGETS
promotetargets.py
if login( username="GOKHAN", password="mypassword" ).exit_code()==0:
for target in get_targets("unmanaged","properties",
targets="oracle_database").out()["data"]:
print "Promoting " + target['Target Name']
add_target( name=target['Target Name'], type=target['Target Type'],
host=target['Host Info'].split(';')[0].split(':')[1],
properties=target['Properties'],
credentials="UserName:dbsnmp;password:xyz;Role:Normal")
logout()
SAMPLE EMCLI SCRIPT #4
➤ Goal: Change DBSMP (database user) passwords of all database targets
➤ Login to OMS
➤ Get list of all database targets
get_targets( target="oracle_database" ).out()["data"]
➤ Update DBSNMP user password
update_db_password(target_name,target_type, user_name,

change_at_target, old_password, new_password

retype_new_password)
➤ Logout
➤ Optional: Read old and new password from command line
➤ Optional: Catch Exceptions (in case, user entered wrong password)
loop
CHANGE DBSNMP PASSWORDS
changedbsnmp.py
if login( username="GOKHAN", password="123456" ).exit_code()==0:
for db in get_targets( targets="oracle_database").out()["data"]:
update_db_password (target_name= db["Target Name"],
target_type= db["Target Type"],
change_at_target="yes", user_name="dbsnmp",
old_password="oldpassword",
new_password="newpassword", retype_new_password="newpassword")
logout()
secure programming!?
CHANGE DBSNMP PASSWORDS
changedbsnmp.py
if len(sys.argv) <> 2:
print "Usage: emcli @changedbsnmp.py oldpwd newpwd"
exit()
if login( username="GOKHAN", password="123456" ).exit_code()==0:
for db in get_targets( targets="oracle_database").out()["data"]:
print "Updating dbsnmp password on " + db["Target Name"]
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])
logout()
CHANGE DBSNMP PASSWORDS
changedbsnmp.py
if len(sys.argv) <> 2:
print "Usage: emcli @changedbsnmp.py oldpwd newpwd"
exit()
if login( username="GOKHAN", password="mypassword" ).exit_code()==0:
for db in get_targets( targets="oracle_database").out()["data"]:
try:
print "Updating dbsnmp password on " + db["Target Name"]
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()
logout()
exception block
SAMPLE EMCLI SCRIPT #5
➤ Goal: List databases running on a specific Operating System
➤ Read OS name from run parameters
➤ Login to OMS
➤ Get list of all database targets from the Targets resource
list( resource="Targets", search ).out()["data"]
➤ Find the OS information from the Targets resource (will return one row)
list( resource="Targets", search ).out()["data"][0]
➤ Compare OS names and print target info if they match
➤ Logout
loop
LIST
➤ Lists avaliable "resources" (data sources/management views)
emcli list -help or list( "help" )
➤ Lists columns of a resource
emcli list -resource="Targets" -help
or list( "help", resource="Targets" ) or list( resource="Targets", help=True )
➤ Selection and Projection
list( resource="Targets",columns="TARGET_NAME,TARGET_TYPE",

search="TARGET_TYPE='oracle_database'")
➤ Run SQL query
list( "select * from mgmt$target where target_type='oracle_database'" )
LIST DATABASES
listdatabases.py
if (len(sys.argv) <> 1 ):
print "Usage: emcli @list_targets.py OSname"
exit()
if login( username="gokhan", password="123456" ).exit_code()==0:
for db in list( resource="Targets", search="TARGET_TYPE='oracle_database'" ).out()['data']:
OS = list( resource="Targets",
search="TARGET_NAME='" + db['HOST_NAME'] + "'" ).out()['data'][0]['TYPE_QUALIFIER1']
if ( OS.lower() == sys.argv[0].lower() ):
print db['TARGET_NAME'], OS
logout()
FURTHER READING
➤ Oracle Enterprise Manager 12c Command-Line Interface

by Kellyn Pot'vin-Gorman, Seth Miller, Ray Smith
➤ My blog: http://www.gokhanatil.com
➤ Ray Smith https://oramanageability.wordpress.com
➤ Kellyn Pot’Vin-Gorman http://dbakevlar.com
➤ Python For Beginners https://www.python.org/about/gettingstarted/
➤ The Definitive Guide to Jython http://www.jython.org/jythonbook/en/1.0/
THANK YOU FOR ATTENDING!
ANY QUESTIONS?

More Related Content

What's hot

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 DBAsGokhan Atil
 
Oracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API ExamplesOracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API ExamplesBobby Curtis
 
How to be a Postgres DBA in a Pinch
How to be a Postgres DBA in a Pinch How to be a Postgres DBA in a Pinch
How to be a Postgres DBA in a Pinch ElizabethGarrettChri
 
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 CourseGokhan Atil
 
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 19cMaria Colgan
 
Adop and maintenance task presentation 151015
Adop and maintenance task presentation 151015Adop and maintenance task presentation 151015
Adop and maintenance task presentation 151015andreas kuncoro
 
HA, Scalability, DR & MAA in Oracle Database 21c - Overview
HA, Scalability, DR & MAA in Oracle Database 21c - OverviewHA, Scalability, DR & MAA in Oracle Database 21c - Overview
HA, Scalability, DR & MAA in Oracle Database 21c - OverviewMarkus Michalewicz
 
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 1Satishbabu Gunukula
 
Snowflake: The most cost-effective agile and scalable data warehouse ever!
Snowflake: The most cost-effective agile and scalable data warehouse ever!Snowflake: The most cost-effective agile and scalable data warehouse ever!
Snowflake: The most cost-effective agile and scalable data warehouse ever!Visual_BI
 
Blue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQL
Blue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQLBlue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQL
Blue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQLBlue Medora
 
Less06 networking
Less06 networkingLess06 networking
Less06 networkingAmit Bhalla
 
Why oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19cWhy oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19cSatishbabu Gunukula
 
AIOUG-GroundBreakers-Jul 2019 - 19c RAC
AIOUG-GroundBreakers-Jul 2019 - 19c RACAIOUG-GroundBreakers-Jul 2019 - 19c RAC
AIOUG-GroundBreakers-Jul 2019 - 19c RACSandesh Rao
 
Oracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsOracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsAnil Nair
 
Oracle database high availability solutions
Oracle database high availability solutionsOracle database high availability solutions
Oracle database high availability solutionsKirill Loifman
 
Oracle 12c PDB insights
Oracle 12c PDB insightsOracle 12c PDB insights
Oracle 12c PDB insightsKirill Loifman
 
Automate the operation of your Oracle Cloud infrastructure v2.0
Automate the operation of your Oracle Cloud infrastructure v2.0Automate the operation of your Oracle Cloud infrastructure v2.0
Automate the operation of your Oracle Cloud infrastructure v2.0Nelson Calero
 
Oracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System AdministrationOracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System AdministrationMozammel Hoque
 
Clone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13c
Clone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13cClone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13c
Clone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13cAlfredo Krieg
 

What's hot (20)

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
 
Oracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API ExamplesOracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API Examples
 
How to be a Postgres DBA in a Pinch
How to be a Postgres DBA in a Pinch How to be a Postgres DBA in a Pinch
How to be a Postgres DBA in a Pinch
 
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
 
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
 
Adop and maintenance task presentation 151015
Adop and maintenance task presentation 151015Adop and maintenance task presentation 151015
Adop and maintenance task presentation 151015
 
HA, Scalability, DR & MAA in Oracle Database 21c - Overview
HA, Scalability, DR & MAA in Oracle Database 21c - OverviewHA, Scalability, DR & MAA in Oracle Database 21c - Overview
HA, Scalability, DR & MAA in Oracle Database 21c - Overview
 
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
 
Snowflake: The most cost-effective agile and scalable data warehouse ever!
Snowflake: The most cost-effective agile and scalable data warehouse ever!Snowflake: The most cost-effective agile and scalable data warehouse ever!
Snowflake: The most cost-effective agile and scalable data warehouse ever!
 
Blue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQL
Blue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQLBlue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQL
Blue Medora Oracle Enterprise Manager (EM12c) Plug-in for PostgreSQL
 
Less06 networking
Less06 networkingLess06 networking
Less06 networking
 
Why oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19cWhy oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19c
 
AIOUG-GroundBreakers-Jul 2019 - 19c RAC
AIOUG-GroundBreakers-Jul 2019 - 19c RACAIOUG-GroundBreakers-Jul 2019 - 19c RAC
AIOUG-GroundBreakers-Jul 2019 - 19c RAC
 
Oracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsOracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret Internals
 
Oracle database high availability solutions
Oracle database high availability solutionsOracle database high availability solutions
Oracle database high availability solutions
 
Oracle Data Integrator
Oracle Data Integrator Oracle Data Integrator
Oracle Data Integrator
 
Oracle 12c PDB insights
Oracle 12c PDB insightsOracle 12c PDB insights
Oracle 12c PDB insights
 
Automate the operation of your Oracle Cloud infrastructure v2.0
Automate the operation of your Oracle Cloud infrastructure v2.0Automate the operation of your Oracle Cloud infrastructure v2.0
Automate the operation of your Oracle Cloud infrastructure v2.0
 
Oracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System AdministrationOracle EBS R12.2 - Deployment and System Administration
Oracle EBS R12.2 - Deployment and System Administration
 
Clone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13c
Clone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13cClone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13c
Clone Oracle Databases In Minutes Without Risk Using Enterprise Manager 13c
 

Similar to EM13c: Write Powerful Scripts with EMCLI

EMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyEMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyGokhan Atil
 
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 interface2Kellyn Pot'Vin-Gorman
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellPhan Hien
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009rsnarayanan
 
Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)ÇözümPARK
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Knoldus Inc.
 
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Neelkanth Sachdeva
 
Cognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinarCognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinarPetr Baudis
 
Maximize the power of OSGi
Maximize the power of OSGiMaximize the power of OSGi
Maximize the power of OSGiDavid Bosschaert
 
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
Maximise the Power of OSGi - Carsten Ziegeler & David BosschaertMaximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaertmfrancis
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubEssam Salah
 
Power shell training
Power shell trainingPower shell training
Power shell trainingDavid Brabant
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellSalaudeen Rajack
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Eviljaredhaight
 
Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Binh Nguyen
 
The enterprise manager command line interface2
The enterprise manager command line interface2The enterprise manager command line interface2
The enterprise manager command line interface2Kellyn Pot'Vin-Gorman
 

Similar to EM13c: Write Powerful Scripts with EMCLI (20)

Kscope emcli kpotvin
Kscope emcli kpotvinKscope emcli kpotvin
Kscope emcli kpotvin
 
EMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyEMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG Germany
 
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
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShell
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009
 
Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)
 
Sa
SaSa
Sa
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
 
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
 
Cognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinarCognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinar
 
Maximize the power of OSGi
Maximize the power of OSGiMaximize the power of OSGi
Maximize the power of OSGi
 
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
Maximise the Power of OSGi - Carsten Ziegeler & David BosschaertMaximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
 
Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010
 
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
 

More from Gokhan Atil

Introduction to Spark with Python
Introduction to Spark with PythonIntroduction to Spark with Python
Introduction to Spark with PythonGokhan Atil
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to CassandraGokhan 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 IstanbulGokhan Atil
 
Essential Linux Commands for DBAs
Essential Linux Commands for DBAsEssential Linux Commands for DBAs
Essential Linux Commands for DBAsGokhan 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ı yoluGokhan 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 SIGGokhan Atil
 
Oracle 12c Database In-Memory
Oracle 12c Database In-MemoryOracle 12c Database In-Memory
Oracle 12c Database In-MemoryGokhan 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 AnalyticsGokhan 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 12cGokhan Atil
 

More from Gokhan Atil (10)

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

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 

Recently uploaded (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 

EM13c: Write Powerful Scripts with EMCLI

  • 1. ORACLE ENTERPRISE MANAGER
 WRITE POWERFUL SCRIPTS WITH EMCLI Gökhan Atıl
  • 2. GÖKHAN ATIL ➤ DBA Team Lead with 15+ years of experience ➤ Oracle ACE Director (2016)
 ACE (2011) ➤ 10g/11g and R12 OCP ➤ Founding Member and Vice President of TROUG ➤ Blogger (since 2008) gokhanatil.com ➤ Twitter: @gokhanatil ➤ Co-author of “Expert Oracle Enterprise Manager 12c”
  • 3. AGENDA ➤ Introduction to EMCLI ➤ EMCLI Verbs ➤ How much Python do I need to know? (Python Cheatsheet) ➤ Sample Scripts ➤ Further Reading
  • 4. EMCLI is an alternative for the web interface. It enables you to access OEM functionality from a text-based console. WHAT IS EMCLI? Repository EMCLI Agents Web Console Management Server Connectors
  • 5. ALREADY INSTALLED EMCLI is already installed and configured on OMS server: $OMS_HOME/bin/emcli
  • 6. INSTALL EMCLI TO YOUR WORKSTATION ➤ Requires Java version 1.7.0_80 or greater ➤ Supported: Windows, Linux, Solaris, HPUX, Tru64, AIX ➤ Setup >> Command Line Interface To run EMCLI on Java 1.8 or higher, you need apply patch 17555224 to the weblogic server. EMCLI with Scripting Mode aka ADVANCED KIT
  • 7. INSTALL AND CONFIGURE ➤ Download the JAR file, set JAVA_HOME and execute the JAR file: java -jar emcliadvancedkit.jar -install_dir=<home> ➤ Configure EM CLI: emcli setup -url="https://host:port/em" -username=<emuser> -trustall
  • 8. WHY ADVANCED KIT? ➤ 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, EMCLI runs Jython scripts containing EMCLI verbs. emcli @scriptname.py Jython is an implementation of the Python designed to run on the Java
  • 10. EMCLI VERBS ➤ A verb is a task or action in the form of a user command that exposes Enterprise Manager functionality. ➤ In Standard mode, EMCLI 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" ]
 [ -3th_ argument ] ➤ In Scripting mode, EMCLI verbs are defined as Python functions, and arguments are entered as function parameters: verb( 1st_argument="value", 2nd_ argument="value")
  • 11. 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
  • 12. GET QUICK HELP You can get the list of available verbs using “help”: emcli help emcli help get_targets
  • 13. ➤ EMCLI verbs returns emcli.response.Response object: result = emcli.response.Response .error()
 .exit_code()
 .isJson()
 .out() ➤ In scripting mode, default output format type is JSON for the verbs resulting a list of items. In interactive mode, to change the output format to JSON, you need to run the following command: set_client_property('EMCLI_OUTPUT_TYPE', 'JSON') JSON - DICT EMCLI RESPONSE OBJECT error text
 error code (0=success)
 is JSON? true/false
 JSON or text [“data”] - LIST DICT DICT DICT
  • 14. result.out():
 { 'data': [{'Status': 'Up', 'Warning': '2', 'Status ID': '1', 'Target Type': 'oracle_database', 'Critical': '1', 'Target Name': 'db000002'}, {'Status': 'Up', 'Warning': '2', 'Status ID': '1', 'Target Type': 'oracle_database', 'Critical': '2', 'Target Name': 'db000001'}, {'Status': 'Up', 'Warning': '2', 'Status ID': '1', 'Target Type': 'oracle_database', 'Critical': '0', 'Target Name': 'db000000'}] } PYTHON DICTIONARY AND LIST OBJECTS, AND EMCLI RESPONSE List:
 L = [1000,1001,1002,1003] L[0] is 1000 Dictionary: D = { "keyA": "red", "keyB": "green" } D["keyA"] is "red" Dict containing List containing Dict: R = { "car": [ { "brand", "BMW" }, { "brand", "Audi" } ] } R["car"][0]["brand"] is "BMW" result.out()["data"][0]
  • 15. HOW MUCH PYTHON DO I NEED TO KNOW? ➤ Variables (Scalar, List, Dictionary) No = 10 Name = "Gokhan" ➤ Conditionals if A == 10: do_something_good do_another_good_thing ➤ Loops for A in list: print A ➤ Various print "LOWERCASE".lower() print "uppercase".upper() print "Henry " + str(5) + "th" print 10 + int("5") print "dbname;orcltest".split(";") exit()
  • 17. LET’S WRITE OUR FIRST EMCLI SCRIPT! ➤ Goal: Clear stateless alerts of all database targets ➤ Login to OMS (The EMCLI client should be logged in to OMS before executing other EMCLI verbs) login( username="GOKHAN", password="123456" ) ➤ Get list of all database targets get_targets( target="oracle_database" ) ➤ Clear stateless alert of each database target clear_stateless_alerts( target_name, target_type, older_than ) ➤ Logout logout() .out()["data"] loop
  • 18. CLEAR STATELESS ALERTS clearalerts.py if login( username="GOKHAN", password="123456" ).exit_code()==0: for target in get_targets( targets="oracle_database" ).out()["data"]: print "Clearing stateless alerts for " + target["Target Name"] clear_stateless_alerts(target_name= target["Target Name"], target_type= target["Target Type"], older_than="0" ) logout()
  • 19. SAMPLE EMCLI SCRIPT #2 ➤ Goal: Apply default host template to all host targets ➤ Login to OMS ➤ Get list of all host templates to find the default template list_templates(target_type="host") ➤ If it's "default" template, assign it to a variable ➤ Get list of all host targets get_targets(target="hosts" ).out()["data"] ➤ Apply host tempate to all hosts apply_template( name, targets, replace_metrics) ➤ Logout loop loop
  • 20. APPLY DEFAULT TEMPLATE TO ALL HOSTS applyhosttemplate.py if login( username="GOKHAN", password="123456" ).exit_code()==0: for template in list_templates( target_type="host" ).out()["data"]: if template["Default Template"] == "yes": defaulttemplate = template["Template Name"] for host in get_targets( targets="host").out()["data"]: apply_template( name=defaulttemplate, replace_metrics="1", targets=host["Target Name"] + ":host") logout()
  • 21. APPLY DEFAULT TEMPLATE TO ALL HOSTS applyhosttemplate.py if login( username="GOKHAN", password="123456" ).exit_code()==0: for template in list_templates( target_type="host" ).out()["data"]: if template["Default Template"] == "yes": defaulttemplate = template["Template Name"] print defaulttemplate + " will be applied to the following hosts:" for host in get_targets( targets="host").out()["data"]: apply_template( name=defaulttemplate, replace_metrics="1", targets=host["Target Name"] + ":host") print host["Target Name"] logout()
  • 22. SAMPLE EMCLI SCRIPT #3 ➤ Goal: Promote all discovered (but unmanaged) single database targets ➤ Login to OMS ➤ Get list of all unmanaged targets (with properties) get_targets("unmanaged","properties",
 target="oracle_database" ).out()["data"] ➤ Parse Hostname from host info host:db01.server.com;timezone_region:Europe/Istanbul ➤ Promote the database target add_target( name, type, host, properties,
 credentials="UserName:dbsnmp;password:xyz;Role:Normal") ➤ Logout loop
  • 23. PROMOTE DATABASE TARGETS promotetargets.py if login( username="GOKHAN", password="mypassword" ).exit_code()==0: for target in get_targets("unmanaged","properties", targets="oracle_database").out()["data"]: add_target( name=target['Target Name'], type=target['Target Type'], host=target['Host Info'], properties=target['Properties'], credentials="UserName:dbsnmp;password:xyz;Role:Normal") logout()
  • 24. PROMOTE DATABASE TARGETS (PARSING HOSTNAME)
  • 25. PROMOTE DATABASE TARGETS promotetargets.py if login( username="GOKHAN", password="mypassword" ).exit_code()==0: for target in get_targets("unmanaged","properties", targets="oracle_database").out()["data"]: print "Promoting " + target['Target Name'] add_target( name=target['Target Name'], type=target['Target Type'], host=target['Host Info'].split(';')[0].split(':')[1], properties=target['Properties'], credentials="UserName:dbsnmp;password:xyz;Role:Normal") logout()
  • 26. SAMPLE EMCLI SCRIPT #4 ➤ Goal: Change DBSMP (database user) passwords of all database targets ➤ Login to OMS ➤ Get list of all database targets get_targets( target="oracle_database" ).out()["data"] ➤ Update DBSNMP user password update_db_password(target_name,target_type, user_name,
 change_at_target, old_password, new_password
 retype_new_password) ➤ Logout ➤ Optional: Read old and new password from command line ➤ Optional: Catch Exceptions (in case, user entered wrong password) loop
  • 27. CHANGE DBSNMP PASSWORDS changedbsnmp.py if login( username="GOKHAN", password="123456" ).exit_code()==0: for db in get_targets( targets="oracle_database").out()["data"]: update_db_password (target_name= db["Target Name"], target_type= db["Target Type"], change_at_target="yes", user_name="dbsnmp", old_password="oldpassword", new_password="newpassword", retype_new_password="newpassword") logout() secure programming!?
  • 28. CHANGE DBSNMP PASSWORDS changedbsnmp.py if len(sys.argv) <> 2: print "Usage: emcli @changedbsnmp.py oldpwd newpwd" exit() if login( username="GOKHAN", password="123456" ).exit_code()==0: for db in get_targets( targets="oracle_database").out()["data"]: print "Updating dbsnmp password on " + db["Target Name"] 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]) logout()
  • 29. CHANGE DBSNMP PASSWORDS changedbsnmp.py if len(sys.argv) <> 2: print "Usage: emcli @changedbsnmp.py oldpwd newpwd" exit() if login( username="GOKHAN", password="mypassword" ).exit_code()==0: for db in get_targets( targets="oracle_database").out()["data"]: try: print "Updating dbsnmp password on " + db["Target Name"] 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() logout() exception block
  • 30. SAMPLE EMCLI SCRIPT #5 ➤ Goal: List databases running on a specific Operating System ➤ Read OS name from run parameters ➤ Login to OMS ➤ Get list of all database targets from the Targets resource list( resource="Targets", search ).out()["data"] ➤ Find the OS information from the Targets resource (will return one row) list( resource="Targets", search ).out()["data"][0] ➤ Compare OS names and print target info if they match ➤ Logout loop
  • 31. LIST ➤ Lists avaliable "resources" (data sources/management views) emcli list -help or list( "help" ) ➤ Lists columns of a resource emcli list -resource="Targets" -help or list( "help", resource="Targets" ) or list( resource="Targets", help=True ) ➤ Selection and Projection list( resource="Targets",columns="TARGET_NAME,TARGET_TYPE",
 search="TARGET_TYPE='oracle_database'") ➤ Run SQL query list( "select * from mgmt$target where target_type='oracle_database'" )
  • 32. LIST DATABASES listdatabases.py if (len(sys.argv) <> 1 ): print "Usage: emcli @list_targets.py OSname" exit() if login( username="gokhan", password="123456" ).exit_code()==0: for db in list( resource="Targets", search="TARGET_TYPE='oracle_database'" ).out()['data']: OS = list( resource="Targets", search="TARGET_NAME='" + db['HOST_NAME'] + "'" ).out()['data'][0]['TYPE_QUALIFIER1'] if ( OS.lower() == sys.argv[0].lower() ): print db['TARGET_NAME'], OS logout()
  • 33. FURTHER READING ➤ Oracle Enterprise Manager 12c Command-Line Interface
 by Kellyn Pot'vin-Gorman, Seth Miller, Ray Smith ➤ My blog: http://www.gokhanatil.com ➤ Ray Smith https://oramanageability.wordpress.com ➤ Kellyn Pot’Vin-Gorman http://dbakevlar.com ➤ Python For Beginners https://www.python.org/about/gettingstarted/ ➤ The Definitive Guide to Jython http://www.jython.org/jythonbook/en/1.0/
  • 34. THANK YOU FOR ATTENDING! ANY QUESTIONS?