From 586e5f2d2c179ceb236ca5415fe637c9eedf3693 Mon Sep 17 00:00:00 2001 From: Shane Mc Cormack Date: Fri, 15 Apr 2016 15:13:24 +0100 Subject: [PATCH] Allow separate samplerates for in/out traffic --- bin/asstatd.pl | 16 +++++++++++++--- conf/knownlinks | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/asstatd.pl b/bin/asstatd.pl index 05a35bf..b53245e 100755 --- a/bin/asstatd.pl +++ b/bin/asstatd.pl @@ -714,6 +714,9 @@ sub flush_cache { my $tag = $dsname; $tag =~ s/(_v6)?_(in|out)$//; + if ($dsname =~ /_(in|out)$/) { + $tag = "${1}_${tag}"; + } my $cursamplingrate = $link_samplingrates{$tag}; push(@templatearg, $dsname); @@ -794,12 +797,19 @@ sub read_knownlinks { my ($routerip,$ifindex,$tag,$descr,$color,$linksamplingrate) = split(/\t+/); $knownlinks_tmp{"${routerip}_${ifindex}"} = $tag; - - unless(defined($linksamplingrate) && $linksamplingrate =~ /^\d+$/) { + + my ($samplein,$sampleout) = split('/', $linksamplingrate); + unless(defined($sampleout) && $sampleout =~ /^\d+$/) { + $sampleout = $samplein; + } + + unless(defined($samplein) && $samplein =~ /^\d+$/) { die("ERROR: No samplingrate for ".$routerip."\n"); } - $link_samplingrates_tmp{$tag} = $linksamplingrate; + $link_samplingrates_tmp{"in_$tag"} = $samplein; + $link_samplingrates_tmp{"out_$tag"} = $sampleout; + #print "DEBUG Sampling Rate for ${routerip}_${ifindex} is IN: $samplein | OUT: $sampleout\n"; } close(KLFILE); diff --git a/conf/knownlinks b/conf/knownlinks index dcbbcf8..4d82d42 100644 --- a/conf/knownlinks +++ b/conf/knownlinks @@ -1,6 +1,7 @@ # Router IP SNMP ifindex[/VLAN] tag description color samplingrate # note: tabs must be used to separate fields (not spaces) # max. length for tag is 12 characters; allowed characters: a-z A-Z 0-9 _ +# sampling rate can be separate for in/out by specifying / rates. 192.0.2.1 15 uplink1 Uplink 1 A6CEE3 1 192.0.2.1 23 uplink2 Uplink 2 1F78B4 1 192.0.2.2 4 uplink3 Uplink 3 B2DF8A 1