Index: trunk/klask
===================================================================
--- trunk/klask	(revision 403)
+++ trunk/klask	(revision 404)
@@ -298,11 +298,9 @@
    $ret{'hostname_fq'} = $hostname_fq if defined $hostname_fq;
 
-   # my $cmd = q{grep  -he '\b} . $param_ip_or_host . q{\b' } . "/var/lib/arpwatch/$interface.dat | sort -rn -k 3,3 | head -1";
-   #my $cmd = q{grep  -he '\b} . $ret{'ipv4_address'} . q{\b' } . "/var/lib/arpwatch/$interface.dat | sort -rn -k 3,3 | head -1";
-   my $cmd = q{grep  -He '\b} . $ret{'ipv4_address'} . q{\b' } . "/var/lib/arpwatch/$interface.dat" . '| sed -e \'s|^/var/lib/arpwatch/\(.*\)\.dat:|\1 |;\' | sort -rn -k 4,4 | head -1';
-   #grep -He 194.254.66.252 /var/lib/arpwatch/*.dat | sed -e 's|^/var/lib/arpwatch/\(.*\)\.dat:|\1\t|;' | sort -rn -k 4,4 | head -1
-
+   my $cmd = q{grep -He '\b}
+      . $ret{'ipv4_address'} . q{\b' }
+      . "/var/lib/arpwatch/$interface.dat"
+      . '| sed -e \'s|^/var/lib/arpwatch/\(.*\)\.dat:|\1 |;\' | sort -rn -k 4,4 | head -1';
    my $cmd_arpwatch = shell_command $cmd;
-   #my ($arp, $ip, $timestamp, $host) = split m/ \s+ /xms, $cmd_arpwatch;
    my ($interface2, $arp, $ip, $timestamp, $host) = split m/ \s+ /xms, $cmd_arpwatch;
 
@@ -661,5 +659,5 @@
             }
 
-         $ret->{$sw->{'hostname'}} = {};
+         $ret->{$sw->{'hostname'}}                = {};
          $ret->{$sw->{'hostname'}}{'hostname'}    = $sw->{'hostname'};
          $ret->{$sw->{'hostname'}}{'description'} = $sw->{'description'};
@@ -1252,10 +1250,13 @@
    LOOP_ON_COMPUTER:
    for my $clientname (@computer) {
-      my %resol_arp = resolve_ip_arp_host($clientname); # resolution arp
+      my %resol_arp = resolve_ip_arp_host($clientname);                          # resolution arp
       my $vlan_name = get_current_vlan_name_for_interface($resol_arp{'interface'});
       my $vlan_id   = get_current_vlan_id($vlan_name);
       my %where     = find_switch_port($resol_arp{'mac_address'}, '', $vlan_id); # retrouve l'emplacement
 
-      next LOOP_ON_COMPUTER if $where{'switch_description'} eq 'unknow' or $resol_arp{'hostname_fq'} eq 'unknow' or $resol_arp{'mac_address'} eq 'unknow';
+      next LOOP_ON_COMPUTER
+         if $where{'switch_description'} eq 'unknow'
+         or $resol_arp{'hostname_fq'}    eq 'unknow'
+         or $resol_arp{'mac_address'}    eq 'unknow';
 
       printf '%-22s %2s %-30s %-15s %18s',
@@ -1386,33 +1387,33 @@
 
    {
-   my $switch_checksum = get_switchdb_checksum(%SWITCH_DB);
-   # Remplis le champs portignore des ports d'inter-connection pour chaque switch
-   my $switch_connection = YAML::Syck::LoadFile("$KLASK_SW_FILE");
-   if ($switch_checksum ne $switch_connection->{'checksum'}) { # Verify checksum
-      if ($no_rebuildsw) {
-         print "WARNING: switch database is outdate, please rebuild if with updatesw command\n";
-         }
-      else {
-         print "WARNING: switch database is going to be rebuilt\n";
-         update_switchdb(verbose => $verbose)
-         }
-      }
-
-   my %db_switch_output_port       = %{$switch_connection->{'output_port'}};
-   my %db_switch_connected_on_port = %{$switch_connection->{'connected_on_port'}};
-   my %db_switch_chained_port = ();
-   for my $swport (keys %db_switch_connected_on_port) {
-      my ($sw_connect, $port_connect) = split m/ $SEP_SWITCH_PORT /xms, $swport, 2;
-      $db_switch_chained_port{$sw_connect} .= "$port_connect:";
-      }
-   for my $sw (@SWITCH_LIST) {
-      push @{$sw->{'portignore'}}, $db_switch_output_port{$sw->{'hostname'}}  if exists $db_switch_output_port{$sw->{'hostname'}};
-      if ( exists $db_switch_chained_port{$sw->{'hostname'}} ) {
-         chop $db_switch_chained_port{$sw->{'hostname'}};
-         push @{$sw->{'portignore'}}, split m/ : /xms, $db_switch_chained_port{$sw->{'hostname'}};
-         }
-#      print "$sw->{'hostname'} ++ @{$sw->{'portignore'}}\n";
-      }
-   }
+      my $switch_checksum = get_switchdb_checksum(%SWITCH_DB);
+      # Remplis le champs portignore des ports d'inter-connection pour chaque switch
+      my $switch_connection = YAML::Syck::LoadFile("$KLASK_SW_FILE");
+      if ($switch_checksum ne $switch_connection->{'checksum'}) { # Verify checksum
+         if ($no_rebuildsw) {
+            print "WARNING: switch database is outdate, please rebuild if with updatesw command\n";
+            }
+         else {
+            print "WARNING: switch database is going to be rebuilt\n";
+            update_switchdb(verbose => $verbose)
+            }
+         }
+
+      my %db_switch_output_port       = %{$switch_connection->{'output_port'}};
+      my %db_switch_connected_on_port = %{$switch_connection->{'connected_on_port'}};
+      my %db_switch_chained_port = ();
+      for my $swport (keys %db_switch_connected_on_port) {
+         my ($sw_connect, $port_connect) = split m/ $SEP_SWITCH_PORT /xms, $swport, 2;
+         $db_switch_chained_port{$sw_connect} .= "$port_connect:";
+         }
+      for my $sw (@SWITCH_LIST) {
+         push @{$sw->{'portignore'}}, $db_switch_output_port{$sw->{'hostname'}} if exists $db_switch_output_port{$sw->{'hostname'}};
+         if (exists $db_switch_chained_port{$sw->{'hostname'}}) {
+            chop $db_switch_chained_port{$sw->{'hostname'}};
+            push @{$sw->{'portignore'}}, split m/ : /xms, $db_switch_chained_port{$sw->{'hostname'}};
+            }
+         #print "$sw->{'hostname'} ++ @{$sw->{'portignore'}}\n";
+         }
+      }
 
    my %router_mac_ip = ();
@@ -1471,5 +1472,7 @@
 
          # do not have a mac address
-         if ($resol_arp{'mac_address'} eq 'unknow' or (exists $resol_arp{'timestamps'} and $resol_arp{'timestamps'} < ($timestamp - 3 * 3600))) {
+         if ($resol_arp{'mac_address'} eq 'unknow'
+               or (exists $resol_arp{'timestamps'} and $resol_arp{'timestamps'} < ($timestamp - 3 * 3600))
+               ) {
             $computer_not_detected{$one_computer} = $current_net;
             next LOOP_ON_COMPUTER;
@@ -1528,9 +1531,10 @@
 
          # mise à jour de la date de détection si détection plus récente par arpwatch
-         $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'}   = $resol_arp{'timestamp'} if exists $resol_arp{'timestamp'} and $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $resol_arp{'timestamp'};
+         $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'}   = $resol_arp{'timestamp'}
+            if exists $resol_arp{'timestamp'} and $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $resol_arp{'timestamp'};
 
          # relance un arping sur la machine si celle-ci n'a pas été détectée depuis plus d'une semaine
-         # push @computer_not_detected, $resol_arp{'ipv4_address'} if $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $timestamp_last_week;
-         $computer_not_detected{$resol_arp{'ipv4_address'}} = $current_net if $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $timestamp_last_week;
+         $computer_not_detected{$resol_arp{'ipv4_address'}} = $current_net
+            if $computerdb->{$resol_arp{'ipv4_address'}}{'timestamp'} < $timestamp_last_week;
 
          }
@@ -1545,5 +1549,6 @@
       my $current_net       = $computer_not_detected{$one_computer};
       my $current_interface = get_current_interface($current_net);
-      system "arping -c 1 -w 1 -rR -i $current_interface $one_computer > /dev/null 2>&1" if get_current_scan_mode($current_net) eq 'active';
+      system "arping -c 1 -w 1 -rR -i $current_interface $one_computer > /dev/null 2>&1"
+         if get_current_scan_mode($current_net) eq 'active';
       }
    return;
@@ -1807,5 +1812,6 @@
 
       # to be improve in the future
-      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{'hostname_fq'} eq ($computerdb->{$ip}{'switch_hostname'} || $computerdb->{$ip}{'switch_description'}); # switch on himself !
+      next LOOP_ON_IP_ADDRESS
+         if $computerdb->{$ip}{'hostname_fq'} eq ($computerdb->{$ip}{'switch_hostname'} || $computerdb->{$ip}{'switch_description'}); # switch on himself !
 
       my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime $computerdb->{$ip}{'timestamp'};
@@ -1910,5 +1916,6 @@
 
       my $vlan = '';
-      $vlan = $computerdb->{$ip}{'network'}.' ('.get_current_vlan_id($computerdb->{$ip}{'network'}).')' if $computerdb->{$ip}{'network'};
+      $vlan = $computerdb->{$ip}{'network'} . ' (' . get_current_vlan_id($computerdb->{$ip}{'network'}) . ')'
+         if $computerdb->{$ip}{'network'};
 
       my $parent_port_hr = format_aggregator4html($computerdb->{$ip}{'switch_port_hr'});
@@ -2788,5 +2795,5 @@
             LOOP_ON_DATABASE:
             for my $ip_db (keys %{$computerdb}) {
-               next LOOP_ON_DATABASE if $computerdb->{$ip_db}{'mac_address'} ne $mac_address;
+               next LOOP_ON_DATABASE   if $computerdb->{$ip_db}{'mac_address'} ne $mac_address;
                next LOOP_ON_IP_ADDRESS if $computerdb->{$ip_db}{'timestamp'} > $timestamp_barrier;
                }
@@ -2803,5 +2810,6 @@
          my $packed_ip   = scalar gethostbyname($ip);
          my $hostname_fq = 'unknown';
-            $hostname_fq = scalar gethostbyaddr($packed_ip, AF_INET) || 'unknown' if defined $packed_ip and get_current_scan_mode($vlan) eq 'active';
+            $hostname_fq = scalar gethostbyaddr($packed_ip, AF_INET) || 'unknown'
+               if defined $packed_ip and get_current_scan_mode($vlan) eq 'active';
 
          next LOOP_ON_IP_ADDRESS if $hostname_fq =~ m/$RE_FLOAT_HOSTNAME/;
@@ -3149,5 +3157,5 @@
 
    my $switch_connection = YAML::Syck::LoadFile("$KLASK_SW_FILE");
-   my $interway = 0;
+   my $interway          = 0;
 
    if ($args{'way'} =~ m/all|desc/) {
