You are on page 1of 14

WSADMIN Scripting

Why to Use Scripting?

• Making configuration changes using the WebSphere


administrative console is error prone and dangerous in
complex production environments

• Routine tasks can be automated, making repetitive


tasks more easily done and done consistently

• Automated tasks faster to execute

o Common Operational and Configurational tasks can be


performed from scripts and command line
What can be done using WSADMIN ?

o Examples:
• Start and stop deployment manager, nodes, application
servers, enterprise applications and clusters
• Configure virtual hosts, JDBC providers, JMS resources
• Create application servers
• Create clusters and add members to a cluster
• Deploying Applications
• Almost all tasks available through administrative console
WsAdmin Objects
There are five administrative objects that
perform different operations
• 1. AdminControl
• 2. AdminConfig
• 3. AdminApp
• 4. AdminTask
• 5. Help
• Admin Control Object is used to work with
running objects and perform traces and type
conversion
• AdminConfig - create/change WebSphere
Application Server "static"configuration
• AdminApp - install, modify or administer
applications
• AdminTask - access administrative
commands to provide alternate way to
access configuration commands
• Help – provides help
JMX Architecture
• Java Management Extensions (JMX) is a framework, provides a
standard way of exposing Java Resources to a system management
infrastructure.

The JMX architecture is structured into three layers:


1. Instrumentation layer
The instrumentation layer dictates how resources can be wrapped
within special Java beans called Management Beans (MBeans).

2. Agent layer
The agent layer consists of the MBean server and agents, which
provide a management infrastructure.
Services implemented include:
– Monitoring, Event notification, Timers

3. Management layer
• The management layer defines how external management applications
can interact with the underlying layers in terms of protocols, APIs, and
so on
How does JMX work?
• Resources(configuration) are managed by JMX MBeans. These are
not EJBs, but simple Javabeans that need to conform to certain
design patterns outlined in the JMX specification.

• An EJB lives in an Application Server container. It usually


implements business logic. An MBean lives in an MBeanServer, and
usually implements management logic (configuration, monitoring,
etc)...

• MBeans
MBeans are managed beans, Java objects that represent
resources to be managed.

An MBean has a management interface consisting of:

Named and typed attributes that can be read and written


Named and typed operations that can be invoked

• Typed notifications that can be emitted by the MBean


JMX Architecture
• The Following Architecture shows JMX MBeanServer and its Mbeans
accessing the resources. Resources are nothing but XML files
• The MBean represents a resource running in the JVM such as an
application, a J2EE technical service ( JDBC driver, ...), ... They can be
used for getting and setting applications configuration (pull), for collecting
statistics (pull) (e.g. performance, resources usage, problems, ...) and
notifying events (push) (e.g. faults, state changes, ...)
• Providers that want to instrument their systems with JMX need to provide a
series of MBeans. Each MBean is meant to wrap, or represent, a certain run
time resource.
For example, in order to expose an application server as a manageable
resource, WebSphere needs to provide an application server MBean.

• Connectors :
Connectors are used to connect an agent with a remote JMX-enabled
management application. This form of communication involves a connector
in the JMX agent and a connector client in the management
• Protocol adapters

Protocol adapters provide a management view of the JMX agent through a


given protocol. Management applications that connect to a protocol adapter
are usually specific to the given protocol.
• MBean server

Each JMX enabled JVM™ contains an MBean server that registers all the
MBeans in the system. It is the MBean server that provides access to all of
its registered MBeans. There is only one MBean server per JVM
Distributed administration architecture –key points:
• Internal MBeans local to the JVM register with the local MBean server.
• External MBeans have a local proxy to their MBean server. The proxy registers with the local Mbean
server. The MBean proxy allows the local MBean server to pass the message to an external MBean
server
located on :
Another server, Node agent , Deployment manager
• A node agent has an MBean proxy for all servers within its node. However, MBean proxies for other
nodes
are not used.
• The deployment manager has MBean proxies for all node agents in the cell.

WAS provides a number of MBeans, each of which can have different functions and operations
available.
For example:
 An application server MBean might expose operations such as start and stop.
 An application MBean might expose operations such as install and uninstall.
Bean Scripting Frame Work
• WebSphere wsadmin tool uses BSF(Bean
Scripting),which supports a variety of
scripting languages like jython, jacl etc to
configure & control Our WAS installation.
• This presentation will focus on Jython
because it's the preferred scripting
language. JACL was what WSADMIN
supported initially. But it is now
deprecated in V6.1.
Invoking WSADMIN
C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv02\bin>wsadmin.bat -help
WASX7001I: wsadmin is the the executable for WebSphere scripting.
Syntax:
wsadmin wsadmin command-line options

[ -h(elp) ]
[ -? ]
[ -c <command> ]
[ -p <properties_file_name>] Specify a properties file other than wsadmin.properties
[ -profile <profile_script_name>] a script file to be executed before the main command or file
[ -f <script_file_name> ] a command to be passed to the script processor
[ -javaoption java_option]
[ -lang language] the language to be used to interpret scripts; supported values are "jacl" and
"jython".
[ -profileName profile] The profile can be used to perform whatever standard initialization is
required.
[ -conntype
SOAP
Any options specified on the command line will override those set in the
properties file.

[-host host_name]
[-port port_number]
[-user userid]
[-password password] |
RMI
NONE
]
[ -jobid <jobid_string>]
[ -tracefile <trace_file>]
WSADMIN Scripts uses the objects( AdminApp ,Admin Config , Admin Control , Admin
Task) to update resources by invoking the appropriate MBEANS running on MBEAN
Server under each JVM (DMGR , NodeAgent , AppServer)
Sample screen shot shows logging into wsadmin

Now we are ready to execute Jython commands by using WSADMIN objects

You might also like