Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP::Info::Layer2::CiscoSB not using ifAlias (ifDescr) mod #503

Open
redaxhu opened this issue Oct 2, 2023 · 2 comments
Open

SNMP::Info::Layer2::CiscoSB not using ifAlias (ifDescr) mod #503

redaxhu opened this issue Oct 2, 2023 · 2 comments

Comments

@redaxhu
Copy link

redaxhu commented Oct 2, 2023

Expected Behavior

The Cisco Small Business Sx200-300-500 switch lines return the port description in ifAlias and the current CiscoSB class not using at all.
SNMP::Info::Layer2::CiscoSB should return ifAlias if it exists in the switch, instead of ifDescription.

Current Behavior

same ifName and ifDescr returned

Possible Solution

add the following to SNMP/Info/Layer2/CiscoSB.pm:

--- CiscoSB.pm-orig     2023-10-02 13:39:04.695835044 +0200
+++ CiscoSB.pm-patch    2023-10-02 13:42:19.385422657 +0200
@@ -41,6 +41,8 @@
 use SNMP::Info::CiscoStats;
 use SNMP::Info::CiscoConfig;
 use SNMP::Info::CDP;
+use SNMP::Info::Layer3;
+

 @SNMP::Info::Layer2::CiscoSB::ISA
     = qw/SNMP::Info::Layer2 SNMP::Info::EtherLike
@@ -72,6 +74,7 @@

 %MIBS = (
     %SNMP::Info::Layer2::MIBS,
+    %SNMP::Info::Layer3::MIBS,
     %SNMP::Info::EtherLike::MIBS,
     %SNMP::Info::CiscoStats::MIBS,
     %SNMP::Info::CiscoConfig::MIBS,
@@ -167,6 +170,27 @@
     return $interfaces;
 }

+sub i_description {
+    my $ciscosb = shift;
+    my $partial = shift;
+    my $i_desc  = $ciscosb->orig_i_description($partial);
+    my $i_name  = $ciscosb->i_alias($partial) || {};
+    my $i_index  = $ciscosb->i_index($partial);
+
+    my %if;
+
+    foreach my $iid ( keys %$i_index ) {
+       my $index = $i_index->{$iid};
+       my $pname = $i_name->{$iid};
+       my $name = $i_desc->{$iid};
+       next unless defined $index;
+       $if{$iid} =  defined($pname) && length $pname ? $pname  : $name;
+    }
+
+    return \%if;
+}
+

Your Environment

  • SNMP::Info version used: 3.92
  • Netdisco version (if used): 2.60.5
@ollyg
Copy link
Member

ollyg commented Nov 4, 2023

Hi @redaxhu many thanks for this! Can you let me know why Layer3::MIBS is needed?
It seems a bit odd for the Layer2::CiscoSB class to import that, and I wonder if it's a specific MIB we can just import that instead.
(personally I do believe the whole Layer2/Layer3 business is not helpful but we have it in the design)

@redaxhu
Copy link
Author

redaxhu commented Nov 4, 2023

Hi @ollyg , actually you are right, it is working without using the Layer3 too.
somehow I though I need Layer3 to access the i_alias() fn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants