以编程方式访问 Websphere Application Server 及其资源

发布于 2024-11-23 16:19:21 字数 2002 浏览 0 评论 0原文

这是我在 StackOverflow 上提出的第一个问题,请耐心等待。

我想实现什么目标?

我需要编写一个独立的程序来访问 Websphere Application Server 的特定实例或多个实例并从中获取详细信息。就我的研究而言,有两种方法可以做到这一点。

  1. 适配器
  2. 连接器

我目前正在采用“连接器”方法以及SOAP连接器(因为它的防火墙友好性)

所以,我的代码将是这样的..


// Initialize the AdminClient.
Properties adminProps = new Properties();

adminProps.setProperty("type", AdminClient.CONNECTOR_TYPE_SOAP );
adminProps.setProperty("host", "localhost");
adminProps.setProperty("port", "8880");
AdminClient adminClient = AdminClientFactory.createAdminClient(adminProps);

String query = "WebSphere:*";
//String query = "WebSphere:type=Server,*";
ObjectName queryName = new ObjectName(query);
Set s = adminClient.queryNames(queryName, null);
if (!s.isEmpty()) {
    iter = s.iterator();
    while (iter.hasNext()) {
        ObjectName nodeagent = (ObjectName) iter.next();
    System.out.println("*********************************************");
        System.out.println("KeyPropertyList: " + nodeagent.getKeyPropertyListString());
    }
}

通过这段代码,我能够获得所有的列表WAS 的特定实例 (C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01) 上的 MBean,并且成功打印密钥 - 属性列表。

现在我有一个 MBean 列表。接下来怎么办? 链接:_http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.javadoc.doc/web/mbeanDocs/index.html

这是我的查询:

如何我是否可以获得我感兴趣的特定 MBean 的实例并获取所有相关属性?

例如:

AppManagement appM = AppManagementProxy.getJMXProxyForClient (adminClient);
System.out.println(appM.listApplications(null, null, null));

将列出 WAS 特定实例上的所有应用程序

[query、SamplesGallery、ivtApp、DefaultApplication、PlantsByWebSphere]

我有兴趣了解有关已安装应用程序的更多信息,例如,它们是否已启动并正在运行?如果是这样,IP 地址、内部版本号、是否处于维护状态等(仅引用它们作为示例)如果我可以获得 MBean 可以提供的应用程序的所有可能的详细信息,那么它将完成我的任务(部分) )

上述只是一个示例,我想从 MBeans 中获得更多信息。因此,请提供一个解决方案/示例代码,以帮助我从 WAS 实例必须提供的任何 MBean 获取信息。 (使用 JMX)

其他详细信息: IBM WebSphere Application Server,7.0.0.0(基本安装)

提前致谢, 阿杰

This is my very first question on StackOverflow so, please bear with me.

What am I trying to achieve?

I need to write a standalone program to access a particular instance or multiple instances of Websphere Application Server and get details from it. As far as my research goes, there are two ways to do this.

  1. Adaptors
  2. Connectors

I am currently taking up the 'Connectors' approach and that too the SOAP connector (for its firewall friendliness)

So, my code would be something like this..


// Initialize the AdminClient.
Properties adminProps = new Properties();

adminProps.setProperty("type", AdminClient.CONNECTOR_TYPE_SOAP );
adminProps.setProperty("host", "localhost");
adminProps.setProperty("port", "8880");
AdminClient adminClient = AdminClientFactory.createAdminClient(adminProps);

String query = "WebSphere:*";
//String query = "WebSphere:type=Server,*";
ObjectName queryName = new ObjectName(query);
Set s = adminClient.queryNames(queryName, null);
if (!s.isEmpty()) {
    iter = s.iterator();
    while (iter.hasNext()) {
        ObjectName nodeagent = (ObjectName) iter.next();
    System.out.println("*********************************************");
        System.out.println("KeyPropertyList: " + nodeagent.getKeyPropertyListString());
    }
}

With this piece of code, I am able to get the list of all the MBeans on that particular instance of the WAS (C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01) and it successfully prints the Key - Property list.

Now I have a list of MBeans. What next?
Link: _http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.javadoc.doc/web/mbeanDocs/index.html

Here is my query:

How do I get an instance of a particular MBean I am interested in and fetch all related properties?

For example:

AppManagement appM = AppManagementProxy.getJMXProxyForClient (adminClient);
System.out.println(appM.listApplications(null, null, null));

Would list all the application(s) on that particular instance of WAS

[query, SamplesGallery, ivtApp, DefaultApplication, PlantsByWebSphere]

I am interested in knowing more about the applications installed say, are they up and running? If so, the IP Address, build number, is it in maintenance, etc., (just quoting them as an example) If I can get all possible details of the application that the MBean could offer, then it would complete my task (partly)

The aforementioned is just an example and I would like to get more out of MBeans. So, please provide a solution / sample code that would help me out in getting information from any MBean the WAS instance has to offer. (Using JMX)

Additional Details:
IBM WebSphere Application Server, 7.0.0.0 (Base Installation)

Thanks in Advance,
AJ

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

就像说晚安 2024-11-30 16:19:21

您可以通过查询所有服务器并检查应用程序是否在每个服务器上运行,然后找到从每个服务器获取主机来间接获取 IP 地址。我不确定内部版本号是否可用。 “维护中”是什么意思?

您可以从 Application 和 J2EEApplication (JSR 88) MBean 获取更多信息。因此,ObjectName("WebSphere:type=Application,name=myapp")(特定于 WebSphere)或 ObjectName("WebSphere:type=J2EEApplication,name=myapp")。

您可以使用 ConfigServiceProxy 并查询 getid("/DefaultApplication:myapp/") 来获取配置信息。您可以查看 PROFILE_HOME/config/cells/CELL/applications/APP.ear/deployments/APP/deployment.xml 以查看配置中可用的信息类型。您可以将其与 WAS_HOME/web/configDocs/ 中从 appdeployment 包开始的类型信息进行匹配。

IP address you could get indirectly by querying all servers and checking if the app is running on each of them, and then finding getting the host from each server. I'm not sure if build number is available. What does "in maintenance" mean?

You can get more information from the Application and J2EEApplication (JSR 88) MBeans. So, ObjectName("WebSphere:type=Application,name=myapp"), which is WebSphere-specific, or ObjectName("WebSphere:type=J2EEApplication,name=myapp").

You can get configuration information using ConfigServiceProxy and querying for the getid("/DefaultApplication:myapp/"). You can look at PROFILE_HOME/config/cells/CELL/applications/APP.ear/deployments/APP/deployment.xml to see the kind of information available from the config. You can match it up with the type information in WAS_HOME/web/configDocs/ starting with the appdeployment package.

以歌曲疗慰 2024-11-30 16:19:21

尝试

String query = "WebSphere:*,mbeanIdentifier=<XXX>";

mbean 的标识符在哪里

Try

String query = "WebSphere:*,mbeanIdentifier=<XXX>";

Where is the identifier of the mbean

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文