Using #Jolokia and JSON to display JMX data in #SAPNWCloud
I’ve always been interested in Java Management Extensions (JMX) as a means to monitor data from Java applications. It is standardized, present in most application servers and you can easily add it to your own applications as well.
If you are thinking about adding real-time monitoring to your applications (how many purchase orders in the last hour, average time needed to access your back-end CRM system ,etc), it is a perfect fit.
The only problem is that the tools to monitor JMX have usually been pretty old school, much too complex and too heavy for modern web architectures.
I was looking for a new way to access JMX data
.
Enter Jolokia
What is Jolokia?
Jolokia is a JMX-HTTP bridge giving an alternative to JSR-160 connectors. It is an agent based approach with support for many platforms. In addition to basic JMX operations it enhances JMX remoting with unique features like bulk requests and fine grained security policies.
It has various clients (including Javascript, Java and Perl) and it allows you to access the data via JSON.
It was the perfect choice to access the JMX data that I wanted to read.
The problem was that I was really lazy and I didn’t want to write my own UI to access this JSON data.
I saw that the Jolokia’s developer (Roland Huß) had also developed Aji – which was “Jolokia’s fancy sister” and was a dashboard for JSON-based JMX data. The application on github was definitely a work in progress but I decided to try it out and see if it would work.
I downloaded the war, had to change the name of a file “\app\aji\Mediator.js” to “mediator.js” but I got part of the app working. Starting the app with the “/aji/app/” URL, I could see the JMX-based data in my Tomcat.
What I liked about the app was its amazing small footprint of just 470 Kb and the fact that it is primarily JavaScript rather than Java code. The application didn’t include any graphs and there was no real-time updating of data but I could still could explore the data.
Deploying Aji to NetWeaver Cloud
I then decided to deploy Aji to NetWeaver Cloud.
I used maven to deploy the app and it worked without a problem.
With the MBean browser, I could explore the underlying MBeans from the platform.
If you take a look at the network traffic, you see that that JSON is being passed to the browser to be displayed. Here is an example:
{“timestamp”:1350877265,”status”:200,”request”:{“path”:”java.lang\/name=CodeCacheManager,type=MemoryManager”,”type”:”list”},”value”:{“desc”:”Information on the management interface of the MBean”,”attr”:{“Name”:{“desc”:”Name”,”type”:”java.lang.String”,”rw”:false},”MemoryPoolNames”:{“desc”:”MemoryPoolNames”,”type”:”[Ljava.lang.String;”,”rw”:false},”Valid”:{“desc”:”Valid”,”type”:”boolean”,”rw”:false}}}}
Here are some screenshots:
The MBean “com.sap.mbean” shows me information about my application
The MBean “com.sap.js” / Type: “RequestProcessor Metrics” shows me performance information about my application
The MBean “com.sap.js” / Type: “SAPJVMMetrics” shows me JVM-specific performance information about my application.
The MBean “sap.management” / Type: “GCProblemReporting” shows me GC-specific performance information about my application.
There are other MBeans to explore so go ahead and take a look on your own.
Why is this important?
Although I had fun exploring the internals of the NetWeaver Cloud server, I was more interested in the potential of this functionality for applications deployed on the platform. Some might say that such information could be directly accessed via JSON without the intermediary of JMX but many existing Java applications that run in enterprises use JMX to publish metrics and Jolokia allow this information to be easily surfaced. A another potential problem is that NWCloud services don’t or can’t have a http interface and a JMX interface might be possible
There is also an Operations Cockpit being developed by SAP Labs for NetWeaver. I don’t know the internals of this functionality but it could also be using the JMX Interface.
With Jolokia, developers on NetWeaver Cloud could easily built dashboards to make sure that their applications are running correctly. I just heard that upcoming versions of SAPUI5 will include D3. There is a cool demo of what is possible with D3 / cubism on the Jolokia site. You could imagine a very cool dashboard for your NWCloud-based app based on these technologies.
Have fun.
Pretty cool stuff, and thorough write-up! This is definitely something I want to try out myself.
The JMX capabilities may just be the bulletpoint that will convince prospective clients to invest in moving their apps to NetWeaver Cloud