From 44ffd0f75b708d192cd88be71878979271d8c2dd Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 28 Apr 2023 10:27:45 +0200 Subject: [PATCH 1/2] #10157 Added max parameter --- .../util/plugin/pandora_snmp_bandwidth.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl index 2c68be5473..015bde5893 100755 --- a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl +++ b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl @@ -60,6 +60,7 @@ Where OPTIONS could be: -inUsage Show only input usage (in percentage) - 1, or not 0. -outUsage Show only output usage (in percentage) - 1, or not 0. -f We treat unkonwn duplex as full duplex. + -max Value that replaces ifSpeed when you have a port chanel with multiple interfaces. Note: You can also use snmpget/snmpwalk argument notation, e.g. -v is equal to -version, -c to -community, etc. @@ -140,6 +141,9 @@ sub update_config_key ($) { if ($arg eq 'f') { return "unknown_fullduplex"; } + if ($arg eq 'max') { + return "max_interfaces"; + } } ################################################################################ @@ -258,12 +262,17 @@ sub prepare_tree { $speed{'oid'} .= $config->{'x86_indexes'}{'ifSpeed'}.$ifIndex; } - my $speed = snmp_get(\%speed); - if (ref($speed) eq "HASH") { - $speed = int $speed->{'data'}; + my $speed = 0; + if (empty($config->{'max_interfaces'}) { + $speed = snmp_get(\%speed); + if (ref($speed) eq "HASH") { + $speed = int $speed->{'data'}; + } else { + # Ignore, cannot retrieve inOctets. + next; + } } else { - # Ignore, cannot retrieve inOctets. - next; + $speed = $config->{'max_interfaces'}; } { From 77b5b7af4511c748390a3c912e3bee047fee2ced Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 28 Apr 2023 10:51:21 +0200 Subject: [PATCH 2/2] #10157 Fix max_interfaces --- pandora_server/util/plugin/pandora_snmp_bandwidth.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl index 015bde5893..15fcf58f73 100755 --- a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl +++ b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl @@ -263,7 +263,7 @@ sub prepare_tree { } my $speed = 0; - if (empty($config->{'max_interfaces'}) { + if (empty($config->{'max_interfaces'})) { $speed = snmp_get(\%speed); if (ref($speed) eq "HASH") { $speed = int $speed->{'data'};