我是 JMX 的新手。我开发了一个 Web 服务,使用 Glassfish 作为服务器。现在我想监控我的应用程序;
我的第一个想法是使用 Jconsole 和 JVM 作为远程监控工具。继续我的研究后,我发现这篇文章:
http://www.javacodegeeks.com/2012/02/client-side-server-monitoring-with.html
这表明我必须使用像 Jolokia 这样的桥,我显然不明白原因。JConsole + mbeans 还不够?
我继续我的研究,并使用他们的示例创建了一个 java 项目:
public static void main(String[] args) throws MalformedObjectNameException, J4pException {
J4pClient j4pClient = new J4pClient("http://localhost:8080/jolokia/");
J4pReadRequest req = new J4pReadRequest("java.lang:type=Memory",
"HeapMemoryUsage");
J4pReadResponse resp = j4pClient.execute(req);
Map<String, String> vals = resp.getValue();
System.out.println("Memory usage: used: " + vals);
}
它起作用了,我收到了一些与我的使用内存有关的消息。但是,我不知道目的是什么。
监控我的 Web 服务的最佳方式是什么?