Wednesday Jan 04, 2006

Recently I've been putting together some scripts to extract performance data from various log files on a particular cluster of www.sun.com servers - there have been intermittent performance issues and I have been tried to zone in on the source.

At this point, I have scripts that will record vmstat data, web page accesses and errors, as well as detailed GC data from the application server JVM and load them into a database.

What I had been lacking was a way to turn that data into some pretty graphs. For a few days, I had just been building a CSV file from the data and loading it into StarOffice to produce a graph. But that quickly became pretty tedious. So I started looking at packages out there which might help.

All I really wanted to do was graph some simple time-series charts for various data points, for  example, CPU usage at 15 minute intervals for each day. After a little bit of searching I came across JFreeChart, and after looking at the demo page,  JFreeChart seemed like it would fit the bill, so I decided to take a closer look.

Unfortunately finding information on how to use the API was a little challenging. The JFreeChart developer's have an interesting business model where the API is free, but you have to buy their book to understand how to use it. That's fine, I can go ahead and  buy the book, but I want to start tinkering NOW.

I did find a couple of articles which got me started in the right direction. A Javaworld article titled Chart a new course with JFreeChart which provided some snippets of code on how to create various types of charts. And I also found a DevChannel article titled Data driven graphics with JFreeChart which provided a complete sample program.

From these articles I was able to pretty quickly put together some utilities that read data directly from the database I have my profile data in and graph them out in various ways.  Here's an example chart from one of the more interesting days when the garbage collector got a little jiggy with it - still trying to figure out what when on there, the JVM did seem to recover the next day which is a little interesting.

Anyways, anyone looking for some graphing/charting software for Java, I'd definitely recommend taking a look at JFreeChart.

This blog copyright 2009 by mock