# [rrd-users] Re: How to obtain a summary

Alex van den Bogaerdt alex at ergens.op.het.net
Wed Oct 16 23:50:07 MEST 2002

```On Wed, Oct 16, 2002 at 05:00:07PM -0300, Roberto Machado wrote:

> I learned how to use CDEF an INF / UNKN to display a background for
> values based on a threshold (ok, critical, warning, etc).

good.  That's half of the job.

> But how do I make a CDEF to state, within the time period specified in
> the graph, how long is it in a certain state. For instance, CPU
> consumption. I can track it and make a red background when cpu
> consumption is above 70%. But can I GPRINT something like:
>
> 35% of the time - CRITICAL
> 20% of the time - WARNING
> 45% of the time - OK
>
> Using CDEFs?

A percentage is nothing more than " x out of 100 ".

Each interval is a fixed portion of time.  Each interval is in the "critical"
state or it isn't.  For each interval, it is 100% critical or it is 0% critical.

Just calculate this using an IF statement:

CDEF:critical=value,12345,GT,100,0,IF

This will set "critical" to 100 when "value" exceeds 12345.  It will do this for
each (known) interval.

The nice thing about RRDtool is that it will do the averaging for you.  If one
out of four intervals is 100%, the average will be 25%.  You don't need to keep
track of the total number of intervals, RRDtool will do this for you.  Just GPRINT
the average of "critical".

Of course you need to duplicate and tailor the example CDEF to suit your needs.

If memory serves me well, any interval that's unknown is *not* counted.  This means
that the following range:  " 10 20 NaN 30 40 " will show 25% above 39, 50% below 21
and so on.  If you don't like this, make sure you have no NaN (see the tutorial if
you don't know how).

HTH
Alex

--
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