[rrd-users] Re: rrdtool xport - getting total bandwidth for a specific date interval

Göran Törnqvist goran at goran.aleborg.se
Mon Sep 19 22:00:33 MEST 2005


Thanks for your time...Im well on my way now :)
The perl script returned a bunch of error messages though so I think I need 
to understand everything to build my own PHP-script.
Here's the thing, when I do rrdtool fetch like:

rrdtool fetch switch_traffic_in_24.rrd AVERAGE -s 20050901 -e 20050919

i get a lot of:

1127044800: 1.0029921389e+05 1.1126736736e+05
1127052000: 8.8105098833e+04 9.1622791134e+04

I need to add these together somehow to get total bandwidth used, right? But 
I dont know what like 1.0029921389e+05 means/how it should be handled (is it 
exponential?). And it lookes like 2 values 1.0029921389e+05 1.1126736736e+05 
. Is it (value2-value1) that should be added to the total?
REALLY sorry for these newbie questions guys...I won't trouble you for much 
longer.
Say RTFM and i go away :)


----- Original Message ----- 
From: "nate" <rrdtool at aphroland.org>
To: <rrd-users at list.ee.ethz.ch>
Sent: Monday, September 19, 2005 7:32 PM
Subject: [rrd-users] Re: rrdtool xport - getting total bandwidth for a 
specific date interval


Göran Törnqvist said:
> Hello,
> I got a bunch of RRA files and I want to get the total bandwidth from them
> for a specific date interval for accounting purposes.
> Im using cacti to generate the graphs so Im not too good at RRDTOOL Im
> afraid (sorry) and couldnt find a solution to this.
> I´ve managed to get data from a rrd-file like this:
> rrdtool xport --start now-24h --end now
> DEF:out=rra/switch_traffic_in_28.rrd:traffic_out:MAX XPORT:out:"out bytes"

not sure if your looking to get xml but I just use rrdtool
fetch

rrdtool fetch filename.rrd AVERAGE -s -24h

prints out something like

1127150520: 7.6991200000e+02
1127150530: 2.8831200000e+02
1127150540: 3.9471900000e+02
1127150550: 7.8114600000e+02
1127150560: 4.3480000000e+02
1127150570: 3.4909600000e+02
1127150580: 7.1223400000e+02
1127150590: 5.0366200000e+02
1127150600: 4.8812200000e+02
1127150610: 3.8741500000e+02
1127150620: 3.8995000000e+02
1127150630: 7.8206000000e+02
1127150640: 5.8476000000e+02
1127150650: 5.6893500000e+02


makes it easy to parse

(Disclaimer I'm not that good with perl):
#!/usr/bin/perl -w
#
#

while (<>) {
        $value = 0;
        next if ( $_ =~ /nan/ );
        if ( /^[0-9]{4,}\:\s(.*)$/ ) {
        $value = sprintf("%0d",($1/1));
        $counter++;
        $total += $value;
        # print "Value: $value\t Counter: $counter\n";
     }
}

$average = sprintf("%0d",($total/$counter));

print "Total: $total\t Average: $average (Samples: $counter)\n"

e.g.

monitor at tracker3:~/bin$ rrdtool fetch
/rrd/server/wls/HeapFree/AppServer01/heapfree.rrd AVERAGE -s -24h| perl
test.pl
Total: 4945881   Average: 572 (Samples: 8640)


I use this method for a lot of threshhold detections for some of
the RRDs I manage.

nate


--
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://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi




--
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://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list