HOME
Library
JRobin API
Utilities
Support
About Us
Forum

 

SourceForge.net Logo 

Get Firefox

 

 

Quick reference

Here is the list of some most commonly used RRDTool commands and command line switches with a proper translation to Java (JRobin API). It's quite straightforward:

RRDTool command...

...in JRobin API

CREATE

rrdtool create test.rrd RrdDef rrdDef = new RrdDef("test.rrd");
--start 1000111222 rrdDef.setStartTime(1000111222L);
--step 300 rrdDef.setStep(300);
DS:input:COUNTER:600:0:U rrdDef.addDatasource("input", "COUNTER", 600, 0, Double.NaN);
RRA:AVERAGE:0.5:6:700 rrdDef.addArchive("AVERAGE", 0.5, 6, 700)
[Enter] RrdDb rrdDb = new RrdDb(rrdDef);

UPDATE

rrdtool update test.rrd RrdDb rrdDb = new RrdDb("test.rrd");
Sample sample = rrdDb.createSample();
1000111222:23.45:U sample.setTime(1000111222L);
sample.setValue(0, 23.45);
sample.setValue(1, Double.NaN);
-t input:output
1000111222:12.345:U
sample.setTime(1000111222L);
sample.setValue("input", 12.345);
sample.setValue("output", Double.NaN);
[Enter] sample.update();

LAST

rrdtool last test.rrd RrdDb rrdDb = new RrdDb("test.rrd");
[Enter] long lastUpdateTime = rrdDb.getLastUpdateTime();

FETCH

rrdtool fetch test.rrd RrdDb rrdDb = new RrdDb("test.rrd");
AVERAGE
--start 1000111222
--end 1000222333
FetchRequest req = rrdDb.createFetchRequest("AVERAGE",
1000111222L, 1000222333L);
AVERAGE
--start 1000111222
--end 1000222333
--resolution 600
FetchRequest req = rrdDb.createFetchRequest("AVERAGE",
1000111222L, 1000222333L, 600);
[Enter] FetchData fetchData = req.fetchData();

DUMP

rrdtool dump
test.rrd > test.xml
RrdDb rrdDb = new RrdRb("test.rrd");
[Enter] rrdDb.dumpXml("test.xml");

RESTORE

rrdtool restore
new.rrd old.xml
[Enter]

RrdDb rrdDb = new RrdDb("new.rrd" "old.xml");

GRAPH

rrdtool graph
traffic.png
RrdGraphDef def = new RrdGraphDef();
String pngFile = "traffic.png";
--start 1000111222
--end 1000222333
def.setTimePeriod(1000111222L, 1000222333L);
--start "10/25/2003"
--end "10/28/2003"

def.setTimePeriod(Util.getTimestamp(2003, 9, 25),
Util.getTimestamp(2003, 9, 28));*

-w 400 -h 200 int pngWidth = 400, pngHeight = 200;
-v "this is y-axis" def.setVerticalLabel("this is y-axis");
-t "this is graph title" def.setTitle("this is graph title");

--lower-limit 1000.0
--upper-limit 2000.0
--rigid

def.setGridRange(1000.0, 2000.0, true);
--background image_path def.setBackground("image_path");
--color BACK#FF0080 def.setBackColor(new Color(0xFF, 0x00, 0x80));
--color CANVAS#FF0080 def.setCanvasColor(new Color(0xFF, 0x00, 0x80));
--base 1024 def.setBaseValue(1024);
--units-exponent 6 def.setUnitsExponent(6);
--no-legend def.setShowLegend(false);
DEF:in=traffic.rrd:input:AVERAGE def.datasource("in", "traffic.rrd", "input", "AVERAGE");
CDEF:in1=in,8,* def.datasource("in1", "in,8,*");
CDEF:in2=rpn_expression def.datasource("in2", "rpn_expression");
LINE1:in#0000FF:"input" def.line("in", new Color(0, 0, 0xFF), "input");
AREA:in1#00FF00:"input 1" def.area("in1", new Color(0, 0xFF, 0), "input 1");
STACK:in2#FFFF00:"input 2\r" def.stack("in2", new Color(0xFF, 0xFF, 0), "input 2@r");
COMMENT:"This is a comment" def.comment("This is a comment");
GPRINT:in:AVERAGE:
"avg=%.2lf %sbits/sec"
def.gprint("in", "AVERAGE", "avg=@2 @sbits/sec");
GPRINT:in1:MAX:
"avg1=%5.2lf %Sbits/sec\r"
def.gprint("in1", "MAX", "avg1=@5.2 @Sbits/sec@r);
[Enter] RrdGraph g = new RrdGraph(def);
g.saveAsPNG(pngFile, pngWidth, pngHeight);**

XPORT

rrdtool xport
--start 1000111222
--end 1000222333
RrdExportDef def =
new RrdExportDef(1000111222L, 1000222333L);
DEF:xval=test.rrd:x:AVERAGE def.datasource("xval", "test.rrd", "x", "AVERAGE");
XPORT:xval:"X values" def.export("xval", "X values");
--maxrows 100 RrdExport export = new RrdExport(def);
ExportData data = export.fetch(100);
[Enter] System.out.println(data.exportXml());

TUNE***

rrdtool tune file.rrd
--heartbeat input:600 
RrdToolkit toolkit = RrdToolkit.getInstance();
toolkit.setDsHeartbeat("file.rrd", "input", 600);
rrdtool tune file.rrd
--maximum input:10000
RrdToolkit toolkit = RrdToolkit.getInstance();
toolkit.setDsMaxValue("file.rrd", "input", 10000, false);

Simple, isn't it?

(*) Java months are zero based.
(**) PNG format should be your first choice. However, JRobin supports GIF and JPEG formats too.
(***) JRobin's RRDToolkit class is not fully compatible with rrdtool tune command but has some interesting features (to add/remove datasource/archive for example) that cannot be found in RRDTool. 

Back to the top

Copyright © 2003, 2004 Sasa Markovic & Arne Vandamme. All Rights Reserved.