Changeset 245
- Timestamp:
- Sep 7, 2017, 11:22:01 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r244 r245 507 507 508 508 my $swport_num = $result->{$research1}; 509 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_num2hr($session, $swport_num));509 my $swport_hr = snmp_get_switchport_num2hr($session, $swport_num); 510 510 511 511 $session->close; … … 520 520 for my $portignore (@{$sw->{portignore}}) { 521 521 next LOOP_ON_SWITCH if $swport_hr eq $portignore; 522 my ($swport_hr_limited) = split / :/, $swport_hr; # Beginning of the swith port (Aggregator)522 my ($swport_hr_limited) = split /|/, $swport_hr; # Beginning of the swith port (Aggregator) 523 523 next LOOP_ON_SWITCH if $swport_hr_limited eq $portignore; 524 524 } … … 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_num2hr($session, $swport_num));565 my $swport_hr = snmp_get_switchport_num2hr($session, $swport_num); 566 566 567 567 SWITCH_PORT_IGNORE: … … 667 667 return @res; 668 668 } 669 670 #---------------------------------------------------------------671 sub get_human_readable_port {672 my $sw_model = shift;673 my $sw_port = shift;674 675 # Not need anymore676 # get port name by snmp677 return $sw_port;678 }679 680 # if ($sw_model eq 'HP8000M') {681 #682 # my $reste = (($sw_port - 1) % 8) + 1;683 # my $major = int (($sw_port - 1) / 8);684 # return "$INTERNAL_PORT_MAP{$major}$reste";685 # }686 #687 # if ($sw_model eq 'HP2424M') {688 # if ($sw_port > 24) {689 #690 # my $reste = $sw_port - 24;691 # return "A$reste";692 # }693 # }694 #695 # if ($sw_model eq 'HP1600M') {696 # if ($sw_port > 16) {697 #698 # my $reste = $sw_port - 16;699 # return "A$reste";700 # }701 # }702 #703 # if ($sw_model eq 'HP2810-48G' or $sw_model eq 'HP2810-24G') {704 # if ($sw_port > 48) {705 #706 # my $reste = $sw_port - 48;707 # return "Trk$reste";708 # }709 # }710 #711 # if ($sw_model eq 'HP3500-24G') {712 # if ($sw_port > 289) {713 #714 # my $reste = $sw_port - 289;715 # return "Trk$reste";716 # }717 # }718 #719 # return $sw_port;720 721 #sub get_numerical_port {722 # my $sw_model = shift;723 # my $sw_port = shift;724 #725 # if ($sw_model eq 'HP8000M') {726 #727 # my $letter = substr $sw_port, 0, 1;728 # my $reste = substr $sw_port, 1;729 #730 # return $INTERNAL_PORT_MAP_REV{$letter} * 8 + $reste;731 # }732 #733 # if ($sw_model eq 'HP2424M') {734 # if ($sw_port =~ m/^A/xms ) {735 #736 # my $reste = substr $sw_port, 1;737 #738 # return 24 + $reste;739 # }740 # }741 #742 # if ($sw_model eq 'HP1600M') {743 # if ($sw_port =~ m/^A/xms ) {744 #745 # my $reste = substr $sw_port, 1;746 #747 # return 16 + $reste;748 # }749 # }750 #751 # if ($sw_model eq 'HP2810-48G' or $sw_model eq 'HP2810-24G') {752 # if ($sw_port =~ m/^Trk/xms ) {753 #754 # my $reste = substr $sw_port, 3;755 #756 # return 48 + $reste;757 # }758 # }759 #760 # if ($sw_model eq 'HP3500-24G') {761 # if ($sw_port =~ m/^Trk/xms ) {762 #763 # my $reste = substr $sw_port, 3;764 #765 # return 289 + $reste;766 # }767 # }768 #769 # return $sw_port;770 # }771 669 772 670 #--------------------------------------------------------------- … … 848 746 849 747 my $current_port_name = snmp_get_switchport_index2hr($snmp_session, $current_port_index); 850 $swport_hr .= " :$current_port_name";748 $swport_hr .= "|$current_port_name"; # Join with | (: is already use) 851 749 } 852 750 } … … 860 758 861 759 # Split for Aggregator port 862 ($swport_hr) = split /:/, $swport_hr; 760 # Keep only the Aggregator part 761 ($swport_hr) = split /|/, $swport_hr; 863 762 864 763 my $swport_num = $swport_hr; … … 1137 1036 my %db_switch_chained_port = (); 1138 1037 for my $swport (keys %db_switch_connected_on_port) { 1139 my ($sw_connect,$port_connect) = split m/ : /xms, $swport ;1038 my ($sw_connect,$port_connect) = split m/ : /xms, $swport, 2; 1140 1039 $db_switch_chained_port{$sw_connect} .= "$port_connect:"; 1141 1040 } … … 1651 1550 1652 1551 for my $swport (sort keys %db_switch_connected_on_port) { 1653 my ($sw_connect,$port_connect) = split m/ : /xms, $swport ;1552 my ($sw_connect,$port_connect) = split m/ : /xms, $swport, 2; 1654 1553 for my $sw (keys %{$db_switch_connected_on_port{$swport}}) { 1655 1554 … … 2485 2384 if (defined $result and $result->{$research1} ne 'noSuchInstance') { 2486 2385 my $swport_num = $result->{$research1}; 2487 my $swport_hr = get_human_readable_port($sw->{model}, snmp_get_switchport_num2hr($session, $swport_num));2386 my $swport_hr = snmp_get_switchport_num2hr($session, $swport_num); 2488 2387 print "Klask find MAC $mac_address on switch $sw_name port $swport_hr\n"; 2489 2388 } … … 2642 2541 $maybe_more_than_one_switch_connected = 'yes'; 2643 2542 2644 my ($sw_connect,$port_connect) = split m/ : /xms, $swport ;2543 my ($sw_connect,$port_connect) = split m/ : /xms, $swport, 2; 2645 2544 my @sw_on_same_port = keys %{$db_switch_connected_on_port{$swport}}; 2646 2545 print "VERBOSE_10: $swport -- ".$#sw_on_same_port." -- @sw_on_same_port\n" if $verbose; … … 2694 2593 print "------------------------------------------------\n"; 2695 2594 for my $swport (sort keys %db_switch_connected_on_port) { 2696 my ($sw_connect,$port_connect) = split m/ : /xms, $swport ;2595 my ($sw_connect,$port_connect) = split m/ : /xms, $swport, 2; 2697 2596 for my $sw (keys %{$db_switch_connected_on_port{$swport}}) { 2698 2597 if (exists $db_switch_output_port{$sw}) { … … 2766 2665 print "------------------------------------------------\n"; 2767 2666 for my $swport (sort keys %db_switch_connected_on_port) { 2768 my ($sw_connect,$port_connect) = split m/ : /xms, $swport ;2667 my ($sw_connect,$port_connect) = split m/ : /xms, $swport, 2; 2769 2668 for my $sw (keys %{$db_switch_connected_on_port{$swport}}) { 2770 2669 my $arrow ='<--'; … … 2842 2741 2843 2742 for my $swport (keys %db_switch_connected_on_port) { 2844 my ($sw_connect,$port_connect) = split m/ : /xms, $swport ;2743 my ($sw_connect,$port_connect) = split m/ : /xms, $swport, 2; 2845 2744 next if not $sw_connect eq $sw; 2846 2745 next if $port_connect eq $db_switch_output_port{$sw}; … … 2867 2766 # print "------------------------------------------------\n"; 2868 2767 for my $swport (sort keys %db_switch_connected_on_port) { 2869 my ($sw_connect,$port_connect) = split m/ : /xms, $swport ;2768 my ($sw_connect,$port_connect) = split m/ : /xms, $swport, 2; 2870 2769 for my $sw (keys %{$db_switch_connected_on_port{$swport}}) { 2871 2770 if (exists $db_switch_output_port{$sw}) {
Note: See TracChangeset
for help on using the changeset viewer.