Example: Identifying running objects using wsadmin scripting
Use the AdminControl object to interact with running MBeans.
In the WebSphere® Application Server, MBeans represent running objects. You can interrogate the MBean server to see the objects it contains.
- Use the queryNames command to see running MBean
objects. For example:Using Jacl:
$AdminControl queryNames *Using Jython:This command returns a list of all MBean types. Depending on the server to which your scripting client attaches, this list can contain MBeans that run on different servers:print AdminControl.queryNames('*')- If the client attaches to a stand-alone WebSphere Application Server, the list contains MBeans that run on that server.
- The list that the queryNames command returns
is a string representation of JMX ObjectName objects. For
example:
This example represents a TraceServer object that runs in server1 on MyNode.WebSphere:cell=MyCell,name=TraceService,mbeanIdentifier=TraceService, type=TraceService,node=MyNode,process=server1 - The single queryNames argument represents the ObjectName object
for which you are searching. The asterisk ("*") in the example means
return all objects, but it is possible to be more specific. As shown
in the example, ObjectName has two parts: a domain, and a
list of key properties. For MBeans created by the WebSphere Application
Server, the domain is WebSphere. If you do not specify
a domain when you invoke queryNames, the scripting client assumes
the domain is WebSphere. This means that the first example
query is equivalent to:Using Jacl:
$AdminControl queryNames WebSphere:*Using Jython:AdminControl.queryNames('WebSphere:*') - WebSphere Application Server includes the
following key properties for the ObjectName object:
- name
- type
- cell
- node
- process
- mbeanIdentifier
Using Jacl:$AdminControl queryNames WebSphere:type=Server,node=myNode,*Using Jython:This example returns a list of all MBeans that represent server objects running the node myNode. The, * at the end of the ObjectName object is a JMX wildcard designation. For example, if you enter the following:AdminControl.queryNames('WebSphere:type=Server,node=myNode,*')Using Jacl:$AdminControl queryNames WebSphere:type=Server,node=myNodeUsing Jython:you get an empty list back because the argument to queryNames is not a wildcard. There is no Server MBean running that has exactly these key properties and no others.print AdminControl.queryNames('WebSphere:type=Server,node=myNode') - If you want to see all the MBeans representing applications running
on a particular node, invoke the following example:Using Jacl:
$AdminControl queryNames WebSphere:type=Application,node=myNode,*Using Jython:print AdminControl.queryNames('WebSphere:type=Application,node=myNode,*')
Tópico de Referência