* AS-Stats: Smooth I/O burstiness and reduce overall IOPS requirements

by flushing only 10% of the cache every 25 seconds (instead
		of the entire cache at once every 60 seconds).
		(contributed by James A. T. Rice)
This commit is contained in:
Manuel Kasper 2012-04-19 11:59:08 +00:00
parent 98804cfd51
commit 9080842d99
6 changed files with 58 additions and 37 deletions

9
README
View File

@ -1,12 +1,17 @@
AS-Stats v1.34 (2011-04-26)
AS-Stats v1.35 (2012-04-19)
a simple tool to generate per-AS traffic graphs from NetFlow/sFlow records
by Manuel Kasper, Monzoon Networks AG <mkasper@monzoon.net>
--------------------------------------------------------------------
Changes
-------
xxx Allow hyphens in link names.
v1.35 Allow hyphens in link names.
(contributed by Gareth Campling)
Smooth I/O burstiness and reduce overall IOPS requirements
by flushing only 10% of the cache every 25 seconds (instead
of the entire cache at once every 60 seconds).
(contributed by James A. T. Rice)
v1.34 Fix for NaN detection in rrd-extractstats.pl for

View File

@ -16,7 +16,8 @@ my $samplingrate = 1; # rate for sampled NetFlow (or = 1 for unsampled)
my $ascache = {};
my $ascache_lastflush = 0;
my $ascache_flush_interval = 60;
my $ascache_flush_interval = 25;
my $ascache_flush_number = 0;
my $server_port = 9000;
my $MAXREAD = 8192;
@ -174,29 +175,36 @@ sub flush_cache {
} elsif ($pid != 0) {
# in parent
$ascache_lastflush = time;
$ascache = {};
for (keys %$ascache) {
if ($_ % 10 == $ascache_flush_number % 10) {
delete $ascache->{$_};
}
}
$ascache_flush_number++;
return;
}
while (my ($as, $cacheent) = each(%$ascache)) {
#print "$$: flushing data for AS $as ($cacheent->{updatets})\n";
if ($as % 10 == $ascache_flush_number % 10) {
#print "$$: flushing data for AS $as ($cacheent->{updatets})\n";
my $rrdfile = getrrdfile($as, $cacheent->{updatets});
my @templatearg;
my @args;
my $rrdfile = getrrdfile($as, $cacheent->{updatets});
my @templatearg;
my @args;
while (my ($dsname, $value) = each(%$cacheent)) {
next if ($dsname !~ /_(in|out)$/);
while (my ($dsname, $value) = each(%$cacheent)) {
next if ($dsname !~ /_(in|out)$/);
push(@templatearg, $dsname);
push(@args, $value * $samplingrate);
}
push(@templatearg, $dsname);
push(@args, $value * $samplingrate);
}
RRDs::update($rrdfile, "--template", join(':', @templatearg),
$cacheent->{updatets} . ":" . join(':', @args));
my $ERR = RRDs::error;
if ($ERR) {
print "Error updating RRD file $rrdfile: $ERR\n";
RRDs::update($rrdfile, "--template", join(':', @templatearg),
$cacheent->{updatets} . ":" . join(':', @args));
my $ERR = RRDs::error;
if ($ERR) {
print "Error updating RRD file $rrdfile: $ERR\n";
}
}
}

View File

@ -16,7 +16,8 @@ my $samplingrate = 512;
my $ascache = {};
my $ascache_lastflush = 0;
my $ascache_flush_interval = 60;
my $ascache_flush_interval = 25;
my $ascache_flush_number = 0;
my $server_port = 6343;
my $MAXREAD = 8192;
@ -223,29 +224,36 @@ sub flush_cache {
# in parent
$childrunning = 1;
$ascache_lastflush = time;
$ascache = {};
for (keys %$ascache) {
if ($_ % 10 == $ascache_flush_number % 10) {
delete $ascache->{$_};
}
}
$ascache_flush_number++;
return;
}
while (my ($as, $cacheent) = each(%$ascache)) {
print "$$: flushing data for AS $as ($cacheent->{updatets})\n";
if ($as % 10 == $ascache_flush_number % 10) {
print "$$: flushing data for AS $as ($cacheent->{updatets})\n";
my $rrdfile = getrrdfile($as, $cacheent->{updatets});
my @templatearg;
my @args;
my $rrdfile = getrrdfile($as, $cacheent->{updatets});
my @templatearg;
my @args;
while (my ($dsname, $value) = each(%$cacheent)) {
next if ($dsname !~ /_(in|out)$/);
while (my ($dsname, $value) = each(%$cacheent)) {
next if ($dsname !~ /_(in|out)$/);
push(@templatearg, $dsname);
push(@args, $value * $samplingrate);
}
push(@templatearg, $dsname);
push(@args, $value * $samplingrate);
}
RRDs::update($rrdfile, "--template", join(':', @templatearg),
$cacheent->{updatets} . ":" . join(':', @args));
my $ERR = RRDs::error;
if ($ERR) {
print "Error updating RRD file $rrdfile: $ERR\n";
RRDs::update($rrdfile, "--template", join(':', @templatearg),
$cacheent->{updatets} . ":" . join(':', @args));
my $ERR = RRDs::error;
if ($ERR) {
print "Error updating RRD file $rrdfile: $ERR\n";
}
}
}

View File

@ -59,7 +59,7 @@ AS: <input type="text" name="as" size="6" />
<?php endif; ?>
<div id="footer">
AS-Stats v1.34 written by Manuel Kasper, Monzoon Networks AG.<br/>
AS-Stats v1.35 written by Manuel Kasper, Monzoon Networks AG.<br/>
<?php if ($outispositive): ?>
Outbound traffic: positive / Inbound traffic: negative
<?php else: ?>

View File

@ -45,7 +45,7 @@ $class = (($i % 2) == 0) ? "even" : "odd";
</table>
<div id="footer">
AS-Stats v1.34 written by Manuel Kasper, Monzoon Networks AG.<br/>
AS-Stats v1.35 written by Manuel Kasper, Monzoon Networks AG.<br/>
<?php if ($outispositive): ?>
Outbound traffic: positive / Inbound traffic: negative
<?php else: ?>

View File

@ -88,7 +88,7 @@ foreach ($knownlinks as $link) {
</div>
<div id="footer">
AS-Stats v1.34 written by Manuel Kasper, Monzoon Networks AG.<br/>
AS-Stats v1.35 written by Manuel Kasper, Monzoon Networks AG.<br/>
<?php if ($outispositive): ?>
Outbound traffic: positive / Inbound traffic: negative
<?php else: ?>