通过 jstatd 查看 MBean
我正在尝试通过 jstatd 监视服务器上运行的所有 Java 进程。我已经将其设置得足够好,可以连接 VisualVM 并查看所有正在运行的进程。大多数显示工作正常,但某些内容(尤其是 CPU 使用情况和 MBean)无法显示。相反,它说:
MBean 浏览器
数据不可用,因为无法建立与 JMX 代理的 JMX 连接。
数据不可用。我认为问题在于应用程序必须通过 jstatd
RMI 注册表而不是本地注册表“宣布”,因此我尝试了以下操作(根据 这些建议),但它仍然不会显示。我尝试的代码如下:
public class JmxRmiConnectorTest {
public static void main(String[] args) throws Exception {
Registry rmiRegistry = LocateRegistry.createRegistry(9994);
String svc =
"service:jmx:rmi://localhost:9994/jndi/rmi://localhost:1099/connector";
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
JMXServiceURL url = new JMXServiceURL(svc);
RMIConnectorServer rmiServer = new RMIConnectorServer(url, null, mbeanServer);
rmiServer.start();
Thread.sleep(100000);
rmiServer.stop();
}
}
当通过jstatd查看时,如何让我的MBeans和CPU使用率显示在VisualVM中?
I am trying to monitor all Java processes running on a server via jstatd. I've got it set up enough that I can connect with VisualVM and see all running processes. Most displays work fine, however certain things (especially CPU usage and MBeans) do not display. Instead, it says:
MBeans Browser
Data not available because JMX connection to the JMX agent could not be established.
I assumed that the problem was that the application must "announce" through the jstatd
RMI registry rather than a local one, so I tried out the following (per these suggestions) but it still won't display. The code I tried is as follows:
public class JmxRmiConnectorTest {
public static void main(String[] args) throws Exception {
Registry rmiRegistry = LocateRegistry.createRegistry(9994);
String svc =
"service:jmx:rmi://localhost:9994/jndi/rmi://localhost:1099/connector";
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
JMXServiceURL url = new JMXServiceURL(svc);
RMIConnectorServer rmiServer = new RMIConnectorServer(url, null, mbeanServer);
rmiServer.start();
Thread.sleep(100000);
rmiServer.stop();
}
}
How can I get my MBeans and CPU usage to show up in VisualVM when seen through jstatd?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
jstatd 与 JMX 无关。 Jstatd 是 Jvmstat 的代理。要获取 MBean 和 CPU 使用情况,您还需要启用 JMX。请参阅 JMX 远程监控和管理更多细节。启用 JMX 后,VisualVM 将自动检测(通过 jvmstat)它也可以使用 JMX,并且它将在一个位置显示来自 jvmstat 和 JMX 的数据。
jstatd has nothing to do with JMX. Jstatd is a proxy for Jvmstat. To get MBeans and CPU usage you need to also enable JMX. See JMX Remote Monitoring and Management for more details. Once you have JMX enabled, VisualVM will automatically detect (via jvmstat) that it can also use JMX and it will display data from both jvmstat and JMX in one place.
在远程,像这样启动java以启用jmxremote。
在语言环境中,使用像这样的 jps
jps YOUHOSTNAME:9191
。In remote, launch java like this to enabl jmxremote.
In locale,use jps like this
jps YOUHOSTNAME:9191
.适合那些需要快速工作方法的人。
JMX可以动态启动/停止,无需重新启动JVM。
就我而言,动态启动 jmx 并重新启动 jvisualvm 后,JMX 和 cpu 使用情况正常。
或者
Just for those who need a quick working method.
JMX can be start/stop dynamically, that's without restart of JVM.
In my case, after start jmx dynamically and restart jvisualvm, JMX and cpu usage works fine.
or