Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think what you may be looking for is the use of the <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/txml_adminclient.html" rel="nofollow">WebSphere Thin Administrative Client</a>, which exposes Java APIs and provides access to the WAS <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.javadoc.doc/web/mbeanDocs/index.html" rel="nofollow">MBeans</a> that allow you to query the status of your servers/applications (along with many other management and monitoring tasks).</p> <p>First, you'll want to obtain a connection to WAS (the <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.javadoc.doc%2Fweb%2Fapidocs%2Fcom%2Fibm%2Fwebsphere%2Fmanagement%2FAdminClient.html" rel="nofollow"><code>AdminClient</code></a>) as follows:</p> <pre><code>Properties clientProps = new Properties(); clientProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP); clientProps.setProperty(AdminClient.CONNECTOR_HOST, dmgrHostname); clientProps.setProperty(AdminClient.CONNECTOR_PORT, dmgrSoapConnectorPort); if (dmgrIsSecure) { clientProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true"); clientProps.setProperty(AdminClient.USERNAME, wasUsername); clientProps.setProperty(AdminClient.PASSWORD, wasUserPassword); } AdminClient adminClient = AdminClientFactory.createAdminClient(clientProps); </code></pre> <p>Next, you'll want to query for the relevant MBeans, and then perform the relevant operations. In your case, you may be interested in the <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.javadoc.doc%2Fweb%2FmbeanDocs%2FClusterMgr.html" rel="nofollow">ClusterMgr</a> and/or <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.javadoc.doc%2Fweb%2FmbeanDocs%2FJ2EEApplication.html" rel="nofollow">J2EEApplication</a> MBeans. Here is an example that queries for the Cluster's state:</p> <pre><code>AdminClient adminClient = getAdminClient(target); ObjectName clusterMgr = (ObjectName)adminClient.queryNames( ObjectName.getInstance("WebSphere:*,type=ClusterMgr"), null).iterator().next(); String state = adminClient.invoke(clusterMgr, "getClusterState", new Object[] {clusterName}, new String[] {String.class.getName()}); </code></pre> <p>You can invoke further operations as desired, such as querying the individual cluster member's status.</p> <p>Also, in addition to querying, you can also <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.javadoc.doc/web/apidocs/com/ibm/websphere/management/AdminClient.html#addNotificationListener(javax.management.ObjectName,%20javax.management.NotificationListener,%20javax.management.NotificationFilter,%20java.lang.Object)" rel="nofollow">register notifications</a> so that your program can be notified when certain events happen, such as a change in state of clusters, servers, or applications.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload