* Fixed a bug in Alert->check_condition_age() where not setting a host_uuid caused the returned age to always be 0.

* Updated scan_apc_pdu to not report a lost PDU unless it's been gone for ten minutes.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 2 years ago
parent 99a6593fe6
commit 89121a2b3b
  1. 2
      Anvil/Tools/Alert.pm
  2. 16
      scancore-agents/scan-apc-pdu/scan-apc-pdu
  3. 1
      share/words.xml

@ -276,7 +276,7 @@ sub check_condition_age
my $clear = defined $parameter->{clear} ? $parameter->{clear} : 0; my $clear = defined $parameter->{clear} ? $parameter->{clear} : 0;
my $name = defined $parameter->{name} ? $parameter->{name} : ""; my $name = defined $parameter->{name} ? $parameter->{name} : "";
my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : "NULL"; my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
clear => $clear, clear => $clear,
name => $name, name => $name,

@ -260,7 +260,7 @@ FROM
my $scan_apc_pdu_link_speed = $row->[10]; my $scan_apc_pdu_link_speed = $row->[10];
my $scan_apc_pdu_phase_count = $row->[11]; my $scan_apc_pdu_phase_count = $row->[11];
my $scan_apc_pdu_outlet_count = $row->[12]; my $scan_apc_pdu_outlet_count = $row->[12];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
scan_apc_pdu_uuid => $scan_apc_pdu_uuid, scan_apc_pdu_uuid => $scan_apc_pdu_uuid,
scan_apc_pdu_fence_uuid => $scan_apc_pdu_fence_uuid, scan_apc_pdu_fence_uuid => $scan_apc_pdu_fence_uuid,
scan_apc_pdu_serial_number => $scan_apc_pdu_serial_number, scan_apc_pdu_serial_number => $scan_apc_pdu_serial_number,
@ -1385,6 +1385,7 @@ WHERE
} }
# Delete this from the SQL hash so we know it didn't vanish. # Delete this from the SQL hash so we know it didn't vanish.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0726", variables => { hash_key => "sql::scan_apc_pdu_uuid::${scan_apc_pdu_uuid}" }});
delete $anvil->data->{sql}{scan_apc_pdu_uuid}{$scan_apc_pdu_uuid}; delete $anvil->data->{sql}{scan_apc_pdu_uuid}{$scan_apc_pdu_uuid};
} }
else else
@ -1596,7 +1597,16 @@ INSERT INTO
scan_apc_pdu_ipv4_address => $scan_apc_pdu_ipv4_address, scan_apc_pdu_ipv4_address => $scan_apc_pdu_ipv4_address,
}}); }});
if ($scan_apc_pdu_model_number ne "DELETED") if ($scan_apc_pdu_model_number ne "DELETED")
{
# The PDUs only allow one connection at a time, so if another scan agent is
# connected, we'll get this issue. As such, check how long it's been missing, and
# alert only if it's been missing for 10 minutes.
my $age = $anvil->Alert->check_condition_age({name => "scan_apc_pdu::lost_pdu::".$scan_apc_pdu_serial_number});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { age => $age }});
if ($age > 600)
{ {
# Yup! send an alert. # Yup! send an alert.
my $query = " my $query = "
@ -1626,6 +1636,7 @@ WHERE
}); });
} }
} }
}
# Commit the queries. # Commit the queries.
$anvil->Database->write({query => $anvil->data->{sys}{queries}, debug => 2, source => $THIS_FILE, line => __LINE__}); $anvil->Database->write({query => $anvil->data->{sys}{queries}, debug => 2, source => $THIS_FILE, line => __LINE__});
@ -2004,6 +2015,9 @@ sub gather_pdu_data
# If I got the serial number, I found the PDU. # If I got the serial number, I found the PDU.
next if not $scan_apc_pdu_serial_number; next if not $scan_apc_pdu_serial_number;
# In case this PDU disappeared before, this will clear that condition.
$anvil->Alert->check_condition_age({clear => 1, name => "scan_apc_pdu::lost_pdu::".$scan_apc_pdu_serial_number});
############################################################################################# #############################################################################################
# Base PDU info # # Base PDU info #
############################################################################################# #############################################################################################

@ -2199,6 +2199,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0723">The server: [#!variable!server!#] is configured to stay off, ignoring it.</key> <key name="log_0723">The server: [#!variable!server!#] is configured to stay off, ignoring it.</key>
<key name="log_0724">The file: [#!variable!file!#] needs to be added to the database, but since the last scan it's size grew from: [#!variable!old_size_bytes!# (#!variable!old_size_hr!#)] to: [#!variable!new_size_bytes!# (#!variable!new_size_hr!#)]. A difference of: [#!variable!difference_bytes!# (#!variable!difference_hr!#)]. It might still be being uploaded, so we'll keep checking periodocally until the size stops changing.</key> <key name="log_0724">The file: [#!variable!file!#] needs to be added to the database, but since the last scan it's size grew from: [#!variable!old_size_bytes!# (#!variable!old_size_hr!#)] to: [#!variable!new_size_bytes!# (#!variable!new_size_hr!#)]. A difference of: [#!variable!difference_bytes!# (#!variable!difference_hr!#)]. It might still be being uploaded, so we'll keep checking periodocally until the size stops changing.</key>
<key name="log_0725">Found the missing file: [#!variable!file!#] in the directory: [#!variable!directory!#]. Updating the database now.</key> <key name="log_0725">Found the missing file: [#!variable!file!#] in the directory: [#!variable!directory!#]. Updating the database now.</key>
<key name="log_0726">Deleting the hash key: [#!variable!hash_key!#].</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. --> <!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key> <key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>

Loading…
Cancel
Save