Modify attributes on running objects using the wsadmin scripting tool
Use scripting and the wsadmin tool to modify attributes on running objects.
We can run a script that modifies attributes on running objects.
- Obtain the name of the running object.
Run the completeObjectName command with the name parameter.
- Jacl:
$AdminControl completeObjectName name
- Jython:
AdminControl.completeObjectName(name)
Element Description $ Jacl operator for substituting a variable name with its value AdminControl Enable the manipulation of MBeans running in a WebSphere Application Server process completeObjectName AdminControl command name Fragment of the object name used to find the matching object name. For example: type=TraceService,node=mynode,*. This value can be any valid combination of domain and key properties, for example, type, name, cell, node, process, and so on. - Set the ts1 variable to the running object.
The following scripts set the ts1 variable to the result of the completeObjectName commands.
- Jacl:
set ts1 [$AdminControl completeObjectName name]
- Jython:
ts1 = AdminControl.completeObjectName(name)
Element Description set Jacl command ts1 variable name $ Jacl operator for substituting a variable name with its value AdminControl Enable the manipulation of MBeans running in a WAS process completeObjectName AdminControl command name fragment of the object name. It is used to find the matching object name. For example: type=TraceService,node=mynode,*. It can be any valid combination of domain and key properties, for example, type, name, cell, node, process, and so on. - Modify the running object.
The following scripts use the setAttribute command to set the ts1 variable ring buffer size to 10.
- Jacl:
$AdminControl setAttribute $ts1 ringBufferSize 10
- Jython:
AdminControl.setAttribute(ts1, 'ringBufferSize', 10)
We can also modify multiple attribute name and value pairs, for example:
Element Description $ Jacl operator for substituting a variable name with its value AdminControl Enable the manipulation of MBeans running in a WAS process setAttribute AdminControl command ts1 Evaluate to the ID of the server specified in step number 3 ringBufferSize ringBufferSize of modify objects 10 Value of the ringBufferSize attribute
- Jacl:
set ts1 [$AdminControl completeObjectName type=TraceService,process=server1,*]
$AdminControl setAttributes $ts1 {{ringBufferSize 10} {traceSpecification com.ibm.*=all=disabled}}
- Jython list:
ts1 = AdminControl.completeObjectName('type=TraceService,process=server1,*')
AdminControl.setAttributes(ts1, [['ringBufferSize', 10], ['traceSpecification', 'com.ibm.*=all=disabled']])
- Jython string:
ts1 =AdminControl.completeObjectName('type=TraceService,process=server1,*')
AdminControl.setAttributes(ts1, '[[ringBufferSize 10] [traceSpecification com.ibm.*=all=disabled]]')
The new attribute values are returned to the command line.
Start the wsadmin scripting client Turning traces on and off in servers processes using scripting wsadmin AdminControl Perform operations on running objects Example: Identifying running objects Commands for the AdminControl object