* Added a missing modified_date to ip_addresses in Database->get_ip_addresses().

* Updated scan-network to purge old historical ip_addresses when clearing duplicates now.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent aa64b0f7fa
commit e6dcff1cf1
  1. 16
      Anvil/Tools/Database.pm
  2. 2
      Anvil/Tools/System.pm
  3. 22
      scancore-agents/scan-network/scan-network
  4. 1
      tools/anvil-daemon

@ -3613,9 +3613,9 @@ SELECT
FROM
bridges
WHERE
bridge_host_uuid = ".$anvil->Database->quote($host_uuid)."
bridge_host_uuid = ".$anvil->Database->quote($host_uuid)."
AND
bridge_id != 'DELETED'
bridge_id != 'DELETED'
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
@ -3687,7 +3687,7 @@ SELECT
FROM
network_interfaces
WHERE
network_interface_host_uuid = ".$anvil->Database->quote($host_uuid)."
network_interface_host_uuid = ".$anvil->Database->quote($host_uuid)."
AND
network_interface_operational != 'DELETED'
;";
@ -3779,7 +3779,15 @@ AND
{
# This isn't a network we should know about (ie: it might be a stray 'virbrX'
# birdge), delete this IP.
my $query = "UPDATE ip_addresses SET ip_address_note = 'DELETED' WHERE ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid).";";
my $query = "
UPDATE
ip_addresses
SET
ip_address_note = 'DELETED',
modified_date = ".$anvil->Database->quote($anvil->Database->refresh_timestamp)."
WHERE
ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
next;

@ -5051,7 +5051,7 @@ sub update_hosts
$anvil->Database->get_ip_addresses({debug => $debug});
# Load the IPs we manage. If we find any entries for these that we don't expect, we'll remove them.
$anvil->Database->get_ip_addresses({debug => $debug});
$anvil->Network->load_ips({debug => $debug});
foreach my $host_uuid (keys %{$anvil->data->{hosts}{host_uuid}})
{

@ -1456,9 +1456,14 @@ ORDER BY
uuid => $ip_address_uuid,
}});
my $query = "DELETE FROM ip_addresses WHERE ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
my $queries = [];
push @{$queries}, "DELETE FROM history.ip_addresses WHERE ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid).";";
push @{$queries}, "DELETE FROM ip_addresses WHERE ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid).";";
foreach my $query (@{$queries})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
}
$anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__});
$count--;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { count => $count }});
@ -1476,9 +1481,14 @@ ORDER BY
uuid => $ip_address_uuid,
}});
my $query = "DELETE FROM ip_addresses WHERE ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
my $queries = [];
push @{$queries}, "DELETE FROM history.ip_addresses WHERE ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid).";";
push @{$queries}, "DELETE FROM ip_addresses WHERE ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid).";";
foreach my $query (@{$queries})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
}
$anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__});
$count--;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { count => $count }});

@ -143,6 +143,7 @@ $anvil->data->{switches}{'refresh-json'} = "";
$anvil->data->{switches}{'run-once'} = 0;
$anvil->data->{switches}{'main-loop-only'} = 0;
$anvil->data->{switches}{'no-start'} = 0;
$anvil->data->{switches}{'purge'} = 0;
$anvil->data->{switches}{'startup-only'} = 0;
$anvil->Get->switches;

Loading…
Cancel
Save