3

I can't manage to create an archive with the correct type. What am I missing? My example is very similar to the official example on https://code.google.com/p/rrd4j/wiki/Tutorial

RRD creation:

rrdDef.setStartTime(L - 300);
rrdDef.addDatasource("speed", DsType.GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addArchive(ConsolFun.MAX, 0.5, 1, 24);
rrdDef.addArchive(ConsolFun.MAX, 0.5, 6, 10);

I add some values: (1,2,3 for each step)

long x = L;
while (x <= L + 4200) {
   Sample sample = rrdDb.createSample();
   sample.setAndUpdate((x + 11) + ":1");
   sample.setAndUpdate((x + 12) + ":2");
   sample.setAndUpdate((x + 14) + ":3");
   x += 300;
}

And then I fetch it:

FetchRequest fetchRequest = rrdDb.createFetchRequest(ConsolFun.MAX, (L - 600), L + 4500);
FetchData fetchData = fetchRequest.fetchData();
String s = fetchData.dump();

I get the result: (hoping to find the maximum)

920804100:  NaN  
920804400:  NaN  
920804700:  +1.0000000000E00  
920805000:  +1.0166666667E00  
920805300:  +1.0166666667E00  
...
920808600:  +1.0166666667E00  
920808900:  +1.0166666667E00  
920809200:  NaN

I would like to see the maximum value here. Tried it with total as well, and I get THE SAME result.

What do I have to change, so I get the greatest value sent in one step, or to get the sum of the values sent in one step.

Thanks

Jakabfi Attila
  • 367
  • 3
  • 16

1 Answers1

0

The MAX is not the maximum value input but the maximum consolidated data point. What you're saying to rrd given your example is

  1. At one point in time I'm going 1MPH
  2. One second later I'm going 2MPH
  3. Two seconds later I'm going 4MPH

rrd now has 3 data points covering 3 seconds of a 300 second interval. What should rrd store? 1, 2, or 3? None of the above it has to normalize the data in some way to say between X and X+STEP the rate is Y.

To complicate matters it's not for certain that your 3 data points are landing in the the same 300 second interval. Your first 2 data points could be in one interval and the 4MPH could be in the next one. This is because the starting data point stored is not exactly start+step. i.e. if you start at 14090812456 it might be something like 14090812700 even though your step is 300

The only way to store exact input values with GAUGE is to push updates at the exact step times rrd store the data points. I'm going 1MPH at x, 2MPH at x+300, 4MPH at x+300 where x starts at the first data point.

Here is a bash example showing this working using your rrd settings, I'm using a constant start time and x starting at what I know is rrd's first data point.

L=1409080000
rrdtool create max.rrd --start=$L DS:speed:GAUGE:600:U:U RRA:MAX:0.5:1:24 RRA:MAX:0.5:6:10
x=$(($L+200))
while [ $x -lt $(($L+3000)) ]; do
        rrdtool update max.rrd "$(($x)):1"
        rrdtool update max.rrd "$(($x+300)):2"
        rrdtool update max.rrd "$(($x+600)):3"
        x=$(($x+900))
done

rrdtool fetch max.rrd MAX -r 600 -s 1409080000
                          speed

1409080200: 1.0000000000e+00
1409080500: 2.0000000000e+00
1409080800: 3.0000000000e+00
1409081100: 1.0000000000e+00
1409081400: 2.0000000000e+00
1409081700: 3.0000000000e+00
1409082000: 1.0000000000e+00

Not really that usefull but if you increase the resolution to say 1200 seconds you start getting max over larger time intervals

rrdtool fetch max.rrd MAX -r 1200 -s 1409080000
                          speed

1409081400: 3.0000000000e+00
1409083200: 3.0000000000e+00
1409085000: nan
1409086800: nan
1409088600: nan
Dustin Butler
  • 818
  • 7
  • 22