pan-european network solutions
dns|europe logo
Open Source

RRDJTool

Round Robin Database Java Tool

If you like Tobi Oetiker's excellent RRDTool and Java as much as I do, try this:

rrdjtool-1.0.1.tar.gz

It's a single class (Rrd.java) which performs RRD calls using Java native interface (JNI). Currently, it's tested on Linux platform only and supports the following RRD commands:

  • rrdcreate
  • rrdupdate
  • rrdgraph
  • rrdlast
  • rrdfetch.

Suppose you want to execute the following RRD command from Java:

String rrdCmd = "create temperatures.rrd " +
   "--start 999999999 --step 300 " +
   "DS:temp1:GAUGE:1800:U:U " +
   "DS:temp2:GAUGE:1800:U:U " +
   "RRA:AVERAGE:0.5:1:600 " +
   "RRA:AVERAGE:0.5:6:700 " +
   "RRA:AVERAGE:0.5:24:700 " +
   "RRA:AVERAGE:0.5:288:700 ";

Without JNI, you are forced to do it using slow and inefficient system calls:

System.exec("/path_to_rrdtool_binary/rrdtool " + rrdCmd);

With Rrd.java, it's more natural:

Rrd.getInstance().create(rrdCmd);

RrdException is thrown if any RRD command fails.

The point is: JNI calls are much, much faster than System.exec() calls.

Before you start using Rrd.class, you have to create libjrrd.so (this library provides necessary JNI support). Compiling instructions along with the Makefile for linux can be found in the /native directory of this distribution. Once you build this library, place it in some standard library folder, or update LD_LIBRARY_PATH environment variable to point to the /native directory.

Source code and full javadoc are included.

I hope than one day we'll see java language suport included in the RRDTOOL source code distribution.

Sasa Markovic
sasam@dnseurope.co.uk