[rrd-users] Re: COUNTER to DERIVE

Dave Plonka plonka at doit.wisc.edu
Fri Dec 29 17:12:14 MET 2000



David,

Let me preface this by saying that I might not have a deep
understanding of DERIVE, since I don't use it.  I've just read the
description in the "rrdcreate" man page.

On Fri, Dec 29, 2000 at 09:08:10AM -0500, David Koski wrote:
> 
> I'm about ready to take the plunge and re-do my RRDs from there intial set
> to COUNTER to DERIVE as set about a year and a half ago.

I'm curious what sort of data it is that you are collecting.

It seems to me that you wouldn't want to convert something that had
been stored as a COUNTER type (such as a contiuously increasing SNMP
counter) to a DERIVE type cuz your going to get a huge anomaly in the
graph every time the counter wraps around.  Presumably the value will
drop dramatically at those times, and DERIVE will record a huge
negative delta value, no?

If you're saying that what you were collecting shouldn't have been a
COUNTER in the first place, should it have been a GAUGE instead?  I can
see, as Tobi describes in the "rrdcreate" man page, why one might wish
to convert a GAUGE type to a DERIVE type.

> Is there a
> simple way to do this since COUNTER and DERIVE really are the same minus
> the Counter roll logic?  So far the only suggested way I have is to unload
> the data, recreate the RRD and reload the data, but for several thousand
> RRD files, this would be a mess frankly.  Is there any other way suggested
> way?  I noticed rrd tune has an option to alter the data-source type, but
> don't know if this would be wise on an already populated RRD (Its still
> messy as well but more manageable than unloading and reloading), the other
> problem is writing a script to detect its a COUNTER and does the change,
> since I have several hundred GAUGE RRDs as well...

An alternative would be to use dump and restore, and perl or something
to intelligently edit the files in between:

   $ rrdtool dump file.rrd > file.xml
   $ perl -pi -e 's/COUNTER/DERIVE/' file.xml # do some intelligent edit
   $ mv file.rrd file.rrd_backup              # save the original!
   $ rrdtool restore file.xml file.rrd

About manipulating RRD data in general, using dump and restore is the
key.  Between those operations, you can use an XML parser to manipulate
the raw data.

I like to work in perl and there is a reasonable XML::Parser for perl,
and other modules layered atop, like XML::Simple.  I have hacked
XML::Simple to work with the XML from "rrdtool dump".  You can find
that modified module embedded within this "log2rrd" utility:

   http://net.doit.wisc.edu/~plonka/log2rrd/

which tries to convert MRTG log files to RRD files.

Since I wrote log2rrd, Tobi developed other ideas about how best to
convert from old MRTG log files, so my util is now defunct - perhaps
now just an example of how one can manipulate RRD files using XML in
perl.

One last disclaimer - of course you can do major damage to RRD files by
manipulating their raw values.  No warranties.  Test! Test! Test! after
you make changes.

Dave

-- 
plonka at doit.wisc.edu  http://net.doit.wisc.edu/~plonka  ARS:N9HZF  Madison, WI

--
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
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list