# [rrd-users] Re: binary value

alex at ergens.op.Het.Net alex at ergens.op.Het.Net
Sun Mar 5 10:39:28 MET 2000

```Gilles Lamiral wrote:
>
> I want to fetch binary value, 0 and 1 (and NaN, if any)
> At least in the small granular base, I want to keep those
> binary value. How can I do ?

This is not so hard to do as it looks.  You have to understand *when*
RRDtool will change values.

An example is in place here.  Suppose you are monitoring the following
values at the following times:

time 0:00:00 value 0
time 0:02:30 value 1
time 0:05:00 value 0
Also assume that the step time is five minutes.

What is going to happen?  During one interval, the value has been
0 for half of that interval and it has been 1 for the other half.
This means that the average value will be 0.5 ...

The minimum value will be 0, the maximum value will be 1.

So, to prevent RRDtool from doing this, apply that same logic to the
values and now it is easy to understand that you should have the same
value during a complete interval.  This means that you should enter the
values at exactly the time that RRDtool is expecting them.  Also, you
cannot consolidate the values into larger intervals unless you are
willing to get those halves.

The only way to get rid of an NaN value is to average it out by using
the xff factor.  You specify that all primary datapoints from which a
consolidated is built must be valid ones (not NaN) by using a xff factor
of 0.

(Note: times are valid for the MET timezone; change where needed)

rrdtool create bit.rrd --start 952210799    \
--step 300           \
DS:bit:GAUGE:300:0:1 \
RRA:AVERAGE:0:1:6    \
RRA:AVERAGE:0:2:4
rrdtool update bit.rrd \
952210800:1 \
952211100:1 \
952211400:1 \
952211700:1 \
952212000:0 \
952212300:1 \
952212600:1 \
952212900:1 \
952213200:1

This will insert all values in the RRD.  The first RRA will contain the
last 6 values, the second RRA will be built from the last 8 values.

RRDtool will choose the best available RRA when it fetches data from the
database.  If you store 6 intervals in one RRA you can fetch at most 30
minutes worth of data from it:
rrdtool fetch bit.rrd AVERAGE --start 952211400 --end 952213200
bit

952211400:           NaN
952211700:          1.00
952212000:          0.00
952212300:          1.00
952212600:          1.00
952212900:          1.00
952213200:          1.00

When you ask more data from it, it will use the next RRA:
rrdtool fetch bit.rrd AVERAGE --start 952211100 --end 952213200
bit

952210800:           NaN
952211400:          1.00
952212000:          0.50
952212600:          1.00
952213200:          1.00

regards,
--
__________________________________________________________________
/ alex at slot.hollandcasino.nl                  alex at ergens.op.het.net \
| work                                                         private |
| My employer is capable of speaking therefore I speak only for myself |
+----------------------------------------------------------------------+

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users

```