Create new RRD file
rrd:
rrdtool create test.rrd --step 300 \ DS:input:COUNTER:600:0:U \ DS:output:COUNTER:600:0:U \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ RRA:AVERAGE:0.5:24:797 \ RRA:AVERAGE:0.5:288:775 \ RRA:MAX:0.5:1:600 \ RRA:MAX:0.5:6:700 \ RRA:MAX:0.5:24:797 \ RRA:MAX:0.5:288:775
jrobin
// create new RRD definition RrdDef def = new RrdDef("test.rrd", 300); def.addDatasource("input", "COUNTER", 600, 0, Double.NaN); def.addDatasource("output", "COUNTER", 600, 0, Double.NaN); def.addArchive("AVERAGE", 0.5, 1, 600); def.addArchive("AVERAGE", 0.5, 6, 700); def.addArchive("AVERAGE", 0.5, 24, 797); def.addArchive("AVERAGE", 0.5, 288, 775); def.addArchive("MAX", 0.5, 1, 600); def.addArchive("MAX", 0.5, 6, 700); def.addArchive("MAX", 0.5, 24, 797); def.addArchive("MAX", 0.5, 288, 775); // RRD file definition is completed, create the database! RrdDb rrd = new RrdDb(def); // by this point, file "test.rrd" can be found on your disk
Update RRD files
rrd:
rrdtool update test.rrd timestamp:inputValue:outputValue
jrobin
// open the file RrdDb rrd = new RrdDb("test.rrd"); // obtain values for timestamp, inputValue and outputValue somehow long timestamp = ...; // without milliseconds, rounded to the neares second (see notes) double inputValue = ...; double outputValue = ...; // create new, empty data sample using RRD file reference: Sample sample = rrd.createSample(timestamp); // put datasource values in your sample sample.setValue("input", inputValue); // or: sample.setValue(0, inputValue) sample.setValue("output", outputValue); // or: sample.setValue(1, outputValue); // update rrd file sample.update();