[rrd-users] Is it possible to create the rrd database by reading from a file?

David Ball davidtball at gmail.com
Sat May 19 04:56:47 CEST 2007

  I guess it would help to understand what exactly you're trying to
graph, and how you expect it to look.  If your value isn't numeric,
how will it know where to place the value in your graph with respect
to the Y axis ?
  As for your questions:
1) see above
2) the --step parameter indicates how far apart RRDTool expects the
timestamps to be, so as you have it currently, you'd need a --step of
'1', which I've never tried.  Also, your DS does not appear to be
defined properly.  See
 for more detail and formatting.  As well, the --start parameter
expects a unix timestamp, although it can be any number as long as
subsequent updates are within range.  In your case, your --start would
have to be '1' as well.
2b) see above URL for detail on defining an RRA as well. Although, I'm
not sure what you'd be defining in your RRA if your values are

   RRDTool required A LOT of reading and patience on my part in order
to get familiar with it, and I still consider myself a newb.  Lots of
google searching to find examples helped as well, so you may wish to
go that route to see if anyone else has tried something similar to
what you're trying.


On 5/18/07, betamaz <betamaz at gmail.com> wrote:
> Hi,
> I've some questions about scripting creation of the rrdtool database. Since,
> my use of the rrdtool is a bit different from most examples which involve
> incremental updates to the database of integers, i'm having some trouble
> understanding the parameters. currently i'd like to create a database from
> the static input file of pc counters which looks like below:
> [traces]$ head -n 20 ~/input.log
> 1:c0103b74
> 2:c0103b79
> 3:c0103bf4
> 4:c0103bf5
> 5:c0103bf6
> ...
> ...
> Q1:  Tor the time attribute that rrdtool needs--for now-- i've added an
> arbitrary value to represent time ticks. The second column is not of a
> number format--though the pc which is in hex can easily be coverted to a
> number format. This brings me to my first question: Is it possible to plot
> time versus a non integer value using rrdtool?
> Q2.a: In the below script--which i've written up based on Simon's
> pseudocode--are the "rrdtool create" parameters correct? Specifically, since
> i'm reading from a file, what should the increment option --step be
> (currently it's set to 60, because else i'd get an error saying "ERROR: step
> size should b no less than one second"). In the rrdtool create
> documentation, i did not see a option for the create command to specify that
> the intervals should be right after each other with no wait time in between
> (since i'd like to read from a file and stop adding to the database
> afterwards).
> Q2.b: Also, when specifying the Round Robin Arhive, what is the format for
> specifying data source is from a file?  I've tried variation of the line
> "DS:input:ABSOLUTE:$INPUT_FILE, all without success.
> -------------------------------------------------------------------------
> #!/bin/sh
> rrdtool="/usr/local/rrdtool-1.2.19/bin/rrdtool"
> delim=":"
> if [ ! -f $INPUT_FILE ]; then
>     print "File $INPUT_FILE not found"
>     exit 1
> fi
> rrdtool create datafile.rrd \
>     --start N --step 60 \
> cat $INPUT_FILE | while read line
> do
>     #timestamp="$(echo ${line} | cut -d: -f1)"
>     #pc="$(echo ${line} | cut -d: -f2)"
>     while (read -u 0 -d ":" timestamp value)
>     do
>         echo "$timestamp - $pc"
>         #rrdtool update datafile.rrd $timestamp:$pc
>     done
> done
> #rrdtool create graph
> -------------------------------------------------------------------------
> Thank you for your help,
> -Bita.
> On 5/16/07, Simon Hobson <linux at thehobsons.co.uk> wrote:
> > betamaz wrote:
> > >I'm new to rrdtool and have been reading up on the tutorial posted
> > >on the main webpage. The examples in the tutorial describe how to
> > >create a database by taking measurements. For example, using snmp or
> > >it gives basic examples where the inputs are via the rrdtool create
> > >command line (for example the speed inputs for test.rrd). Is there a
> > >way, to read inputs from command line and create a database out of
> > >that (similar to gnuplot)?
> >
> > Yes, RRD doesn't care where the data comes from, all it sees are a
> > series of update with timestamp and a number of values. As long as
> > the timestamps a) make sense for the data, and b) are always
> > increasing, then rrd will handle it.
> >
> > So assuming you have a file containing a series of records, one per
> > line, of the form time:value then you simply need to write a script
> > of the form :
> >
> > create rrd file
> > while (read timestamp:value pair)
> >    update rrd with timestamp and value
> > done
> > create graph
> >
> >   With the exception of drawing a graph which normally takes a few
> > lines of arguments, the above can be written in about the same number
> > of statements in most languages (whether that be Bash shell script,
> > Perl, ...). How much extra checking etc you put in is up to you and
> > what you know about the source of the data - such as is the file
> > format likely to be correct (ie it's created by a trustworthy
> > automated tool) or do you need to do extensive validation on the
> > input ?
> >
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

More information about the rrd-users mailing list