- Timestamp:
- Jul 24, 2009, 2:11:18 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r57 r58 176 176 # my $cmd = "grep -e '".'\b'."$param_ip_or_host".'\b'."' /var/lib/arpwatch/arp.dat | sort +2rn | head -1"; 177 177 # my $cmd = "grep -he '".'\b'."$param_ip_or_host".'\b'."' /var/lib/arpwatch/*.dat | sort +2rn | head -1"; 178 my $cmd = "grep -he '" .'\b'."$param_ip_or_host".'\b'."' /var/lib/arpwatch/$interface.dat | sort -rn -k 3,3 | head -1";178 my $cmd = "grep -he '" . '\b' . "$param_ip_or_host" . '\b' . "' /var/lib/arpwatch/$interface.dat | sort -rn -k 3,3 | head -1"; 179 179 my $cmd_arpwatch = shell_command $cmd; 180 180 my ($arp, $ip, $timestamp, $host) = split m/ \s+ /xms, $cmd_arpwatch; … … 298 298 return '00' if $car eq '00UNKNOW'; 299 299 my %table = ( 300 "0"=>"0", "1"=>"1", "2"=>"2", "3"=>"3", "4"=>"4",301 "5"=>"5", "6"=>"6", "7"=>"7", "8"=>"8", "9"=>"9",302 "A"=>"10", "B"=>"11", "C"=>"12", "D"=>"13", "E"=>"14", "F"=>"15"300 '0'=>'0', '1'=>'1', '2'=>'2', '3'=>'3', '4'=>'4', 301 '5'=>'5', '6'=>'6', '7'=>'7', '8'=>'8', '9'=>'9', 302 'A'=>'10', 'B'=>'11', 'C'=>'12', 'D'=>'13', 'E'=>'14', 'F'=>'15' 303 303 ); 304 304 my @chars = split m//xms, $car; … … 327 327 328 328 my %ret; 329 $ret{switch_description} = "unknow";330 $ret{switch_port} = "0";329 $ret{switch_description} = 'unknow'; 330 $ret{switch_port} = '0'; 331 331 332 332 return %ret if $arp eq 'unknow';; … … 398 398 } 399 399 400 my $research = "1.3.6.1.2.1.17.4.3.1.2".arp_hex_to_dec($arp);400 my $research = '1.3.6.1.2.1.17.4.3.1.2' . arp_hex_to_dec($arp); 401 401 LOOP_ON_ALL_SWITCH: 402 402 for my $sw (@SWITCH) { … … 550 550 my %resol_arp = resolve_ip_arp_host($clientname); #resolution arp 551 551 my %where = find_switch_port($resol_arp{mac_address}); #retrouve l'emplacement 552 printf "%-22s %2i %-30s %-15s %18s", $where{switch_description}, $where{switch_port}, $resol_arp{hostname_fq}, $resol_arp{ipv4_address}, $resol_arp{mac_address}."\n"552 printf '%-22s %2i %-30s %-15s %18s', $where{switch_description}, $where{switch_port}, $resol_arp{hostname_fq}, $resol_arp{ipv4_address}, $resol_arp{mac_address}."\n" 553 553 unless $where{switch_description} eq 'unknow' and $resol_arp{hostname_fq} eq 'unknow' and $resol_arp{mac_address} eq 'unknow'; 554 554 } … … 572 572 $year += 1900; 573 573 $mon++; 574 my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min;574 my $date = sprintf '%04i-%02i-%02i %02i:%02i', $year, $mon, $mday, $hour, $min; 575 575 576 576 printf "%-22s %2s %-30s %-15s %-18s %s\n", … … 656 656 printf "\rComputer scanned: %4i/%i (%2i%%)", $i, $number_of_computer, $total_percent; 657 657 # printf ", Computer detected: %4i/%i (%2i%%)", $detected_computer, $size_of_database, int(($detected_computer*100)/$size_of_database); 658 printf ", detected: %4i/%i (%2i%%)", $detected_computer, $size_of_database, int(($detected_computer*100)/$size_of_database);659 printf " [Time: %02i:%02i / %02i:%02i]", int($localtime/60), $localtime % 60, int($time_elapse/60), $time_elapse % 60;660 # printf " [%02i:%02i/%02i:%02i]", int($localtime/60), $localtime % 60, int($time_elapse/60), $time_elapse % 60;661 printf " %-14s", $one_computer;658 printf ', detected: %4i/%i (%2i%%)', $detected_computer, $size_of_database, int(($detected_computer*100)/$size_of_database); 659 printf ' [Time: %02i:%02i / %02i:%02i]', int($localtime/60), $localtime % 60, int($time_elapse/60), $time_elapse % 60; 660 # printf ' [%02i:%02i/%02i:%02i]', int($localtime/60), $localtime % 60, int($time_elapse/60), $time_elapse % 60; 661 printf ' %-14s', $one_computer; 662 662 663 663 my %resol_arp = resolve_ip_arp_host($one_computer,$current_interface); … … 823 823 $year += 1900; 824 824 $mon++; 825 my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min;825 my $date = sprintf '%04i-%02i-%02i %02i:%02i', $year, $mon, $mday, $hour, $min; 826 826 827 827 printf "%-25s %2s <------- %-30s %-15s %-18s %s\n", … … 893 893 $year += 1900; 894 894 $mon++; 895 my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min;895 my $date = sprintf '%04i-%02i-%02i %02i:%02i', $year, $mon, $mday, $hour, $min; 896 896 897 897 # $odd_or_even++; … … 901 901 my $switch_hostname = $computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description} || 'unkown'; 902 902 chomp $switch_hostname; 903 my $switch_hostname_sort = sprintf "%s %3s",$switch_hostname, $computerdb->{$ip}{switch_port};904 905 my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /xms, $ip);906 907 my $mac_sort = sprintf "%04i-%s", 9999 - $mac_count{$computerdb->{$ip}{mac_address}}, $computerdb->{$ip}{mac_address};903 my $switch_hostname_sort = sprintf '%s %3s' ,$switch_hostname, $computerdb->{$ip}{switch_port}; 904 905 my $ip_sort = sprintf '%03i%03i%03i%03i', split( m/ \. /xms, $ip); 906 907 my $mac_sort = sprintf '%04i-%s', 9999 - $mac_count{$computerdb->{$ip}{mac_address}}, $computerdb->{$ip}{mac_address}; 908 908 909 909 $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^ \d+ \. \d+ \. \d+ \. \d+ $/xms; … … 932 932 for my $sw (sort keys %db_switch_output_port) { 933 933 934 my $switch_hostname_sort = sprintf "%s %3s",$sw, $db_switch_output_port{$sw};934 my $switch_hostname_sort = sprintf '%s %3s' ,$sw, $db_switch_output_port{$sw}; 935 935 936 936 $typerow = $typerow eq 'even' ? 'odd' : 'even'; … … 945 945 $year += 1900; 946 946 $mon++; 947 my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min;948 949 my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /xms, $ipv4_address);950 951 my $mac_sort = sprintf "%04i-%s", 9999, $mac_address;952 953 my ( $host_short ) = sprintf "%s %3s", split(m/ \. /xms, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port};947 my $date = sprintf '%04i-%02i-%02i %02i:%02i', $year, $mon, $mday, $hour, $min; 948 949 my $ip_sort = sprintf '%03i%03i%03i%03i', split( m/ \. /xms, $ipv4_address); 950 951 my $mac_sort = sprintf '%04i-%s', 9999, $mac_address; 952 953 my ( $host_short ) = sprintf '%s %3s' , split(m/ \. /xms, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port}; 954 954 955 955 print <<"END_HTML"; … … 984 984 for my $sw (keys %{$db_switch_connected_on_port{$swport}}) { 985 985 986 my $switch_hostname_sort = sprintf "%s %3s",$sw_connect, $port_connect;986 my $switch_hostname_sort = sprintf '%s %3s' ,$sw_connect, $port_connect; 987 987 988 988 my $mac_address = $db_switch{$sw}->{mac_address}; … … 993 993 $year += 1900; 994 994 $mon++; 995 my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min;996 997 my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /xms, $ipv4_address);998 999 my $mac_sort = sprintf "%04i-%s", 9999, $mac_address;995 my $date = sprintf '%04i-%02i-%02i %02i:%02i', $year,$mon,$mday,$hour,$min; 996 997 my $ip_sort = sprintf '%03i%03i%03i%03i', split( m/ \. /xms, $ipv4_address); 998 999 my $mac_sort = sprintf '%04i-%s', 9999, $mac_address; 1000 1000 1001 1001 $typerow = $typerow eq 'even' ? 'odd' : 'even'; … … 1003 1003 if (exists $db_switch_output_port{$sw}) { 1004 1004 1005 my ( $host_short ) = sprintf "%s %3s", split( m/\./xms, $sw, 1), $db_switch_output_port{$sw};1005 my ( $host_short ) = sprintf '%s %3s' , split( m/\./xms, $sw, 1), $db_switch_output_port{$sw}; 1006 1006 1007 1007 print <<"END_HTML"; … … 1112 1112 } 1113 1113 1114 my $research = "1.3.6.1.2.1.17.4.3.1.2".arp_hex_to_dec($mac_address);1114 my $research = '1.3.6.1.2.1.17.4.3.1.2' . arp_hex_to_dec($mac_address); 1115 1115 print "Klask search OID $research on switch $switch_name\n"; 1116 1116
Note: See TracChangeset
for help on using the changeset viewer.