Changeset 179


Ignore:
Timestamp:
Aug 25, 2016, 11:51:49 AM (8 years ago)
Author:
g7moreau
Message:
  • Add scan-mode parameter active/passive
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r178 r179  
    530530   }
    531531
     532sub get_current_scan_mode {
     533   my $vlan_name = shift;
     534
     535   return $KLASK_CFG->{network}{$vlan_name}{'scan-mode'} || $DEFAULT{'scan-mode'} || 'active';
     536   }
     537
    532538sub get_current_vlan_name_for_interface {
    533539   my $interface = shift;
     
    939945
    940946   ALL_NETWORK:
    941    for my $net (@network) {
    942 
    943       my @computer = get_list_ip($net);
    944       my $current_interface = get_current_interface($net);
    945 
    946       fast_ping(@computer);
     947   for my $current_net (@network) {
     948
     949      my @computer = get_list_ip($current_net);
     950      my $current_interface = get_current_interface($current_net);
     951
     952      fast_ping(@computer) if get_current_scan_mode($current_net) eq 'active';
    947953
    948954      LOOP_ON_COMPUTER:
     
    968974         # do not search on router connection (why ?)
    969975         if ( exists $router_mac_ip{$resol_arp{mac_address}}) {
    970             $computer_not_detected{$one_computer} = $current_interface;
     976            $computer_not_detected{$one_computer} = $current_net;
    971977            next LOOP_ON_COMPUTER;
    972978            }
     
    974980         # do not search on switch inter-connection
    975981         if (exists $switch_level{$resol_arp{hostname_fq}}) {
    976             $computer_not_detected{$one_computer} = $current_interface;
     982            $computer_not_detected{$one_computer} = $current_net;
    977983            next LOOP_ON_COMPUTER;
    978984            }
     
    985991         # do not have a mac address
    986992         if ($resol_arp{mac_address} eq 'unknow' or (exists $resol_arp{timestamps} and $resol_arp{timestamps} < ($timestamp - 3 * 3600))) {
    987             $computer_not_detected{$one_computer} = $current_interface;
     993            $computer_not_detected{$one_computer} = $current_net;
    988994            next LOOP_ON_COMPUTER;
    989995            }
     
    10171023               switch_port_hr     => $where{switch_port_hr},
    10181024               timestamp          => $timestamp,
    1019                network            => $net,
     1025               network            => $current_net,
    10201026               };
    10211027            next LOOP_ON_COMPUTER;
     
    10331039               switch_port_hr     => $where{switch_port_hr},
    10341040               timestamp          => $resol_arp{timestamp},
    1035                network            => $net,
     1041               network            => $current_net,
    10361042               };
    10371043            }
     
    10451051         # relance un arping sur la machine si celle-ci n'a pas été détectée depuis plus d'une semaine
    10461052#         push @computer_not_detected, $resol_arp{ipv4_address} if $computerdb->{$resol_arp{ipv4_address}}{timestamp} < $timestamp_last_week;
    1047          $computer_not_detected{$resol_arp{ipv4_address}} = $current_interface if $computerdb->{$resol_arp{ipv4_address}}{timestamp} < $timestamp_last_week;
     1053         $computer_not_detected{$resol_arp{ipv4_address}} = $current_net if $computerdb->{$resol_arp{ipv4_address}}{timestamp} < $timestamp_last_week;
    10481054
    10491055         }
     
    10591065
    10601066   for my $one_computer (keys %computer_not_detected) {
    1061       my $interface = $computer_not_detected{$one_computer};
    1062       system "arping -c 1 -w 1 -rR -i $interface $one_computer &>/dev/null";
    1063 #      print  "arping -c 1 -w 1 -rR -i $interface $one_computer 2>/dev/null\n";
     1067      my $current_net = $computer_not_detected{$one_computer};
     1068      my $current_interface = get_current_interface($current_net);
     1069      system "arping -c 1 -w 1 -rR -i $current_interface $one_computer &>/dev/null" if get_current_scan_mode($current_net) eq 'active';
     1070#      print  "arping -c 1 -w 1 -rR -i $current_interface $one_computer 2>/dev/null\n";
    10641071      }
    10651072   return;
Note: See TracChangeset for help on using the changeset viewer.