SlideShare a Scribd company logo
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 Active Data Guard: Best Practices and New Features Deep Dive
Oracle Active Data Guard: Best Practices and New Features Deep Dive Oracle Active Data Guard: Best Practices and New Features Deep Dive
Oracle Active Data Guard: Best Practices and New Features Deep Dive
Glen Hawkins
 
Postgresql Database Administration Basic - Day1
Postgresql  Database Administration Basic  - Day1Postgresql  Database Administration Basic  - Day1
Postgresql Database Administration Basic - Day1
PoguttuezhiniVP
 
Oracle GoldenGate 21c New Features and Best Practices
Oracle GoldenGate 21c New Features and Best PracticesOracle GoldenGate 21c New Features and Best Practices
Oracle GoldenGate 21c New Features and Best Practices
Bobby Curtis
 
Python and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super ToolsPython and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super Tools
Seth Miller
 
Running E-Business Suite Database on Oracle Database Appliance
Running E-Business Suite Database on Oracle Database ApplianceRunning E-Business Suite Database on Oracle Database Appliance
Running E-Business Suite Database on Oracle Database Appliance
Maris Elsins
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
SrirakshaSrinivasan2
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8
Frederic Descamps
 
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
 
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
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
Federico Campoli
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
Frederic Descamps
 
Lessons learned from writing over 300,000 lines of infrastructure code
Lessons learned from writing over 300,000 lines of infrastructure codeLessons learned from writing over 300,000 lines of infrastructure code
Lessons learned from writing over 300,000 lines of infrastructure code
Yevgeniy Brikman
 
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and AdministerOracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Andrejs Karpovs
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
Frederic Descamps
 
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIESORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
Ludovico Caldara
 
MySQL Shell for Database Engineers
MySQL Shell for Database EngineersMySQL Shell for Database Engineers
MySQL Shell for Database Engineers
Mydbops
 
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
Kenny Gryp
 
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
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
Saeid Zebardast
 
Comparison of ACFS and DBFS
Comparison of ACFS and DBFSComparison of ACFS and DBFS
Comparison of ACFS and DBFS
DanielHillinger
 

What's hot (20)

Oracle Active Data Guard: Best Practices and New Features Deep Dive
Oracle Active Data Guard: Best Practices and New Features Deep Dive Oracle Active Data Guard: Best Practices and New Features Deep Dive
Oracle Active Data Guard: Best Practices and New Features Deep Dive
 
Postgresql Database Administration Basic - Day1
Postgresql  Database Administration Basic  - Day1Postgresql  Database Administration Basic  - Day1
Postgresql Database Administration Basic - Day1
 
Oracle GoldenGate 21c New Features and Best Practices
Oracle GoldenGate 21c New Features and Best PracticesOracle GoldenGate 21c New Features and Best Practices
Oracle GoldenGate 21c New Features and Best Practices
 
Python and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super ToolsPython and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super Tools
 
Running E-Business Suite Database on Oracle Database Appliance
Running E-Business Suite Database on Oracle Database ApplianceRunning E-Business Suite Database on Oracle Database Appliance
Running E-Business Suite Database on Oracle Database Appliance
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8
 
Oracle 12c and its pluggable databases
Oracle 12c and its pluggable databasesOracle 12c and its pluggable databases
Oracle 12c and its pluggable databases
 
Oracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API ExamplesOracle GoldenGate 18c - REST API Examples
Oracle GoldenGate 18c - REST API Examples
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
Lessons learned from writing over 300,000 lines of infrastructure code
Lessons learned from writing over 300,000 lines of infrastructure codeLessons learned from writing over 300,000 lines of infrastructure code
Lessons learned from writing over 300,000 lines of infrastructure code
 
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and AdministerOracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
Oracle E-Business Suite R12.2.5 on Database 12c: Install, Patch and Administer
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
 
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIESORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
 
MySQL Shell for Database Engineers
MySQL Shell for Database EngineersMySQL Shell for Database Engineers
MySQL Shell for Database Engineers
 
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
 
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
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
 
Comparison of ACFS and DBFS
Comparison of ACFS and DBFSComparison of ACFS and DBFS
Comparison of ACFS and DBFS
 

Similar to EM13c: Write Powerful Scripts with EMCLI

Kscope emcli kpotvin
Kscope emcli kpotvinKscope emcli kpotvin
Kscope emcli kpotvin
Kellyn Pot'Vin-Gorman
 
EMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyEMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG Germany
Gokhan 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 interface2
Kellyn 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 PowerShell
Phan 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 webinar
Petr Baudis
 
Maximize the power of OSGi
Maximize the power of OSGiMaximize the power of OSGi
Maximize the power of OSGi
David 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 Bosschaert
mfrancis
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
Power shell training
Power shell trainingPower shell training
Power shell training
David Brabant
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
Salaudeen 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 Evil
jaredhaight
 
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
Binh Nguyen
 
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
 

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

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
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
 
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
 
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
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
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
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
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
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 

Recently uploaded (20)

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
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
 
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...
 
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
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
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...
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
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
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 

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?