[rrd-users] Re: rrdtool xport - getting total bandwidth for a specific date interval
nate
rrdtool at aphroland.org
Mon Sep 19 19:32:32 MEST 2005
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
More information about the rrd-users
mailing list