Changeset 154
- Timestamp:
- Jun 8, 2016, 7:47:21 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r153 r154 425 425 426 426 my $swport = $result->{$research1}; 427 428 my $research_hr = $OID_NUMBER{ifName} .'.'. $swport; 429 $result = $session->get_request( 430 -varbindlist => [$research_hr] 431 ); 432 my $swport_hr = $swport; 433 $swport_hr = get_port_human_readable_short($result->{$research_hr}) if defined $result; 427 my $swport_hr = snmp_get_swithport_hr($session, $swport); 434 428 435 429 $session->close; … … 467 461 return $ret if $mac_address eq 'unknow'; 468 462 469 # for my $sw (@SWITCH) {470 # next if exists $SWITCH_PORT_COUNT{$sw->{hostname}};471 #472 # $SWITCH_PORT_COUNT{$sw->{hostname}} = {};473 # print "DEBUG: SWITCH_PORT_COUNT defined for $sw->{hostname}\n" if $DEBUG xor 2;474 # }475 476 463 my $research1 = $OID_NUMBER{searchPort1} . mac_address_hex_to_dec($mac_address); 477 464 my $research2 = $OID_NUMBER{searchPort2} .'.'. $vlan_id . mac_address_hex_to_dec($mac_address); … … 493 480 if (defined $result and $result->{$research1} ne 'noSuchInstance') { 494 481 my $swport = $result->{$research1}; 482 my $swport_hr = snmp_get_swithport_hr($session, $swport); 495 483 496 484 $ret->{$sw->{hostname}} = {}; … … 498 486 $ret->{$sw->{hostname}}{description} = $sw->{description}; 499 487 $ret->{$sw->{hostname}}{port} = get_human_readable_port($sw->{model}, $swport); 488 $ret->{$sw->{hostname}}{port_hr} = $swport_hr; 500 489 501 490 # $SWITCH_PORT_COUNT{$sw->{hostname}}->{$swport}++; … … 679 668 680 669 return $sw_port_hr; 670 } 671 672 sub snmp_get_swithport_hr { 673 my ($snmp_session, $swport) = @_; 674 675 my $research_hr = $OID_NUMBER{ifName} .'.'. $swport; 676 $result = $snmp_session->get_request( 677 -varbindlist => [$research_hr] 678 ); 679 my $swport_hr = $swport; 680 $swport_hr = get_port_human_readable_short($result->{$research_hr}) if defined $result; 681 return $swport_hr; 681 682 } 682 683 … … 1323 1324 my $mac_sort = sprintf '%04i-%s', 9999, $mac_address; 1324 1325 1325 my ( $host_short ) = sprintf '%s %3s' , split(m/ \. /xms, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port };1326 my ( $host_short ) = sprintf '%s %3s' , split(m/ \. /xms, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port_hr}; 1326 1327 1327 1328 print <<"END_HTML"; … … 1329 1330 <td sorttable_customkey="$switch_hostname_sort">$sw</td> 1330 1331 <td class="bklask-port">$db_switch_output_port{$sw}</> 1331 <td>+--> $db_switch_parent{$sw}->{port }</td>1332 <td>+--> $db_switch_parent{$sw}->{port_hr}</td> 1332 1333 <td sorttable_customkey="$host_short">$db_switch_parent{$sw}->{switch}</> 1333 1334 <td sorttable_customkey="$ip_sort">$ipv4_address</td> … … 2002 2003 next ALL_SWITCH_CONNECTED if $switch->{port} eq '0'; 2003 2004 2004 $db_switch_output_port{$switch->{hostname}} = $switch->{port };2005 print "VERBOSE_2: output port $switch->{hostname} : $switch->{port }\n" if $verbose;2005 $db_switch_output_port{$switch->{hostname}} = $switch->{port_hr}; 2006 print "VERBOSE_2: output port $switch->{hostname} : $switch->{port_hr}\n" if $verbose; 2006 2007 } 2007 2008 } … … 2055 2056 2056 2057 my $switch = $where{$ip}->{$switch_detected}; 2057 print "VERBOSE_6: $db_switch_ip_hostnamefq{$ip} -> $switch->{hostname} : $switch->{port }\n" if $verbose;2058 print "VERBOSE_6: $db_switch_ip_hostnamefq{$ip} -> $switch->{hostname} : $switch->{port_hr}\n" if $verbose; 2058 2059 2059 2060 next if $switch->{port} eq '0'; 2060 next if $switch->{port }eq $db_switch_output_port{$switch->{hostname}};2061 next if $switch->{port_hr} eq $db_switch_output_port{$switch->{hostname}}; 2061 2062 next if $switch->{hostname} eq $db_switch_ip_hostnamefq{$ip}; # $computerdb->{$ip}{hostname}; 2062 2063 … … 2131 2132 for my $sw (sort keys %db_switch_output_port) { 2132 2133 if (exists $db_switch_parent{$sw}) { 2133 printf "%-28s %2s +--> %2s %-25s\n", $sw, $db_switch_output_port{$sw}, $db_switch_parent{$sw}->{port }, $db_switch_parent{$sw}->{switch};2134 printf "%-28s %2s +--> %2s %-25s\n", $sw, $db_switch_output_port{$sw}, $db_switch_parent{$sw}->{port_hr}, $db_switch_parent{$sw}->{switch}; 2134 2135 } 2135 2136 else { … … 2199 2200 for my $sw (sort keys %db_switch_output_port) { 2200 2201 if (exists $db_switch_parent{$sw}) { 2201 printf "%-28s %2s +--> %2s %-25s\n", $sw, $db_switch_output_port{$sw}, $db_switch_parent{$sw}->{port }, $db_switch_parent{$sw}->{switch};2202 printf "%-28s %2s +--> %2s %-25s\n", $sw, $db_switch_output_port{$sw}, $db_switch_parent{$sw}->{port_hr}, $db_switch_parent{$sw}->{switch}; 2202 2203 } 2203 2204 else {
Note: See TracChangeset
for help on using the changeset viewer.