使用 PowerShell 连接到 JMX
我不是开发人员,因此在阅读以下消息时请记住这一点:
我需要能够使用 Windows PowerShell 连接到主机上的 JMX RMI 代理,这可能吗?
来自java客户端的示例字符串如下:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:7979/jmxrmi");
原因是我正在 PowerShell 脚本中执行其他工作,并希望将其全部保存在一个位置。
谢谢 !
I am not a developer so please keep that in mind when reading the following message:
I need to be able to use Windows PowerShell to connect to a JMX RMI agent on a host, is this even possible ?
The example string from the java client I have been given is as below:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:7979/jmxrmi");
The reason for this is that I am doing other work in my PowerShell script and would like to keep it all in one place.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是两种技术的不同寻常的组合,但它是可能的。
如果您尝试连接到 JBoss 服务器,最快的方法可能是调用 twiddle,一个命令工具,它将向目标 JBoss 服务器分派 JMX 请求并将结果返回到标准输出。
另一种方法是在目标服务器上实施 Jolokia 代理。这将允许您使用 REST 发出 JMX 请求。响应也将以 REST 格式返回,您可以使用 这些解决方案。
第三,您还可以在目标服务器上部署 JMX-WS 服务,这将允许您使用 Web 服务与 JMX 服务器进行通信。此文档提供了一些这方面的 VBScript 示例。
上述内容实际上都没有使用您概述的 JMXServiceURL 语法,并且我想不出一种方法可以将这种基于 RMI 的协议真正干净地集成到 PowerShell 中,但希望上述内容之一对您有用。
==========更新==========
可能有一种方法可以使用RMI实现。查看IKVM。它是一个 Java 字节码到 .NET 的编译器。我已成功将 JMX/RMI java 代码编译成 .Net 程序集并从 C# 中使用它。我认为 PowerShell 也会做同样的事情。
This is an unusual mix of two technologies, but it is possible.
On the off-chance that you are attempting to connect to a JBoss server, the quickest way may be for you to call twiddle, a command tool that will dispatch JMX requests to the target JBoss server and return the results to standard out.
Another way is to implement the Jolokia agent on the target servers. This will allow you to issue JMX requests using REST. Responses will also be returned in REST format which you can process in PowerShell using one of these solutions.
Thirdly, you can also deploy the JMX-WS service on your target servers which will allow you to communicate with the JMX server using web-services. This document provides some VBScript examples of this.
None of the above actually uses the JMXServiceURL syntax you outlined, and I cannot think of a way you could actually cleanly integrate this RMI based protocol into PowerShell, but hopefully one of the above will work for you.
========== UPDATE ==========
There may be a way to use the RMI implementation. Take a look at IKVM. It is a Java Byte Code to .NET compiler. I have successfully compiled JMX/RMI java code into a .Net assembly and used it from C#. I think PowerShell will do the same thing.