User Tools

Site Tools


middleware:wsadmin

Scripting with wsadmin

Help

print Help.message('WASX7115E')
print Help.Adminapp()
print AdminApp.help("listModules")

AdminApp

Use the AdminApp object to manage applications.

List installed Applications

print AdminApp.list()
print AdminApp.list("WebSphere:cell=myCell,node=myNode,server=myServer")
print AdminApp.list("WebSphere:cell=myCell,node=myNode")

Edit application configuration

Beware, the application will restart on save:

AdminApp.edit('appname', ['options']) # or
AdminApp.edit('appname', '[options]')

Interactively:

AdminApp.editInteractive('appname')

AdminControl

The AdminControl scripting object is used for operational control of running objects

The WebSphere Application Server ObjectName class uniquely identifies running objects. The ObjectName class consists of the following elements:

  • The domain name WebSphere.
  • Several key properties, for example:
    • type - Indicates the type of object that is accessible through the MBean, for example, ApplicationServer, and EJBContainer.
    • name - Represents the display name of the particular object, for example, MyServer.
    • node - Represents the name of the node on which the object runs.
    • process - Represents the name of the server process in which the object runs.
    • mbeanIdentifier - Correlates the MBean instance with corresponding configuration data.

When ObjectName classes are represented by strings, they have the following pattern:

[domainName]:property=value[,property=value]*

For example, you can specify

WebSphere:name="My Server",type=ApplicationServer,node=n1,*

to specify an application server named My Server on node n1. (The asterisk (*) is a wildcard, used so that you do not have to specify the entire set of key properties.) The AdminControl commands that take strings as parameters expect strings that look like this example when specifying running objects (MBeans). You can obtain the object name for a running object with the getObjectName command.

Specify MBeans

With a partial object name (template), you can use the completeObjectName and queryNames methods.

CompleteObjectName retrurns the first match as a string.

AdminControl.completeObjectName(template)
AdminControl.completeObjectName("type=Server,name=server1,*")

QueryNames returns a list of all the objects, separated by \n

AdminControl.queryNames(template)  
res=AdminControl.queryNames("type=Server,*")
res.split('\n')

Find MBeans attributes and operations

To find information on a running MBean supported attributes and operations, use Help.attributes and Help.operations.

srv=AdminControl.completeObjectName("type=Server,name=server1,*")
print Help.attributes(srv)
print Help.operations(srv)
print Help.attributes(srv,'pid')
print Help.operations(srv,'stop')

Performing operations and modifying attributes on MBeans

To invoke an operations, use AdminControl.invoke(mbean, operation)

srv=AdminControl.completeObjectName("type=Server,name=server1,*")
AdminControl.invoke(srv,'stop')

To modify an attribute, use AdminControl.setAttribute(mbean, attribute, value)

AdminControl.setAttribute(ts1, 'ringBufferSize', 10)
AdminControl.setAttributes(srv, [['ringBufferSize', 10], ['traceSpecification', 'com.ibm.*=all=disabled']])

Force node synchronization

Use AdminControl.invoke(node, 'sync'):

node = AdminControl.completeObjectName('type=NodeSync,node=nbk02476Node01,*')
AdminControl.invoke(node, 'sync')

AdminConfig

Save configuration

AdminConfig.save()
middleware/wsadmin.txt · Last modified: 2009/02/25 15:53 by ap

Informativa sui cookie