|
Project Information
Featured
Downloads
Links
|
Highlights
Read about CfTracker's RRD4J usage! Usage Exampleimport org.rrd4j.code.*;
import static org.rrd4j.DsType.*;
import static org.rrd4j.ConsolFun.*;
...
// first, define the RRD
RrdDef rrdDef = new RrdDef(rrdPath, 300);
rrdDef.addArchive(AVERAGE, 0.5, 1, 600); // 1 step, 600 rows
rrdDef.addArchive(AVERAGE, 0.5, 6, 700); // 6 steps, 700 rows
rrdDef.addArchive(MAX, 0.5, 1, 600);
// then, create a RrdDb from the definition and start adding data
RrdDb rrdDb = new RrdDb(rrdDef);
Sample sample = rrdDb.createSample();
while (...) {
sample.setTime(t);
sample.setValue("inbytes", ...);
sample.setValue("outbytes", ...);
sample.update();
}
rrdDb.close();
// then create a graph definition
RrdGraphDef gDef = new RrdGraphDef();
gDef.setWidth(500);
gDef.setHeight(300);
gDef.setFilename(imgPath);
gDef.setStartTime(start);
gDef.setEndTime(end);
gDef.setTitle("My Title");
gDef.setVerticalLabel("bytes");
gDef.datasource("bytes", "myrrdpath", "inbytes", AVERAGE);
gDef.hrule(2568, Color.GREEN, "hrule");
gDef.setImageFormat("png");
// then actually draw the graph
RrdGraph graph = new RrdGraph(gDef); // will create the graph in the path specifiedGo through the source of Demo for more examples. Supported DatabasesNext to memory and file storage, RRD4J supports the following databases (using byte array storage):
ClojureThanks to the rrd4clj project Clojure now has a RRD API (using RRD4J). Check out their examples. Contributing to RRD4JIf you are interested in contributing to RRD4J, start by posting patches to issues that are important to you. Subscribe to the discussion group and introduce yourself. If you can't contribute, please let us know about your RRD4J use case. Always good to hear your stories! Graph Examples (from the JRDS project)
|