[rrd-users] RE Having some trouble understanding what it is, exactly, I'm pulling from an RRD database file using RRDTool::OO with perl

Cyrille Bollu Cyrille.Bollu at fedasil.be
Tue Jun 15 09:59:44 CEST 2010


I'm not an expert at all but I think I can help you

> - Are these values really bytes? 
Yes, it is the average number of bytes *per second* seen during the 
considered time interval
>How do I know what the values are? 
Because you always know what you measure. Don't you? ;-)
> Is it contained in the RRD database file somewhere so I can have the 
script auto-adapt? 
Yes it is contained in the file "/var/www/html/cacti/rra/326/28889.rrd". 
You can use the "rrdtool dump <filename>" command to "see" them by 
yourself.
> - Am I 100% sure that $value[0] is always "IN" and $value[1] is always 
"OUT"? 
For that particular file yes. But I'm pretty sure it can be different from 
file to file depending on how you created them (I guess $value[0] 
corresponds to the rrd file's first data source, $value[1] to the rrd 
file's second data source, etc...)
> - Does this look sane or is there a better way to do this? 
The script looks sane but I don't understand why you're trying to do this. 
So I can't judge the sanity of your idea and can't tell if there's a 
better way to achieve your goals.
> - What's up with my time selection? Why does 3600 seconds only produce 4 
samples even though the resolution is set to 300 seconds(3600/300=12)? 
Probably because your rrd database doesn't have data at the time requested 
and $rrd->fetch_next() returns the nearest "consolidated data points".
>From your sample, though strange, it looks like that your rrd database 
keeps 10 minutes of data with a 5 minutes time interval, then <x> minutes 
of data with a 45 minutes time interval. Run "rrdtool info <filename>" on 
your rrd database to figure this out.

Best regards,

Cyrille


rrd-users-bounces+cyrille.bollu=fedasil.be at lists.oetiker.ch wrote on 
15/06/2010 01:37:57:

> Hello RRD-Users,
> 
> I also posted this on the Cacti forum since it relates to Cacti data
> directly but the RRD database is rrdtool specific. I'm having some 
> trouble understanding what it is, exactly, I'm pulling from an RRD 
> database file.
> 
> Lets say, for example, that I have a graph of network traffic called
> "aa11.acc - Traffic - Fa0/14". The data source template being used 
> is "Interface - Traffic". And the datasource path is 
> "<path_rra>/326/28889.rrd". The graph template being used is 
> "Interface - Traffic (bits/sec)" characterized by "(traffic_in): 
> Inbound" and "(traffic_out): Outbound" as well as the current, 
> average and maximum for each of those. 
> 
> I'd like to pull the values from the RRD file. I've created a script
> to do this using the device name, interface name and a start/end 
> pair like this: 

> 
> Code:
> 
> 
> #!/usr/bin/perl 
> use RRDTool::OO; 
> 
> # code to get the rrd file name from the cacti database omitted.  
Instead 
> # I'll define it as: 
> $rrdfile = "/var/www/html/cacti/rra/326/28889.rrd"; 
> 
> $rrd = RRDTool::OO->new( file => $rrdfile ); 
> @ARGV[2] = time()-3600 if !@ARGV[2]; 
> @ARGV[3] = time()      if !@ARGV[3]; 
> $rrd->fetch_start( 
>         start => @ARGV[2], 
>         end   => @ARGV[3], 
>         resolution => "300", 
>         cfunc => "AVERAGE" 
>         ); 
> $rrd->fetch_skip_undef(); 
> print "Start: ",time()-3600,"\nEnd:   ",time(),"\n"; 
> print "Device: $devname\n"; 
> print "RRDFile: $rrdpath\n\n"; 
> while(my($time, @value) = $rrd->fetch_next()) { 
>   print "$time: ",sprintf("%.2f", $value[0])," Bytes IN\n" if $value[0]; 

>   print "$time: ",sprintf("%.2f", $value[1])," Bytes OUT\n" if 
$value[1]; 
>   $sumin = $sumin + $value[0]; 
>   $sumout = $sumout + $value[1]; 
> } 
> print "IN:   ",sprintf("%.2f", $sumin)," Bytes\n"; 
> print "OUT:  ",sprintf("%.2f", $sumout)," Bytes\n"; 
> print "TOTAL:",sprintf("%.2f", $sumin+$sumout)," Bytes\n"; 
> 
> 
> 
> The values I get are the following, leaving off the start-end 
> parameters in my script defaults them to the last one hour (3600 
> seconds) of data. 

> 
> Code:
> 
> 
> [root at traf ~]# ./rrd-read.pl aa11 Fa0/14 
> Start: 1276544454 
> End:   1276548054 
> Device: Fa0/14 
> RRDFile: /var/www/html/cacti/rra/326/28889.rrd 
> 
> 1276544700: 22144.43 Bytes IN 
> 1276544700: 2484.16 Bytes OUT 
> 1276547400: 30579.32 Bytes IN 
> 1276547400: 3318.26 Bytes OUT 
> 1276547700: 22904.95 Bytes IN 
> 1276547700: 2469.39 Bytes OUT 
> 1276548000: 21962.23 Bytes IN 
> 1276548000: 2323.77 Bytes OUT 
> IN:   97590.94 Bytes 
> OUT:  10595.58 Bytes 
> TOTAL:108186.51 Bytes 
> 
> 
> 
> Questions: 
> - Are these values really bytes? How do I know what the values are? 
> Is it contained in the RRD database file somewhere so I can have the
> script auto-adapt? 
> - Am I 100% sure that $value[0] is always "IN" and $value[1] is always 
"OUT"? 
> - Does this look sane or is there a better way to do this? 
> - What's up with my time selection? Why does 3600 seconds only 
> produce 4 samples even though the resolution is set to 300 
> seconds(3600/300=12)? 
> 
> Thanks for taking the time to review this post to the list.
> 
> Regards, 
> 
> Landon Stewart <LStewart at SUPERB.NET>
> SuperbHosting.Net by Superb Internet Corp.
> Toll Free (US/Canada): 888-354-6128 x 4199
> Direct: 206-438-5879
> Web hosting and more "Ahead of the Rest": http://www.superbhosting.net
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20100615/777321b3/attachment.htm 


More information about the rrd-users mailing list