diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm
index 3d88b40a..e524dd70 100644
--- a/Anvil/Tools/Database.pm
+++ b/Anvil/Tools/Database.pm
@@ -17634,7 +17634,7 @@ sub _find_column
This returns the most up to date database ID, the time it was last updated and an array or DB IDs that are behind.
-If there is a problem, C<< !!error!! >> is returned.
+If there is a problem, C<< !!error!! >> is returned. If this is called by a host that isn't a Striker, C<< 0 >> is returned and no actions are take.
Parameters;
@@ -17662,6 +17662,14 @@ sub _find_behind_databases
tables => $tables,
}});
+ # If we're not a striker, return.
+ my $host_type = $anvil->Get->host_type();
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host_type => $host_type }});
+ if ($host_type ne "striker")
+ {
+ return(0);
+ }
+
# This should always be set, but just in case...
if (not $source)
{
diff --git a/scancore-agents/scan-network/scan-network b/scancore-agents/scan-network/scan-network
index 249db986..99573555 100755
--- a/scancore-agents/scan-network/scan-network
+++ b/scancore-agents/scan-network/scan-network
@@ -85,6 +85,9 @@ process_health($anvil);
# This clears the TX and RX variable data for interfaces older than 'scancore::database::age_out'.
clear_old_variables($anvil);
+# This removes network interfaces that have been marked as DELETED for a while now.
+clear_old_interfaces($anvil);
+
# Shut down.
$anvil->ScanCore->agent_shutdown({agent => $THIS_FILE});
@@ -93,6 +96,81 @@ $anvil->ScanCore->agent_shutdown({agent => $THIS_FILE});
# Functions #
#############################################################################################################
+# This removes network interfaces that have been marked as DELETED for a while now.
+sub clear_old_interfaces
+{
+ my ($anvil) = @_;
+
+ # Read in all interfaces and for each, delete historical records over the age-out time.
+ my $age = $anvil->data->{scancore}{database}{age_out};
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { age => $age }});
+
+ if ($age =~ /\D/)
+ {
+ # Age is not valid, set it to defaults.
+ $age = 24;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { age => $age }});
+ }
+
+ my $query = "SELECT now() - '".$age."h'::interval;";
+ my $old_timestamp = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0];
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
+ query => $query,
+ old_timestamp => $old_timestamp,
+ }});
+
+ $query = "
+SELECT
+ network_interface_uuid,
+ network_interface_mac_address,
+ network_interface_name
+FROM
+ network_interfaces
+WHERE
+ network_interface_host_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)."
+AND
+ network_interface_operational = 'DELETED'
+AND
+ modified_date < '".$old_timestamp."'
+ORDER BY
+ network_interface_name ASC;
+;";
+ my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
+ my $count = @{$results};
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ results => $results,
+ count => $count,
+ }});
+ foreach my $row (@{$results})
+ {
+ my $network_interface_uuid = $row->[0];
+ my $network_interface_mac_address = $row->[1];
+ my $network_interface_name = $row->[2];
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ 's1:network_interface_uuid' => $network_interface_uuid,
+ 's2:network_interface_mac_address' => $network_interface_mac_address,
+ 's3:network_interface_name' => $network_interface_name,
+ }});
+
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_network_log_0002", variables => {
+ age => $age,
+ mac => $network_interface_mac_address,
+ name => $network_interface_name,
+ }});
+
+ my $queries = [];
+ push @{$queries}, "DELETE FROM history.network_interfaces WHERE network_interface_uuid = '".$network_interface_uuid."';";
+ push @{$queries}, "DELETE FROM network_interfaces WHERE network_interface_uuid = '".$network_interface_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__});
+ }
+
+ return(0);
+}
+
# This clears the TX and RX variable data for interfaces older than 'scancore::database::age_out'.
sub clear_old_variables
{
@@ -416,8 +494,14 @@ sub collect_data
{
### Set some fake values.
# Speed is "as fast as possible", so we'll record 100 Gbps, but that is really kind of arbitrary.
- $speed = 1000 if ((not $speed) or ($speed eq "-1"));
- $duplex = "full" if not $duplex;
+ if ((not $speed) or ($speed eq "-1"))
+ {
+ $speed = 10000;
+ }
+ if ((not $duplex) or ($duplex eq "unknown"))
+ {
+ $duplex = "full";
+ }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
speed => $speed,
duplex => $duplex,
diff --git a/scancore-agents/scan-network/scan-network.xml b/scancore-agents/scan-network/scan-network.xml
index 84081118..459a172a 100644
--- a/scancore-agents/scan-network/scan-network.xml
+++ b/scancore-agents/scan-network/scan-network.xml
@@ -215,5 +215,6 @@ This mode is NOT supported by the Anvil! Intelligent Availability™ platform!
Aging out RX and TX data under: [#!variable!records!#] interfaces. These have 1 or more historical records older than: [#!variable!age!#] hours old from the database host: [#!variable!host!#].
+ The old network interface: [#!variable!name!#] with the MAC address: [#!variable!mac!#] was marked as deleted more than: [#!variable!age!#] hours ago. Purging it from the database.
diff --git a/share/words.xml b/share/words.xml
index bf3e9147..122f2d16 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -3188,15 +3188,19 @@ We will sleep a bit and try again.
+
+
+
+
+
+
+
-
-
-
-
+
@@ -3204,6 +3208,8 @@ We will sleep a bit and try again.
+
+
@@ -3230,6 +3236,7 @@ We will sleep a bit and try again.
+
@@ -3255,6 +3262,12 @@ We will sleep a bit and try again.
+
+
+
+
+
+
@@ -3262,11 +3275,15 @@ We will sleep a bit and try again.
+
+
+
+
@@ -3347,6 +3364,7 @@ We will sleep a bit and try again.
+
@@ -3355,7 +3373,10 @@ We will sleep a bit and try again.
-
+
+
+
+
@@ -3385,15 +3406,14 @@ We will sleep a bit and try again.
+
+
-
-
-
@@ -3408,6 +3428,8 @@ We will sleep a bit and try again.
+
+
@@ -3453,6 +3475,7 @@ We will sleep a bit and try again.
+
@@ -3460,12 +3483,18 @@ We will sleep a bit and try again.
+
+
+
+
+
+
@@ -3484,6 +3513,7 @@ We will sleep a bit and try again.
+
@@ -3516,6 +3546,7 @@ We will sleep a bit and try again.
+
@@ -3547,6 +3578,7 @@ We will sleep a bit and try again.
+
@@ -3587,9 +3619,13 @@ We will sleep a bit and try again.
+
+
+
+
@@ -3614,6 +3650,8 @@ We will sleep a bit and try again.
+
+
@@ -3632,6 +3670,7 @@ We will sleep a bit and try again.
+
@@ -3719,6 +3758,7 @@ We will sleep a bit and try again.
+
@@ -3741,6 +3781,13 @@ We will sleep a bit and try again.
+
+
+
+
+
+
+
@@ -3772,14 +3819,16 @@ We will sleep a bit and try again.
+
+
-
-
+
+
@@ -3787,6 +3836,7 @@ We will sleep a bit and try again.
+
@@ -3805,6 +3855,7 @@ We will sleep a bit and try again.
+
@@ -3826,6 +3877,7 @@ We will sleep a bit and try again.
+
@@ -3846,8 +3898,10 @@ We will sleep a bit and try again.
-
+
+
+
@@ -3859,6 +3913,7 @@ We will sleep a bit and try again.
+
@@ -3869,6 +3924,7 @@ We will sleep a bit and try again.
+
@@ -3886,7 +3942,6 @@ We will sleep a bit and try again.
-