Changeset 58 for trunk/klask


Ignore:
Timestamp:
Jul 24, 2009, 2:11:18 AM (15 years ago)
Author:
g7moreau
Message:
  • Suppress Useless interpolation of literal string
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r57 r58  
    176176   # my $cmd = "grep  -e '".'\b'."$param_ip_or_host".'\b'."' /var/lib/arpwatch/arp.dat | sort +2rn | head -1";
    177177   # 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";
    179179   my $cmd_arpwatch = shell_command $cmd;
    180180   my ($arp, $ip, $timestamp, $host) = split m/ \s+ /xms, $cmd_arpwatch;
     
    298298   return '00' if $car eq '00UNKNOW';
    299299   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'
    303303      );
    304304   my @chars = split m//xms, $car;
     
    327327
    328328   my %ret;
    329    $ret{switch_description} = "unknow";
    330    $ret{switch_port} = "0";
     329   $ret{switch_description} = 'unknow';
     330   $ret{switch_port} = '0';
    331331
    332332   return %ret if $arp eq 'unknow';;
     
    398398      }
    399399
    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);
    401401   LOOP_ON_ALL_SWITCH:
    402402   for my $sw (@SWITCH) {
     
    550550      my %resol_arp = resolve_ip_arp_host($clientname);          #resolution arp
    551551      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"
    553553         unless $where{switch_description} eq 'unknow' and $resol_arp{hostname_fq} eq 'unknow' and $resol_arp{mac_address} eq 'unknow';
    554554      }
     
    572572      $year += 1900;
    573573      $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;
    575575
    576576      printf "%-22s %2s %-30s %-15s %-18s %s\n",
     
    656656         printf "\rComputer scanned: %4i/%i (%2i%%)",  $i,                 $number_of_computer, $total_percent;
    657657#         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;
    662662
    663663         my %resol_arp = resolve_ip_arp_host($one_computer,$current_interface);
     
    823823      $year += 1900;
    824824      $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;
    826826
    827827      printf "%-25s  %2s  <-------  %-30s %-15s %-18s %s\n",
     
    893893      $year += 1900;
    894894      $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;
    896896
    897897#      $odd_or_even++;
     
    901901      my $switch_hostname = $computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description} || 'unkown';
    902902      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};
    908908
    909909      $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^ \d+ \. \d+ \. \d+ \. \d+ $/xms;
     
    932932   for my $sw (sort keys %db_switch_output_port) {
    933933
    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};
    935935
    936936      $typerow = $typerow eq 'even' ? 'odd' : 'even';
     
    945945      $year += 1900;
    946946      $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};
    954954
    955955      print <<"END_HTML";
     
    984984      for my $sw (keys %{$db_switch_connected_on_port{$swport}}) {
    985985
    986          my $switch_hostname_sort = sprintf "%s %3s" ,$sw_connect, $port_connect;
     986         my $switch_hostname_sort = sprintf '%s %3s' ,$sw_connect, $port_connect;
    987987
    988988      my $mac_address = $db_switch{$sw}->{mac_address};
     
    993993      $year += 1900;
    994994      $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;
    10001000
    10011001      $typerow = $typerow eq 'even' ? 'odd' : 'even';
     
    10031003         if (exists $db_switch_output_port{$sw}) {
    10041004
    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};
    10061006
    10071007            print <<"END_HTML";
     
    11121112      }
    11131113
    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);
    11151115   print "Klask search OID $research on switch $switch_name\n";
    11161116
Note: See TracChangeset for help on using the changeset viewer.