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

betamaz betamaz at gmail.com
Sat May 19 01:03:43 CEST 2007


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

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

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.




if [ ! -f $INPUT_FILE ]; then
    print "File $INPUT_FILE not found"
    exit 1

rrdtool create datafile.rrd \
    --start N --step 60 \

cat $INPUT_FILE | while read line
    #timestamp="$(echo ${line} | cut -d: -f1)"
    #pc="$(echo ${line} | cut -d: -f2)"

    while (read -u 0 -d ":" timestamp value)
        echo "$timestamp - $pc"
        #rrdtool update datafile.rrd $timestamp:$pc
#rrdtool create graph

Thank you for your help,

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 ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20070518/2d2f1ced/attachment.html 

More information about the rrd-users mailing list