Simple tool to monitor a Tomcat server using JMX

假如想象 提交于 2019-11-30 10:30:02

You definitely don't have to re-invent the wheel, here. You can start with jconsole, which ships with your JDK: just run jconsole [pid] and jconsole will connect to the (locally) running process and let you observe everything via JMX.

If you want remote access to JMX-exposed information, you can use Tomcat's manager webapp along with the included jmxproxy servlet which allows you to remotely perform simple queries to get (and set) JMX properties.

There are other more fully-featured projects such as Jolokia ( http://www.jolokia.org/) that do similar kinds of things.

Assuming that you are using something like Nagios to automatically observe your Tomcat instance, something you definitely don't want to do it spin-up a JVM and make a remote (or even local) JMX connection to inspect a single JMX property (and then do that 5 times to observe 5 different properties, then do those 5 samples every 5 minutes, or 1 minute, or whatever). Instead, you probably want to use a proxy like one described above.

We've had great success coupling Nagios with the Tomcat manager's jmxproxy servlet. It will likely meet your needs for quite a while.

In terms of programmatically using JMX, there are a number of client classes out there. Here's my SimpleJMX project. With it you can use the JmxClient object to connect to and interrogate remote JVMs:

JmxClient client = new JmxClient("remote.sever.name", remotePortNumber);
Set<ObjectName> objectNameSet = client.getBeanNames();
...

Here are the javadocs for JmxClient.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!