diff --git a/lib/Ocsinventory/Agent/Modules/SnmpScan.pm b/lib/Ocsinventory/Agent/Modules/SnmpScan.pm index dc35e495..e309d75a 100644 --- a/lib/Ocsinventory/Agent/Modules/SnmpScan.pm +++ b/lib/Ocsinventory/Agent/Modules/SnmpScan.pm @@ -439,23 +439,18 @@ sub snmp_ip_scan { my $snmp_scan_type = $self->{scan_type_snmp}; # check for scan type and if the required module is available - if ($snmp_scan_type eq 'ICMP' && $common->can_load('Net::Ping')) { - my $block=Net::Netmask->new($net_to_scan); - my $size=$block->size()-2; - my $index=1; - $logger->debug("Scanning $net_to_scan with ping"); - my $ping=Net::Ping->new("icmp",1); - - while ($index <= $size) { - my $res=$block->nth($index); - if ($ping->ping($res)) { - $logger->debug("Found $res"); - push( @{$self->{netdevices}},{ IPADDR=>$res }) unless $self->search_netdevice($res); - } + if ($snmp_scan_type eq 'ICMP' && $common->can_run('fping')) { + my $block = Net::Netmask->new($net_to_scan); + my $network = $block->base() . "/" . $block->bits(); + $logger->debug("Scanning $network with fping"); + + my $fping_output = `fping -aq -g $network 2>/dev/null`; + my $index = 1; + foreach my $ip (split /\n/, $fping_output) { + $logger->debug("Found $ip"); + push(@{$self->{netdevices}}, { IPADDR => $ip }) unless $self->search_netdevice($ip); $index++; } - $ping->close(); - } elsif ($snmp_scan_type eq 'NMAP' && $common->can_load('Nmap::Parser')) { $logger->debug("Scanning $net_to_scan with nmap"); my $nmaparser = Nmap::Parser->new;