Is there any JMX - REST bridge available?

2019-02-06 01:41发布

Hi I would like to monitor a Java application using the browser but at the same time utilising the existing JMX infrastructure.

I know that JMX provides a HTTP interface but I think it provides a standard web gui and its not possible to mashup its functionality with an existing system.

Are you aware of any REST interface for JMX?

My research on google currently shows that there is one project which does something similar. Is this the only option?

标签: http rest jmx
5条回答
【Aperson】
2楼-- · 2019-02-06 02:24

Jolokia is a new (at this time) JMX Agent you can install in your JVM and exposes the MBeanServer over HTTP in JSON format.

查看更多
不美不萌又怎样
3楼-- · 2019-02-06 02:33

For posterity, I've recently added a little web server to my SimpleJMX package. It exposes beans from the platform MBeanServer to HTTP via Jetty if in the classpath. There is also text versions of all pages that make it easy to scrape.

// create a new JMX server listening on a specific port
JmxServer jmxServer = new JmxServer(8000);
jmxServer.start();

// register any beans to jmx as necessary
jmxServer.register(someObj);

// create a web server publisher listening on a specific port
JmxWebServer jmxWebServer = new JmxWebServer(8080);
jmxWebServer.start();

There's a little test program which shows it in operation. Here's an image of java.lang:type=Memory accessed from a browser. As you can see the output is very basic HTML.

enter image description here

查看更多
你好瞎i
4楼-- · 2019-02-06 02:39

Tomcat provides a JMX Proxy Servlet in its Manager Application. I don't think it's exactly REST, but it's stateless and is built from simple HTTP requests, so it should be close enough.

查看更多
再贱就再见
5楼-- · 2019-02-06 02:39

You might want to have a look at jmx4perl. It comes with an agent servlet which proxies REST request to local JMX calls and returns a JSON structure with the answers. It supports read, write, exec, list (list of mbeans) and search operations and knows how to dive into complex data structures via an XPath like expression. Look at the protocol description for more details.

The forthcoming release can deal with bulk (== multiple at once) requests as well and adds the possibility to post a JSON request as alternative to a pure REST GET-request.

In one of the next releases there will support a proxy mode so that no agent servlet needs to be deployed on the target platform, but only on an intermediate, proxy server.

查看更多
趁早两清
6楼-- · 2019-02-06 02:41

MX4J is another alternative., quoting below from the it's home page -

MX4J is a project to build an Open Source implementation of the Java(TM) Management Extensions (JMX) and of the JMX Remote API (JSR 160) specifications, and to build tools relating to JMX.

查看更多
登录 后发表回答