Changeset 244 for trunk/klask
- Timestamp:
- Sep 7, 2017, 10:53:00 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r243 r244 507 507 508 508 my $swport_num = $result->{$research1}; 509 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_ hr($session, $swport_num));509 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_num2hr($session, $swport_num)); 510 510 511 511 $session->close; … … 563 563 if (defined $result and $result->{$research1} ne 'noSuchInstance') { 564 564 my $swport_num = $result->{$research1}; 565 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_ hr($session, $swport_num));565 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_num2hr($session, $swport_num)); 566 566 567 567 SWITCH_PORT_IGNORE: … … 799 799 800 800 #--------------------------------------------------------------- 801 sub snmp_get_switchport_ hr {802 my ($snmp_session, $swport_num , $flag) = @_;801 sub snmp_get_switchport_num2hr { 802 my ($snmp_session, $swport_num) = @_; 803 803 804 804 # On H3C, port number and port index are not the same 805 805 # Double SNMP request to get the name 806 $flag ||= 'distinct'; 806 807 my $research_index = $OID_NUMBER{ifIndex} .'.'. $swport_num; 808 my $result_index = $snmp_session->get_request( 809 -varbindlist => [$research_index] 810 ); 811 807 812 my $swport_index = $swport_num; 808 809 if ($flag eq 'distinct') { 810 my $research_index = $OID_NUMBER{ifIndex} .'.'. $swport_num;811 my $result_index = $snmp_session->get_request(812 -varbindlist => [$research_index] 813 ); 814 $swport_index = $result_index->{$research_index} if defined $result_index; 815 }813 $swport_index = $result_index->{$research_index} if defined $result_index; 814 815 return snmp_get_switchport_index2hr($snmp_session, $swport_index); 816 } 817 818 #--------------------------------------------------------------- 819 sub snmp_get_switchport_index2hr { 820 my ($snmp_session, $swport_index) = @_; 816 821 817 822 my $research_hr = $OID_NUMBER{ifName} .'.'. $swport_index; … … 842 847 next LOOP_ON_OID_PORT if not $port_aggregator_index == $swport_index; 843 848 844 my $current_port_name = snmp_get_switchport_ hr($snmp_session, $current_port_index, 'index');849 my $current_port_name = snmp_get_switchport_index2hr($snmp_session, $current_port_index); 845 850 $swport_hr .= ":$current_port_name"; 846 851 } … … 851 856 #--------------------------------------------------------------- 852 857 # Reverse search port number 853 sub snmp_get_switchport_ num {858 sub snmp_get_switchport_hr2num { 854 859 my ($snmp_session, $swport_hr, $verbose) = @_; 855 860 … … 2324 2329 2325 2330 # Retrieve numeric port value 2326 my $port_num = snmp_get_switchport_ num($session, normalize_port_human_readable($port), $verbose ? 'yes' : '');2331 my $port_num = snmp_get_switchport_hr2num($session, normalize_port_human_readable($port), $verbose ? 'yes' : ''); 2327 2332 die "Error : Port $port does not exist on switch $switch_name\n" if not $port_num =~ m/^\d+$/; 2328 2333 … … 2369 2374 2370 2375 # Retrieve numeric port value 2371 my $port_num = snmp_get_switchport_ num($session, normalize_port_human_readable($port), $verbose ? 'yes' : '');2376 my $port_num = snmp_get_switchport_hr2num($session, normalize_port_human_readable($port), $verbose ? 'yes' : ''); 2372 2377 die "Error : Port $port does not exist on switch $switch_name\n" if not $port_num =~ m/^\d+$/; 2373 2378 … … 2412 2417 2413 2418 # Retrieve numeric port value 2414 my $port_num = snmp_get_switchport_ num($session, normalize_port_human_readable($port), $verbose ? 'yes' : '');2419 my $port_num = snmp_get_switchport_hr2num($session, normalize_port_human_readable($port), $verbose ? 'yes' : ''); 2415 2420 die "Error : Port $port does not exist on switch $switch_name\n" if not $port_num =~ m/^\d+$/; 2416 2421 … … 2480 2485 if (defined $result and $result->{$research1} ne 'noSuchInstance') { 2481 2486 my $swport_num = $result->{$research1}; 2482 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_ hr($session, $swport_num));2487 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_num2hr($session, $swport_num)); 2483 2488 print "Klask find MAC $mac_address on switch $sw_name port $swport_hr\n"; 2484 2489 }
Note: See TracChangeset
for help on using the changeset viewer.