From 912ba274a65de86725673510bb5bcee9f4c487ba Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Tue, 31 Jul 2012 16:26:30 -0400 Subject: [PATCH] Ignore loopback, other, and cpu interfaces. Use IfDescr for interface since we don't have SNMP-REPEATER-MIB loaded and methods defined. --- Info/Layer7.pm | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Info/Layer7.pm b/Info/Layer7.pm index ba23a0ab..c7440b75 100644 --- a/Info/Layer7.pm +++ b/Info/Layer7.pm @@ -37,9 +37,9 @@ use SNMP::Info; @SNMP::Info::Layer7::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Layer7::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '2.08'; +$VERSION = '2.09'; %MIBS = ( %SNMP::Info::MIBS, @@ -60,7 +60,7 @@ $VERSION = '2.08'; # $l7->model() - Looks at sysObjectID which gives the oid of the system -# name, contained in a propriatry MIB. +# name, contained in a proprietary MIB. sub model { my $l7 = shift; my $id = $l7->id(); @@ -84,15 +84,35 @@ sub interfaces { my $l7 = shift; my $partial = shift; - my $interfaces = $l7->i_index($partial) || {}; - my $rptr_port = $l7->rptr_port($partial) || {}; + my $interfaces = $l7->i_index($partial) || {}; + my $i_descr = $l7->i_description($partial) || {}; - foreach my $port ( keys %$rptr_port ) { - $interfaces->{$port} = $port; + # Replace the Index with the ifDescr field. + foreach my $iid ( keys %$i_descr ) { + my $port = $i_descr->{$iid}; + next unless defined $port; + $interfaces->{$iid} = $port; } return $interfaces; } +sub i_ignore { + my $l7 = shift; + my $partial = shift; + + my $i_type = $l7->i_type($partial) || {}; + + my %i_ignore = (); + + foreach my $if ( keys %$i_type ) { + my $type = $i_type->{$if}; + $i_ignore{$if}++ + if $type =~ /(loopback|other|cpu)/i; + } + + return \%i_ignore; +} + 1; __END__