Changeset 86
- Timestamp:
- Mar 30, 2011, 3:18:26 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r84 r86 107 107 sysContact => '1.3.6.1.2.1.1.4.0', 108 108 sysLocation => '1.3.6.1.2.1.1.6.0', 109 searchPort => '1.3.6.1.2.1.17.4.3.1.2', 109 110 ); 110 111 … … 330 331 ### 331 332 # convertit l'hexa (uniquement 2 chiffres) en decimal 332 sub hex_to_dec {333 sub digit_hex_to_dec { 333 334 #00:0F:1F:43:E4:2B 334 335 my $car = '00' . uc shift; … … 345 346 346 347 ### 347 # convertit l'@ arpen decimal348 sub arp_hex_to_dec {348 # convertit l'@ mac en decimal 349 sub mac_address_hex_to_dec { 349 350 #00:0F:1F:43:E4:2B 350 my $ arp= shift;351 352 my @paquets = split m/ : /xms, $ arp;351 my $mac_address = shift; 352 353 my @paquets = split m/ : /xms, $mac_address; 353 354 my $return = q{}; 354 355 foreach(@paquets) { 355 $return .= q{.} . hex_to_dec($_);356 $return .= q{.} . digit_hex_to_dec($_); 356 357 } 357 358 return $return; … … 361 362 # va rechercher le port et le switch sur lequel est la machine 362 363 sub find_switch_port { 363 my $ arp= shift;364 my $mac_address = shift; 364 365 my $switch_proposal = shift || q{}; 365 366 … … 368 369 $ret{switch_port} = '0'; 369 370 370 return %ret if $ arpeq 'unknow';;371 return %ret if $mac_address eq 'unknow';; 371 372 372 373 my @switch_search = @SWITCH; … … 379 380 } 380 381 381 my $research = '1.3.6.1.2.1.17.4.3.1.2' . arp_hex_to_dec($arp);382 my $research = $OID_NUMBER{searchPort} . mac_address_hex_to_dec($mac_address); 382 383 383 384 LOOP_ON_SWITCH: … … 426 427 # va rechercher les port et les switch sur lequel est la machine 427 428 sub find_all_switch_port { 428 my $ arp= shift;429 my $mac_address = shift; 429 430 430 431 my $ret = {}; 431 432 432 return $ret if $ arpeq 'unknow';433 434 for my $sw (@SWITCH) {435 next if exists $SWITCH_PORT_COUNT{$sw->{hostname}};436 437 $SWITCH_PORT_COUNT{$sw->{hostname}} = {};433 return $ret if $mac_address eq 'unknow'; 434 435 # for my $sw (@SWITCH) { 436 # next if exists $SWITCH_PORT_COUNT{$sw->{hostname}}; 437 # 438 # $SWITCH_PORT_COUNT{$sw->{hostname}} = {}; 438 439 # print "DEBUG: SWITCH_PORT_COUNT defined for $sw->{hostname}\n" if $DEBUG xor 2; 439 }440 441 my $research = '1.3.6.1.2.1.17.4.3.1.2' . arp_hex_to_dec($arp);440 # } 441 442 my $research = $OID_NUMBER{searchPort} . mac_address_hex_to_dec($mac_address); 442 443 LOOP_ON_ALL_SWITCH: 443 444 for my $sw (@SWITCH) { … … 452 453 my $swport = $result->{$research}; 453 454 454 #print "DEBUG $arp $swport -- $sw->{hostname} \n";455 # if ( $sw->{hostname} eq 'sw10-batE1-3s.hmg.priv' and $swport == 19 ) { $swport = 20; print "DEBUG $swport -- $sw->{hostname} \n";}456 # if ( $sw->{hostname} eq 'sw8-batE1-3s.hmg.priv' and $swport == 23 ) { $swport = 24; print "DEBUG $swport -- $sw->{hostname} \n";}457 # if ( $sw->{hostname} eq 'sw10-batE1-3s.hmg.priv' ) { print "DEBUG $swport -- $sw->{hostname} \n";}458 # if ( $sw->{hostname} eq 'sw8-batE1-3s.hmg.priv' ) { print "DEBUG $swport -- $sw->{hostname} \n";}459 460 455 $ret->{$sw->{hostname}} = {}; 461 456 $ret->{$sw->{hostname}}{hostname} = $sw->{hostname}; … … 463 458 $ret->{$sw->{hostname}}{port} = get_human_readable_port($sw->{model}, $swport); 464 459 465 $SWITCH_PORT_COUNT{$sw->{hostname}}->{$swport}++;460 # $SWITCH_PORT_COUNT{$sw->{hostname}}->{$swport}++; 466 461 } 467 462 … … 1405 1400 } 1406 1401 1407 my $research = '1.3.6.1.2.1.17.4.3.1.2' . arp_hex_to_dec($mac_address);1402 my $research = $OID_NUMBER{searchPort} . mac_address_hex_to_dec($mac_address); 1408 1403 print "Klask search OID $research on switch $switch_name\n"; 1409 1404
Note: See TracChangeset
for help on using the changeset viewer.