This document provides an overview of the Oracle Enterprise Manager Command Line Interface (EM CLI).
It discusses the different modes of EM CLI including standard, interactive, and scripting modes. It also covers EM CLI verbs, formatting output, fetching information from the EM repository, and provides examples of Bash and Python scripts using EM CLI.
Sample scripts demonstrated include clearing stateless alerts, changing database passwords, and promoting unmanaged databases to managed targets. Fundamentals of Python programming are also introduced for effective EM CLI scripting.
There are a lot of tasks in Oracle world which would not be possible without a programming languages. Shell scripting can be applied to a wide variety of system and database tasks. In my presentation I will share advanced shell scripting techniques on real life customer success story migrating users from on premise Oracle Internet Directory (OID) instance to AWS OID instance. Migration with standard OID provided tools was not possible due to specific customer requirements. Therefore shell scripting came to achieve desired goals. I`ll give deep overview about issues faced during the scripting, troubleshooting techniques used, scripting performance aspects and solutions applied to make efficient user migration possible.
There are a lot of tasks in Oracle world which would not be possible without a programming languages. Shell scripting can be applied to a wide variety of system and database tasks. In my presentation I will share advanced shell scripting techniques on real life customer success story migrating users from on premise Oracle Internet Directory (OID) instance to AWS OID instance. Migration with standard OID provided tools was not possible due to specific customer requirements. Therefore shell scripting came to achieve desired goals. I`ll give deep overview about issues faced during the scripting, troubleshooting techniques used, scripting performance aspects and solutions applied to make efficient user migration possible.
Too many of us have been taught that views are nothing more than stored SQL statements. The goal of this presentation is to challenge this notion. Or, to be precise, to take you one step further, from technicalities to the huge role that well-designed views can play in contemporary database solutions.
Current views are very advanced. They can be built on top of user-defined functions; they can utilize extremely complex INSTEAD-OF triggers (including composite ones), and they can even have indexes! As a result, with all of this added functionality views can serve as an isolation level between UI-driven data representation (heavily denormalized and customized) and DBA-driven data representation (normalized with referential integrity constraints and foreign keys).
Contemporary IT solutions often take this transformation completely out of the database, usually moving it to the middle-tier. This presentation will show that keeping business logic IN the database provides you with much greater flexibility, manageability, and performance. Of course, there are some traps and pitfalls, but these are also avoidable. Real-world examples will be provided to show that the role of views is seriously underestimated.
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...Michael Rosenblum
In any large ecosystem, there are always areas that stay in the twilight, outside of the public’s attention. This deep dive attempts to change the trend regarding two, at first glance, unrelated PL/SQL topics: hierarchical profiler (HProf) and database triggers. But if you look closer, there’s something in common: they’re significantly underused! HProf because nobody heard about it, database triggers because of decades-old stigma. Let’s put both of them back into our development toolset!
Part #1. One of the most critical FREE SQL and PL/SQL performance tuning tools is almost totally unknown! If you ask, how much time is spent on routine A? How often is function B called? Most developers would hand-code something instead of using the Oracle PL/SQL HProf. This isn’t because the provided functionality is disliked, but because developers aren’t aware of its existence! This presentation is an attempt to alter this trend and reintroduce HProf to a wider audience.
Part #2. There isn’t anything “evil” about database triggers; they just have to be used where they can actually solve problems. In this presentation, various kinds of triggers will be examined from a global system optimization view, including tradeoffs between multiple goals (e.g., depending upon the available hardware, developers can select either CPU-intensive or I/O-intensive solutions). This presentation will focus on the most common performance problems related to different kinds of DML triggers and the proper ways of resolving them.
Woo hoo!
18c Qualified expressions for collections and records
Whitelisting with the ACCESSIBLE_BY Clause
More PL/SQL-Only Data Types Cross PL/SQL-to-SQL Interface
Optimizing Function Execution in SQL
The UTL_CALL_STACK Package
Privileges/Access Management for Program Units
Static Expressions In Place of Literals
Marking elements for deprecation
PL/Scope now includes SQL statements in its analysis
탑크리에듀교육센터(http://www.topcredu.co.kr)에서 제공하는
스프링프레임워크 & 마이바티스(Spring Framework, MyBatis)교육강좌입니다. Spring DI(Dependency Injection),세터 주입(Setter Injection) – XML 기반, 어노테이션기반 등에 대하여 설명한 교육자료이니 참고 바랍니다^^.
If you use scripting languages to power web, mobile, and/or enterprise applications, this session will show you how to use Oracle Database efficiently. It demonstrates how PHP can take full advantage of new performance, scalability, availability, and security features in Oracle Database 12c and Oracle Linux. Many of these features are available to other C-based scripting languages too, like Ruby, Python and Perl. DBA's will also benefit by seeing how applications can be monitored.
common_schema, DBA's framework for MySQLShlomi Noach
An introduction to common_schema, looking at the concepts behind the project and some notable features.
Slides from my talk at Percona Live London, Dec 2012
Too many of us have been taught that views are nothing more than stored SQL statements. The goal of this presentation is to challenge this notion. Or, to be precise, to take you one step further, from technicalities to the huge role that well-designed views can play in contemporary database solutions.
Current views are very advanced. They can be built on top of user-defined functions; they can utilize extremely complex INSTEAD-OF triggers (including composite ones), and they can even have indexes! As a result, with all of this added functionality views can serve as an isolation level between UI-driven data representation (heavily denormalized and customized) and DBA-driven data representation (normalized with referential integrity constraints and foreign keys).
Contemporary IT solutions often take this transformation completely out of the database, usually moving it to the middle-tier. This presentation will show that keeping business logic IN the database provides you with much greater flexibility, manageability, and performance. Of course, there are some traps and pitfalls, but these are also avoidable. Real-world examples will be provided to show that the role of views is seriously underestimated.
Hidden Gems of Performance Tuning: Hierarchical Profiler and DML Trigger Opti...Michael Rosenblum
In any large ecosystem, there are always areas that stay in the twilight, outside of the public’s attention. This deep dive attempts to change the trend regarding two, at first glance, unrelated PL/SQL topics: hierarchical profiler (HProf) and database triggers. But if you look closer, there’s something in common: they’re significantly underused! HProf because nobody heard about it, database triggers because of decades-old stigma. Let’s put both of them back into our development toolset!
Part #1. One of the most critical FREE SQL and PL/SQL performance tuning tools is almost totally unknown! If you ask, how much time is spent on routine A? How often is function B called? Most developers would hand-code something instead of using the Oracle PL/SQL HProf. This isn’t because the provided functionality is disliked, but because developers aren’t aware of its existence! This presentation is an attempt to alter this trend and reintroduce HProf to a wider audience.
Part #2. There isn’t anything “evil” about database triggers; they just have to be used where they can actually solve problems. In this presentation, various kinds of triggers will be examined from a global system optimization view, including tradeoffs between multiple goals (e.g., depending upon the available hardware, developers can select either CPU-intensive or I/O-intensive solutions). This presentation will focus on the most common performance problems related to different kinds of DML triggers and the proper ways of resolving them.
Woo hoo!
18c Qualified expressions for collections and records
Whitelisting with the ACCESSIBLE_BY Clause
More PL/SQL-Only Data Types Cross PL/SQL-to-SQL Interface
Optimizing Function Execution in SQL
The UTL_CALL_STACK Package
Privileges/Access Management for Program Units
Static Expressions In Place of Literals
Marking elements for deprecation
PL/Scope now includes SQL statements in its analysis
탑크리에듀교육센터(http://www.topcredu.co.kr)에서 제공하는
스프링프레임워크 & 마이바티스(Spring Framework, MyBatis)교육강좌입니다. Spring DI(Dependency Injection),세터 주입(Setter Injection) – XML 기반, 어노테이션기반 등에 대하여 설명한 교육자료이니 참고 바랍니다^^.
If you use scripting languages to power web, mobile, and/or enterprise applications, this session will show you how to use Oracle Database efficiently. It demonstrates how PHP can take full advantage of new performance, scalability, availability, and security features in Oracle Database 12c and Oracle Linux. Many of these features are available to other C-based scripting languages too, like Ruby, Python and Perl. DBA's will also benefit by seeing how applications can be monitored.
common_schema, DBA's framework for MySQLShlomi Noach
An introduction to common_schema, looking at the concepts behind the project and some notable features.
Slides from my talk at Percona Live London, Dec 2012
Data mining for causal inference: Effect of recommendations on Amazon.comAmit Sharma
As an increasing amount of daily activity---ranging from what we purchase to who we talk---shifts to online platforms, it is only natural to ask how those platforms impact our behavior. Take, for instance, online recommendation systems: how much activity do recommendations actually cause over and above what would have happened in their absence? Without doing randomized experiments, which may be costly or infeasible, estimating the impact of such systems is non-trivial. In this talk, I will argue that careful data mining can help in answering relevant causal questions in a more general way than traditional observational approaches.
Taking recommender systems as an example domain, I will show that data mining can be used to augment a popular techniques such as instrumental variables, by searching for large and sudden shocks in time series data. Applying this method to system logs for Amazon's "People who bought this also bought" recommendations, we are able to analyze over 4,000 unique products that experience such shocks. This leads to a more accurate estimate of the impact of the recommender system: at least 75% of recommendation click-throughs would likely occur in their absence, questioning popular industry estimates based on observed click-through rates.
Finally, this shock-based approach can be generalized to derive a data-driven identification strategy for finding natural experiments in time series data. This method too reveals a similar overestimate for the impact of recommendation systems.
Are you solving a problem worth solving?Elaine Chen
This short talk is for technical professionals who are thinking about starting a business with a technical solution. Entrepreneurship is about problem solving on not only the technical front, but on the business front. We use two well-known examples to highlight the power of using primary market research and customer development to define the problem statement and to validate hypotheses, to arrive efficiently at a business problem that addresses a real need and is economically viable as well.
Any structure expected to stand the test of time and change needs a strong foundation! Software is no exception. Engineering your code to grow in a stable and effective way is critical to your ability to rapidly meet the growing demands of users, new features, technologies, and platform capabilities. Join us to obtain architect-level design patterns for use in your Apex code to keep it well factored, easy to maintain, and in line with platform best practices. You'll follow a Force.com interpretation of Martin Fowler's Enterprise Architecture Application patterns, and the practice of Separation of Concerns.
Cognitive data capture with Elis - Rossum's technical webinarPetr Baudis
Here, we cover the basic technical concepts of Elis, Rossum's cognitive data capture tool. We also talk about how to configure your Elis account and about building Elis extensions. This webinar is aimed at technical Elis users and integrators.
Python RESTful webservices with Python: Flask and Django solutionsSolution4Future
Slides contain RESTful solutions based on Python frameworks like Flask and Django. The presentation introduce in REST concept, presents benchmarks and research for best solutions, analyzes performance problems and shows how to simple get better results. Finally presents soruce code in Flask and Django how to make your own RESTful API in 15 minutes.
Oracle DB Standard Edition: Başka Bir Arzunuz?Gokhan Atil
Enterprise Edition'a gerçekten ihtiyacınız var mı? Standard Edition ile arasındaki farkları biliyor musunuz? Her projede Enterprise Edition kullanmak doğru mu?
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
Zoom is a comprehensive platform designed to connect individuals and teams efficiently. With its user-friendly interface and powerful features, Zoom has become a go-to solution for virtual communication and collaboration. It offers a range of tools, including virtual meetings, team chat, VoIP phone systems, online whiteboards, and AI companions, to streamline workflows and enhance productivity.
E-commerce Application Development Company.pdfHornet Dynamics
Your business can reach new heights with our assistance as we design solutions that are specifically appropriate for your goals and vision. Our eCommerce application solutions can digitally coordinate all retail operations processes to meet the demands of the marketplace while maintaining business continuity.
Understanding Nidhi Software Pricing: A Quick Guide 🌟
Choosing the right software is vital for Nidhi companies to streamline operations. Our latest presentation covers Nidhi software pricing, key factors, costs, and negotiation tips.
📊 What You’ll Learn:
Key factors influencing Nidhi software price
Understanding the true cost beyond the initial price
Tips for negotiating the best deal
Affordable and customizable pricing options with Vector Nidhi Software
🔗 Learn more at: www.vectornidhisoftware.com/software-for-nidhi-company/
#NidhiSoftwarePrice #NidhiSoftware #VectorNidhi
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
In the ever-evolving landscape of technology, enterprise software development is undergoing a significant transformation. Traditional coding methods are being challenged by innovative no-code solutions, which promise to streamline and democratize the software development process.
This shift is particularly impactful for enterprises, which require robust, scalable, and efficient software to manage their operations. In this article, we will explore the various facets of enterprise software development with no-code solutions, examining their benefits, challenges, and the future potential they hold.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Łukasz Chruściel
No one wants their application to drag like a car stuck in the slow lane! Yet it’s all too common to encounter bumpy, pothole-filled solutions that slow the speed of any application. Symfony apps are not an exception.
In this talk, I will take you for a spin around the performance racetrack. We’ll explore common pitfalls - those hidden potholes on your application that can cause unexpected slowdowns. Learn how to spot these performance bumps early, and more importantly, how to navigate around them to keep your application running at top speed.
We will focus in particular on tuning your engine at the application level, making the right adjustments to ensure that your system responds like a well-oiled, high-performance race car.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeAftab Hussain
Understanding variable roles in code has been found to be helpful by students
in learning programming -- could variable roles help deep neural models in
performing coding tasks? We do an exploratory study.
- These are slides of the talk given at InteNSE'23: The 1st International Workshop on Interpretability and Robustness in Neural Software Engineering, co-located with the 45th International Conference on Software Engineering, ICSE 2023, Melbourne Australia
Graspan: A Big Data System for Big Code AnalysisAftab Hussain
We built a disk-based parallel graph system, Graspan, that uses a novel edge-pair centric computation model to compute dynamic transitive closures on very large program graphs.
We implement context-sensitive pointer/alias and dataflow analyses on Graspan. An evaluation of these analyses on large codebases such as Linux shows that their Graspan implementations scale to millions of lines of code and are much simpler than their original implementations.
These analyses were used to augment the existing checkers; these augmented checkers found 132 new NULL pointer bugs and 1308 unnecessary NULL tests in Linux 4.4.0-rc5, PostgreSQL 8.3.9, and Apache httpd 2.2.18.
- Accepted in ASPLOS ‘17, Xi’an, China.
- Featured in the tutorial, Systemized Program Analyses: A Big Data Perspective on Static Analysis Scalability, ASPLOS ‘17.
- Invited for presentation at SoCal PLS ‘16.
- Invited for poster presentation at PLDI SRC ‘16.
2. Gökhan Atıl
DBA Team Leader at bilyoner.com
Oracle ACE (since 2011)
Founding Member and Vice President of
TROUG (troug.org)
Co-author of Expert Oracle Enterprise
Manager
Blogger (since 2008) gokhanatil.com
Active on twitter: @gokhanatil
2
3. Agenda
Introduction to EM CLI
EM CLI Verbs
Formatting the Output
Fetching Information From EM Repository
Sample Bash Scripts
EM CLI Interactive Mode and Scripting Mode
Fundamentals of Python
Sample Python Scripts
3
4. What is EM CLI?
Repository
Agent
OMS
Web Console
4
5. What is EM CLI?
Repository
EM CLI
Agent
OMS
Web Console
4
6. Why EM CLI?
Emotional Reasons:
We love text-based tools
Practical Reasons:
Sometimes it’s faster (less clicks)
Good for scripting (automatisation
and bulk operations)
Web interface of
Enterprise Manager
is so cool!
5
7. Jump into the action!
It’s already installed and configured on
OMS server:
cd $OMSHOME/bin
./emcli (or emcli.bat on Windows servers)
6
8. You can install EM CLI to your PC
Requires Java version 1.6.0_43 or greater
Supported Operating Systems: Windows, Linux,
Solaris, HPUX, Tru64, AIX
Go to “command line interface” page under
“setup” page to download the installation JAR file.
Login is not required, so it’s possible to download
the JAR file with “wget”.
To run EM CLI on Java 1.8 or higher, you need apply patch 17555224 to
the weblogic server. Use"-no-check-certificate" parameter with wget.
7
9. Downloaded and ready to install!
After you download, set JAVA_HOME and install the JAR
file:
java -jar emcliadvancedkit.jar -install_dir=<home>
java -jar emclikit.jar -install_dir=<home>
Configure EM CLI:
emcli help setup
emcli setup -url="https://host:port/em"
-username=<emuser> -dir=<instancedir> -trustall
8
10. EM CLI Directory Structure
EM CLI configuration and log files (.emcli.log) are
located in the “instance home” directory
(remember the -dir parameter).
Basic JAR files and bash scripts are stored in
“installation directory”.
After you run “setup”, required JAR files used by
verbs will be fetched from OMS are stored under
the bindings directory.
9
11. Standard vs Scripting
There are two different installation kits for EM CLI:
EM CLI Standard Kit: This kit supports only the
Standard (command line) mode.
EM CLI with Scripting mode (option): This
“advanced” kit supports Interactive and Script
modes in addition to standard mode.
10
12. 3 modes of EM CLI:
Standard mode: This mode provides a simple command-line
interface to Enterprise Manager, and supports the execution of one
verb at a time from the command line.
emcli get_targets
Interactive mode: This mode enables you to create a single
interactive session with OMS. It is a Jython shell.
emcli
Scripting mode: In Scripting mode, EM CLI runs Jython scripts using
EM CLI verbs as Jython functions.
emcli @scriptname.py
11
13. Understanding EM CLI Syntax
In standard mode, EM CLI expect you enter a verb as
the first parameter. A verb is a task or action in the form
of a user command which exposes Enterprise Manager
functionality. Verbs may take zero or more arguments as
input.
emcli verb 1st_argument
[ -2nd_ argument="value" ]
[ -3rd_ argument="value" ]
[ -4th_ argument ]
…
12
14. A less known feature
emcli setup -
Syntax Error: Ambiguous argument - matches the
beginning of each of these argument names:
-_newline_, -additionalpostparams, -autologin,
-certans, -custom_attrib_file, -dir, -licans,
-localdirans, -noautologin, -nocertvalidate,
-noregister, -novalidate, -offline, -password, -trustall,
-url, -username, -verb_jars_dir
emcli setup -ur="https://host:port/em" -us=<emuser> -t
13
15. Basic Operational Verbs
help: Get help for emcli verbs (Usage: emcli help [verb_name])
setup: Setup emcli to work with an EM Management Server
sync: Synchronize with the EM Management Server (updates)
login: Login to the EM Management Server (OMS)
logout: Logout from the EM Management Server
status: List emcli configuration details
version: List emcli verb versions or the emcli client version
argfile: Execute emcli verbs from a file
invoke_ws: Invoke EM web service.
14
17. “Grep” is your friend!
Some verbs provide own filtering mechanism,
but some of them don’t. Using grep will
help you to filter the output of emcli.
emcli help | grep -i blackout
emcli get_target_types | grep -i database
16
18. Find the exact name of a target
Some verbs require the name and type as input. Target
names, target types and even “verbs” are case
sensitive, so be sure that you use the exact name of a
target and target type:
emcli get_targets
emcli get_targets -targets="targetname:targettype"
emcli get_targets -targets=“targetname:%"
emcli get_targets -targets="targettype"
17
19. Format and redirect the output
emcli get_targets -format="name:pretty"
emcli get_targets -format="name:csv"
emcli get_targets -format="name:script"
emcli get_targets -script
emcli get_targets -script > list_of_targets.txt
emcli get_targets -script l parsing_tool
18
Output can
be parsed
easily by
Unix tools
20. List the targets which has critical
alerts
emcli get_targets -alerts
emcli get_targets -alerts -script -noheader | awk '{ if
($5>0) print $4":"$3"t"$5 }'
19
Critical
Alerts
21. Gateway to the EM repository
Although there are more than 70 verbs to help you fetch a
specific information from OMS such as list of targets, list
of jobs etc, you may still need a more powerful verb
which can fetch information from the repository database.
The following command will list roles defined in EM:
emcli list -resource="Roles"
This command will show all resources that you can query:
emcli list -help
20
22. Gateway to the EM repository
This command shows the columns of the specified resource:
emcli list -resource="Administrators" -help
This command will list user names and user types defined as
EM administrator:
emcli list -resource="Administrators"
-columns="USER_NAME,USER_TYPE"
This command will show details about SYSMAN administrator:
emcli list -resource=“Administrators" -search="USER_NAME =
'SYSMAN'"
21
23. Gateway to the EM repository
For now, “List” verb can query 27 resources. If you
can not find the data you need among these
resources, you can even run SQL on repository
database:
emcli list -sql="<query>"
22
25. Sample Script: Clear Stateless Alerts
login=$(emcli login -username="GOKHAN"
-password="s3cr3t" | grep -c “successful")
if [ $login -eq 1 ]; then
for DBNAME in $(emcli get_targets
-targets="oracle_database" -noheader -script | cut -f4);
do
emcli clear_stateless_alerts -older_than=0
-target_type="oracle_database"
-target_name="$DBNAME"
done
emcli logout
fi
24
26. Sample Script: Delete All Named
Credentials
login=$(emcli login -username="GOKHAN"
-password="s3cr3t" | grep -c "successful")
if [ $login -eq 1 ]; then
for CN in $(emcli list_named_credentials -script
-noheader | cut -f1);
do
emcli delete_named_credential -cred_name="$CN"
done
emcli logout
fi
25
27. EM CLI with Scripting Mode
Run “emcli" without any parameters;
… and you find yourself in a Jython world!
26
28. Someone said Jython?
Jython is an implementation of the Python programming
language designed to run on the Java platform.
27
29. So what’s Python?
Widely used general-purpose, high-level
programming language
Supports multiple programming paradigms,
including OOP, imperative and functional
programming
Dynamic type system and automatic memory
management
Batteries Included (!)
28
30. EM CLI & Python
Verbs are defined as Python functions
Arguments are entered as function parameters
get_targets( target="oracle_database")
Results of verbs can be formatted as JSON
Some Python modules are included (math, os … )
Programming elements of Python makes scripting
easy!
29
31. Fundamentals of Python
Variables (dynamic type, no need for declaration but
need initialisation):
myvar = "TESTDB"
myvar = myvar + ":oracle_database"
myvar = 10
myvar = myvar + 10
myvar = 10 + "10"
TypeError:
unsupported
operand type(s) for
+: 'int' and 'str'
30
32. Fundamentals of Python
Conversion between integer and string, conditional
jumps and code blocks:
myvar = int("2")
myvar = 2
myvar = "2"
if ( myvar >= 10 ):
print "myvar is " + str(myvar)
else:
print "lower than 10"
Code blocks are identified
by “indentation”
31
33. Fundamentals of Python
Dictionary objects, list objects and iterations:
mydict = { 'Name':'Gokhan', 'Age':40 }
mydict['Name'] = "Gokhan"
mylist = ["Joe","William","Jack","Averell"]
mylist[0] = "Joe"
for i in mylist:
print i
JSON
it will print all elements in “mylist”
32
34. EM CLI Response Object
emcli.response represents the response object
which returned from invocation of a emcli verb from
python script.
emcli.response.Response
error() error text
exit_code() error code (0=success)
isJson() is JSON? true/false
out() JSON or text
33
35. EM CLI Response Object
In scripting mode, default output format type is
JSON. In interactive mode, to change the output
format to JSON, you need to run the following
command:
set_client_property('EMCLI_OUTPUT_TYPE', 'JSON')
It’s better to use JSON because it directly matches
with Python “dictionary” object. There’s no need for
extra effort to parse the output.
34
36. EM CLI Response Object
Let’s get the response from a verb:
mytargets = get_targets( target="oracle_database" )
type(mytargets.out())
<type 'dict'>
mytargets.out()
{'data': [{'Status': 'Up', 'Warning': '6', 'Status ID': '0',
'Target Type': 'oracle_database', 'Critical': '64', 'Target
Name': ‘TESTDB’},{…}]}
35
37. EM CLI Response Object
A response always contain a “data” item which is a
list object:
type(mytargets.out()['data'])
<type ‘list'>
mytargets.out()['data']
[{'Status': 'Up', 'Warning': '6', 'Status ID': '0',
'Target Type': 'oracle_database', 'Critical': '64',
'Target Name': ‘TESTDB’},{…}]
36
38. EM CLI Response Object
After we reach the list, we can iterate over the items
of the list:
for DB in mytargets.out()['data']:
print DB['Target Name'], DB['Status']
37
39. Sample Script: Clear Stateless Alerts
Save the following code in a file (clearalerts.py) and
run it as “emcli @clearalerts.py”:
if login( username="GOKHAN" ).exit_code()==0:
mytargets=get_targets( targets="oracle_database" )
for DB in mytargets.out()['data']:
clear_stateless_alerts(
target_name=DB['Target Name'],
target_type=DB['Target Type'], older_than="0" )
38
40. Sample Script: Change DBSNMP
Passwords
if len(sys.argv) <> 2:
print "Usage: emcli @change_dbsnmp_passwords.py oldpwd newpwd"
exit()
if login( username="GOKHAN" ).exit_code()==0:
mytargets=get_targets( targets="%_database" )
for DB in mytargets.out()['data']:
try:
update_db_password (target_name=DB['Target Name'],
target_type=DB['Target Type'] ,
change_at_target="yes",user_name="dbsnmp",
old_password=sys.argv[0],
new_password=sys.argv[1],
retype_new_password=sys.argv[1])
except emcli.exception.VerbExecutionError, e:
print e.error()
39
41. Sample Script: Promote Unmanaged
Databases
lg = login( username="SYSMAN" )
if lg.exit_code() <> 0:
print lg.error()
utargets=get_targets( "unmanaged", "properties",
targets="oracle_database" )
for target in utargets.out()['data']:
add_target( name=target['Target Name'], type=target['Target Type'],
host=target['Host Info'].split(';')[0].split(':')[1],
credentials="UserName:dbsnmp;password:xyz;Role:Normal",
properties=target[‘Properties'] )
positional parameters
40
42. Sample Script: Promote Unmanaged
Databases
lg = login( username="SYSMAN" )
if lg.exit_code() <> 0:
print lg.error()
utargets=get_targets( "unmanaged", "properties",
targets="oracle_database" )
for target in utargets.out()['data']:
add_target( name=target['Target Name'], type=target['Target Type'],
host=target['Host Info'].split(';')[0].split(':')[1],
credentials="UserName:dbsnmp;password:xyz;Role:Normal",
properties=target[‘Properties'] )
positional parameters
40
43. Further Reading:
OEM 12c Command-Line Interface
My blog:
http://www.gokhanatil.com
Kellyn Pot'Vin-Gorman
http://dbakevlar.com
Ray Smith
https://oramanageability.wordpress.com
Sete Miller
http://sethmiller.org
The Definitive Guide to Jython
http://www.jython.org/jythonbook/en/1.0/
41