Skip to content

Commit

Permalink
Merge pull request #55 from JackSlateur/master
Browse files Browse the repository at this point in the history
sFlow: handle multiple ASN, if you want to merge the statistics when …
  • Loading branch information
manuelkasper committed Jan 20, 2017
2 parents ee65b8d + 84931f2 commit fa8f3c8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions bin/asstatd.pl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

my $rrdpath = $opt{'r'};
my $knownlinksfile = $opt{'k'};
my $myas = $opt{'a'};
my $myas_opt = $opt{'a'};
my $peerasstats = $opt{'n'};

die("$usage") if (!defined($rrdpath) || !defined($knownlinksfile));
Expand All @@ -73,7 +73,15 @@
die("sFlow server port can't be the same as NetFlow server port\n");
}

die("Your own AS number is non numeric\n") if ($sflow_server_port > 0 && $myas !~ /^[0-9]+$/);
my %myas;
if($sflow_server_port > 0){
die('No ASN found, please specify -a') if !defined($myas_opt);
%myas = map {$_ => 1 } split(',', $myas_opt);
for my $i (%myas){
next if !defined($i);
die("Your AS number is non numeric ($i)\n") if ($i !~ /^[0-9]+$/);
}
}

if (!$sflow_server_port && $peerasstats) {
die("peer-as statistics only work with sFlow\n");
Expand Down Expand Up @@ -562,10 +570,10 @@ sub parse_sflow {
# them twice; once for input and once for output)

# substitute 0 for own AS number
if ($srcas == $myas) {
if ($myas{$srcas}) {
$srcas = 0;
}
if ($dstas == $myas) {
if ($myas{$dstas}) {
$dstas = 0;
}

Expand Down Expand Up @@ -598,10 +606,10 @@ sub parse_sflow {
$dstpeeras = $dstas;
}

if ($srcpeeras == $myas) {
if ($myas{$srcpeeras}) {
$srcpeeras = 0;
}
if ($dstpeeras == $myas) {
if ($myas{$dstpeeras}) {
$dstpeeras = 0;
}

Expand Down

0 comments on commit fa8f3c8

Please sign in to comment.