- Timestamp:
- Jul 24, 2009, 1:18:01 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r53 r54 144 144 145 145 my $fh = new Filehandle; 146 open $fh, '-|', "$cmd" or die "Can't exec $cmd\n";146 open $fh, q{-|}, "$cmd" or die "Can't exec $cmd\n"; 147 147 my $result = <$fh>; 148 148 close $fh; … … 155 155 sub resolve_ip_arp_host { 156 156 my $param_ip_or_host = shift; 157 my $interface = shift || '*';158 my $type = shift || 'fast';157 my $interface = shift || q{*}; 158 my $type = shift || q{fast}; 159 159 160 160 my %ret = ( … … 222 222 push @paquets, "$chars[-2]$chars[-1]"; 223 223 } 224 $ret{mac_address} = join ':', @paquets;224 $ret{mac_address} = join q{:}, @paquets; 225 225 } 226 226 … … 313 313 314 314 my @paquets = split m/ : /xms, $arp; 315 my $return = '';315 my $return = q{}; 316 316 foreach(@paquets) { 317 $return .= ".".hex_to_dec($_);317 $return .= q{.} . hex_to_dec($_); 318 318 } 319 319 return $return; … … 324 324 sub find_switch_port { 325 325 my $arp = shift; 326 my $switch_proposal = shift || '';326 my $switch_proposal = shift || q{}; 327 327 328 328 my %ret; … … 333 333 334 334 my @switch_search = @SWITCH; 335 if ($switch_proposal ne '') {335 if ($switch_proposal ne q{}) { 336 336 for my $sw (@SWITCH) { 337 337 next if $sw->{hostname} ne $switch_proposal; … … 341 341 } 342 342 343 my $research = "1.3.6.1.2.1.17.4.3.1.2".arp_hex_to_dec($arp);343 my $research = '1.3.6.1.2.1.17.4.3.1.2' . arp_hex_to_dec($arp); 344 344 345 345 LOOP_ON_SWITCH: … … 675 675 } 676 676 677 my $switch_proposal = '';677 my $switch_proposal = q{}; 678 678 if (exists $computerdb->{$resol_arp{ipv4_address}} and exists $computerdb->{$resol_arp{ipv4_address}}{switch_hostname}) { 679 679 $switch_proposal = $computerdb->{$resol_arp{ipv4_address}}{switch_hostname}; … … 1048 1048 next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself ! 1049 1049 1050 my $sw_hostname = $computerdb->{$ip}{switch_hostname} || '';1050 my $sw_hostname = $computerdb->{$ip}{switch_hostname} || q{}; 1051 1051 next if $sw_hostname eq 'unknow'; 1052 1052 1053 my $sw_location = '';1053 my $sw_location = q{}; 1054 1054 for my $sw (@SWITCH) { 1055 1055 next if $sw_hostname ne $sw->{hostname}; … … 1058 1058 } 1059 1059 1060 printf "%s: \"%s\"\n", $ip, $sw_location if not $sw_location eq '';1060 printf "%s: \"%s\"\n", $ip, $sw_location if not $sw_location eq q{}; 1061 1061 } 1062 1062 return; … … 1090 1090 1091 1091 sub cmd_search_mac_on_switch { 1092 my $switch_name = shift || '';1093 my $mac_address = shift || '';1094 1095 if ($switch_name eq '' or $mac_address eq '') {1092 my $switch_name = shift || q{}; 1093 my $mac_address = shift || q{}; 1094 1095 if ($switch_name eq q{} or $mac_address eq q{}) { 1096 1096 die "Usage: klask search-mac-on-switch SWITCH_NAME MAC_ADDRESS\n"; 1097 1097 } … … 1146 1146 # for my $one_computer ('194.254.66.254') { 1147 1147 for my $one_router ( get_list_main_router(get_list_network()) ) { 1148 my %resol_arp = resolve_ip_arp_host($one_router, '*','low');# resolution arp1148 my %resol_arp = resolve_ip_arp_host($one_router, q{*}, q{low}); # resolution arp 1149 1149 next DETECT_ALL_ROUTER if $resol_arp{mac_address} eq 'unknow'; 1150 1150 $where{$resol_arp{ipv4_address}} = find_all_switch_port($resol_arp{mac_address}); # retrouve les emplacements des routeurs … … 1179 1179 ALL_SWITCH: 1180 1180 for my $one_computer (@list_switch_ip) { 1181 my %resol_arp = resolve_ip_arp_host($one_computer, '*','low'); # arp resolution1181 my %resol_arp = resolve_ip_arp_host($one_computer, q{*}, q{low}); # arp resolution 1182 1182 next ALL_SWITCH if $resol_arp{mac_address} eq 'unknow'; 1183 1183 … … 1405 1405 $l++; 1406 1406 1407 print "\"location$b-$l\" [label = \"$building" .'/'.join('\n',split(m{ / }xms, $loc))."\", color = black, fillcolor = orange, style = filled];\n";1407 print "\"location$b-$l\" [label = \"$building" . q{/} . join(q{\n}, split(m{ / }xms, $loc)) . "\", color = black, fillcolor = orange, style = filled];\n"; 1408 1408 # print "\"location$b-$l\" [label = \"$building / $loc\", color = black, fillcolor = orange, style = filled];\n"; 1409 1409 print "\"building$b\" -> \"location$b-$l\" [len = 2, color = firebrick]\n";
Note: See TracChangeset
for help on using the changeset viewer.