Update new ips detected

This commit is contained in:
fbsanchez 2020-04-16 14:29:35 +02:00
parent fa0b5760a9
commit b3ed5dab63
1 changed files with 19 additions and 0 deletions

View File

@ -1121,6 +1121,25 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
'SELECT modo FROM tagente WHERE id_agente = ?',
$agent_id
);
# Update new IPs.
# Add found IP addresses to the agent.
if (ref($data->{'other_ips'}) eq 'ARRAY') {
foreach my $ip_addr (@{$data->{'other_ips'}}) {
my $addr_id = get_addr_id($self->{'dbh'}, $ip_addr);
$addr_id = add_address($self->{'dbh'}, $ip_addr) unless ($addr_id > 0);
next unless ($addr_id > 0);
# Assign the new address to the agent
my $agent_addr_id = get_agent_addr_id($self->{'dbh'}, $addr_id, $agent_id);
if ($agent_addr_id <= 0) {
db_do(
$self->{'dbh'}, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
VALUES (?, ?)', $addr_id, $agent_id
);
}
}
}
}
$data->{'agent'}{'agent_id'} = $agent_id;