Archive

Archive for the ‘RRDTool’ Category

Order of RRD Tool readings.

October 26, 2011 Leave a comment

Understand RPN.

Categories: RRDTool

RRD Tool Graphing

August 27, 2011 Leave a comment

One can never select the specific RRA directly but one can do so indirectly by manipulating the start and end times of the graph.

The end time should be:


$End = $Now - ($Now % $Step);
$Start = $Now - ($Width * $Step);


  1. The next question becomes how can we provide graphs with differing resolutions… so far my understanding is that since 1 column of the RRA maps to 1 pixel, if we are defining an image that is 400 pixels wide, we go back 400 RRA records. But what if we want to provide an image that is 800 pixels wide but go back on 400 RRA records?
  2. Another tangential question becomes what if we define a start time that is so far back that the number of pixels / columns go beyond the first available record in the RRA, what would be displayed on the graph? Am testing this theory out…

So now lets create a sample RRD Database:


rrdtool create test.rrd test_graphing.rrd \
--start 1314360000 \
--step 300 \
DS:Temperature:GAUGE:600:0:100 \
DS:InBytesPort0:COUNTER:600:U:U \
DS:OutBytesPort0:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:576 \
RRA:AVERAGE:0.5:144:62 \
RRA:AVERAGE:0.5:288:366


Please refer to the unix time calculator website to get the UTC timestamps.

This gives us the following RRD:

RRD that maintains a record of temperature, and input/output bytes on a port. We maintain 3 sets of records, daily info, monthly info and yearly info.

RRD that maintains a record of temperature, and input/output bytes on a port. We maintain 3 sets of records, daily info, monthly info and yearly info.

We now go ahead and update the RRD.


rrdtool update test_graphing.rrd 1314360300:20:1000:100000
rrdtool update test_graphing.rrd 1314360600:30:1005:100005
rrdtool update test_graphing.rrd 1314360900:30:1015:100015
rrdtool update test_graphing.rrd 1314361200:30:1115:101015


In fact lets get a script to do it…(Yes it is not generic)….



#!/usr/bin/perl
use strict;
use warnings;


use constant STEP => 300;


my $initial_utc_time = 1314361500;
my $min_temp = 0;
my $max_temp = 100;
my $final_utc_time = time();
my $rrd_file =
"$ENV{HOME}/Documents/Playground/RRDTool/test_graphing.rrd";
my $temp;
my $in_count = 1116;
my $out_count = 101016;

#------------------------------------
# Insert stuff in the RRD.
#------------------------------------
for (
my $for_time = $initial_utc_time ;
$for_time < $final_utc_time ;
$for_time += STEP
)
{


#-------------------------------------
# Get a valid temperature value.
#-------------------------------------
if ( ( $temp = sprintf( "%2.2f", ( rand($max_temp) ) ) ) < $min_temp ) {
$temp = $min_temp;
}


#----------------------------------------
# Get a valid counter value for the
# input and output counters.
#----------------------------------------
$in_count += int( rand(1000) );
$out_count += int( rand(1000) );


system(
'rrdtool',
'update' , $rrd_file,
"${for_time}:${temp}:${in_count}:${out_count}"
);
}


The data generated for your RRD file would be different than mine so expect the graph to be different. That should not impact the discussion in anyway.

The file that was generated by the script above is hosted here.

Now let’s carry out the graphing …

Categories: RRDTool