[rrd-users] Re: gauge graph

Alex van den Bogaerdt alex at ergens.op.het.net
Sun Sep 25 05:14:41 MEST 2005

On Thu, Sep 22, 2005 at 07:08:46PM +0200, Sam wrote:
> How do i create a graph dat ever increases?

The most easy way is to have a counter, and insert that into
RRDtool as if it were a gauge.  Then of course you have another
problem: how do you get that counter.  An external script could
solve this problem for you if RRDtool cannot do it.

> I have MRTG update the rrd files.
> the rrd files contain bits in and out of switch ports.

Bytes more likely ?  Make sure you know this for sure.

> i need 2 graphs.
> 1) bandwidth usage (that's easy, got that)
> 2) monthly usage.
>     i want to display the current (or past) month showing the bytes sent
> of that month only per day (increasing).
>    so that you can see the total at the end of month.

This means you want to start with the first interval in a month and
add up all rates multiplied by time.

You use MRTG, do you have the default time span of MRTG ?
If so, you will need to use the RRA that covers 2 hours per row. Most
time zones in the world will not be perfectly aligned to that, midnight
will not always be on a boundary.  For instance, my time zone is aligned
during the summer but not during the winter.  This will introduce a
slight inaccuracy.  A similar problem occurs when consolidation is
necessary to make the graph fit in the available space.

See my site for some explanation on this.

You will want to use RRDtool version 1.2 do to the work.

To start experimenting:
(please note: I did not test anything.  I'm thinking out loud, you can
pick up the pieces if it breaks).

Outside RRDtool determine the first of the month, for instance using
the unix command "date" like this:  date +%Y%m01
Use variable substitution to enter it in your rrdtool graph command.
I use "20050901" in my example.


Now you need a CDEF to do the work.  Adding a number to an unknown
number results in an unknown number.  You really could do without,
as this would mean you _always_ end up with an unknown.

So, at least you're going to need:


You want to use the current rate and each previous one. This means
you need to remember it.  You need to access the same CDEF so you
will need to use PREV, not PREV(x).


Now comes the dificult part: you need to multiply by time.  Chances
are this is hard to find out, unless you are very accurate.  Consolidation
may occur, multiplying by 7200 will not always be right unless a complete
month will fit in the graph.  Some months have 30 days, some have 31 days,
february has 28 or 29 days.  Each day has 12 periods of 2 hours.  Your
graph width will have to match that; somewhere between 336 and 372 pixels.
Or maybe you just always display 31 days, possibly showing a bit of last
month as well.

Multiplying itself is easy.  each row had to be multiplied by 7200 but
as x1*7200+x2*7200+x3*7200... equals 7200*(x1+x2+x3...) you only have
to do this once:


Then you graph ds0thismonthstotals as usual.

Of course you want to check your results.  Use TOTAL and LAST to compare:

GPRINT:ds0thismonthcomputedtotal:"Computed total: %lf\n"
GPRINT:ds0thismonthstotalsmaximum:"Seen total: %lf\n"

TOTAL is an internal computation of all rates times all times.
MAXIMUM just looks at the image you created and reports the
highest value.  These two should more or less match (preferably
be an exact match).

Please report any progress, I'm curious myself!
Alex van den Bogaerdt

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://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi

More information about the rrd-users mailing list