diff --git a/Changes b/Changes index e479d762..602a0bf2 100644 --- a/Changes +++ b/Changes @@ -2,7 +2,14 @@ Version 3.65 () [ENHANCEMENTS] - * Add two more HP 2930F models + * Add two more HP 2930F models (JeroenvIS) + * #296 expand CiscoAgg to also include LACP based aggregated links + and staticly aggregated links. (inphobia) + + [BUG FIXES] + + * #295 make CiscoAgg return ifindex like expected instead of + bp_index (inphobia) Version 3.64 (2018-12-30) diff --git a/lib/SNMP/Info/CiscoAgg.pm b/lib/SNMP/Info/CiscoAgg.pm index d28c8edc..6524a5c0 100644 --- a/lib/SNMP/Info/CiscoAgg.pm +++ b/lib/SNMP/Info/CiscoAgg.pm @@ -1,6 +1,6 @@ # SNMP::Info::CiscoAgg # -# Copyright (c) 2018 SNMP::Info Developers +# Copyright (c) 2019 SNMP::Info Developers # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -30,36 +30,72 @@ package SNMP::Info::CiscoAgg; use strict; +#use warnings; use Exporter; -use SNMP::Info::IEEE802dot3ad 'agg_ports_lag'; +use SNMP::Info::IEEE802dot3ad; @SNMP::Info::CiscoAgg::ISA = qw/ SNMP::Info::IEEE802dot3ad Exporter /; + @SNMP::Info::CiscoAgg::EXPORT_OK = qw/ agg_ports + agg_ports_cisco + agg_ports_lag + agg_ports_pagp /; -use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; +use vars qw/$DEBUG $VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '3.64'; %MIBS = ( %SNMP::Info::IEEE802dot3ad::MIBS, - 'CISCO-PAGP-MIB' => 'pagpGroupIfIndex', + 'CISCO-PAGP-MIB' => 'pagpGroupIfIndex', + 'CISCO-LAG-MIB' => 'clagAggPortListPorts', + 'CISCO-IF-EXTENSION-MIB' => 'cieIfLastInTime', ); %GLOBALS = (); %FUNCS = ( %SNMP::Info::IEEE802dot3ad::FUNCS, + 'lag_ports' => 'clagAggPortListPorts', + 'lag_members' => 'clagAggPortListInterfaceIndexList', ); %MUNGE = ( %SNMP::Info::IEEE802dot3ad::MUNGE, + 'lag_ports' => \&SNMP::Info::munge_port_list, + 'lag_members' => \&munge_port_ifindex, ); +sub munge_port_ifindex { + my $plist = shift; + return unless defined $plist; + return unless length $plist; + + my $list = [ map {sprintf "%d", hex($_)} unpack( "(A8)*", join( '' , map { sprintf "%02x", $_} unpack( "(C4)*", $plist ) )) ]; + + return $list; +} + +sub agg_ports_cisco { + my $dev = shift; + my $group = $dev->lag_members; + + my $mapping = {}; + for my $master (keys %$group) { + my $slaves = $group->{$master}; + for my $slave (@$slaves) { + $mapping->{$slave} = $master; + } + } + + return $mapping; +} + sub agg_ports_pagp { my $dev = shift; @@ -80,9 +116,28 @@ sub agg_ports_pagp { return $mapping; } -# until we have PAgP data and need to combine with LAG data +sub agg_ports_lag { + my $dev = shift; + + # same note as for agg_ports_pagp, it will miss mappings if interfaces + # are down or lacp is not synced. + + my $mapping = {}; + my $group = $dev->dot3adAggPortSelectedAggID; + for my $slave (keys %$group) { + my $master = $group->{$slave}; + next if($master == 0 || $slave == $master); + + $mapping->{$slave} = $master; + } + + return $mapping; +} + + +# combine PAgP, LAG & Cisco proprietary data sub agg_ports { - my $ret = {%{agg_ports_pagp(@_)}, %{agg_ports_lag(@_)}}; + my $ret = {%{agg_ports_pagp(@_)}, %{agg_ports_lag(@_)}, %{agg_ports_cisco(@_)}}; return $ret; } @@ -116,7 +171,7 @@ SNMP::Info Developers =head1 DESCRIPTION This class provides access to Aggregated Links configuration on Cisco devices. -It combines Cisco PAgP and IEEE 802.3ad information. +It combines Cisco PAgP, Cisco proprietary info and IEEE 802.3ad information. Use or create in a subclass of SNMP::Info. Do not use directly. @@ -130,6 +185,10 @@ L =item F +=item F + +=item F + =back MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz @@ -144,15 +203,52 @@ Returns a HASH reference mapping from slave to master port for each member of a port bundle on the device. Keys are ifIndex of the slave ports, Values are ifIndex of the corresponding master ports. +=item C + +Implements the cisco LAG info retrieval. Merged into C data +automatically. Will fetch all members of C +even if they are not running an aggregation protocol. + =item C Implements the PAgP LAG info retrieval. Merged into C data automatically. +=item C + +Mimics C from L but based on ifindex +instead of instead of bp_index. + +=back + +=head2 OVERRIDES + +=over + +=item C + +This will retrieve LAG ports based on C data. +It will be merged into C data. + =back =head2 Table Methods imported from SNMP::Info::IEEE802dot3ad +=over + See documentation in L for details. +=back + +=head1 MUNGES + +=over + +=item C + +Takes C, uses the index as master port, then +returns all members as ifindex. Works with single or multiple slaves to a master. + +=back + =cut