Changeset 214
- Timestamp:
- Feb 18, 2017, 2:21:46 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r213 r214 744 744 } 745 745 746 sub get_port_human_readable_short{746 sub normalize_port_human_readable { 747 747 my $sw_port_hr = shift; 748 748 749 # Manufacturer abbreviation 749 750 $sw_port_hr =~ s/^Bridge-Aggregation/Br/i; 750 751 $sw_port_hr =~ s/^Port-Channel/Po/i; … … 754 755 $sw_port_hr =~ s/^FastEthernet/Fa/i; 755 756 757 # Customer abbreviation 758 $sw_port_hr =~ s/^Ten/Te/i; 759 $sw_port_hr =~ s/^Giga/Gi/i; 760 756 761 return $sw_port_hr; 757 762 } … … 772 777 ); 773 778 my $swport_hr = $swport; 774 $swport_hr = get_port_human_readable_short($result_hr->{$research_hr}) if defined $result_hr;779 $swport_hr = normalize_port_human_readable($result_hr->{$research_hr}) if defined $result_hr; 775 780 return $swport_hr; 776 781 } … … 801 806 next LOOP_OID_PORT if not defined $result; 802 807 803 my $current_port_hr = get_port_human_readable_short($result->{$oid_ifName});808 my $current_port_hr = normalize_port_human_readable($result->{$oid_ifName}); 804 809 printf "PORT2: $oid_ifName => $current_port_hr\n" if $verbose; 805 if ( $current_port_hr =~ m/^$swport_hr$/i) {806 print "PORT3: $current_port_hr <-> $ swport_hr\n" if $verbose;810 if ($current_port_hr eq $swport_hr) { 811 print "PORT3: $current_port_hr <-> $port_index\n" if $verbose; 807 812 $swport_num = $port_index; 808 813 last LOOP_OID_PORT; … … 817 822 # my ($oid_current) = $snmp_session->var_bind_names; 818 823 # last if not Net::SNMP::oid_base_match($research_index, $oid_current); 819 # my $current_port_hr = get_port_human_readable_short($snmp_session->var_bind_list->{$oid_current});824 # my $current_port_hr = normalize_port_human_readable($snmp_session->var_bind_list->{$oid_current}); 820 825 # printf "%s => %s\n", $oid_current, $current_port_hr; # if $verbose; 821 826 # if ( $current_port_hr =~ m/$swport_hr/i ) { … … 839 844 # ); 840 845 # my $swport_hr = $swport; 841 # $swport_hr = get_port_human_readable_short($result_hr->{$research_hr}) if defined $result_hr;846 # $swport_hr = normalize_port_human_readable($result_hr->{$research_hr}) if defined $result_hr; 842 847 # return $swport_hr; 843 848 # } … … 2138 2143 2139 2144 # Retrieve numeric port value 2140 my $port_num = snmp_get_switchport_num($session, $port, $verbose ? 'yes' : '');2145 my $port_num = snmp_get_switchport_num($session, normalize_port_human_readable($port), $verbose ? 'yes' : ''); 2141 2146 die "Error : Port $port not exist on switch $switch_name\n" if $port_num =~ m/^\d+$/; 2142 2147
Note: See TracChangeset
for help on using the changeset viewer.