* Finished porting scan-storcli! This was the largest scan agent to migrate to M3.

* Updated Alert->register() to take message variables using the 'variables' parameter.
* Added a 'cache' parameter to Database->insert_or_update_health() and ->insert_or_update_temperature(). When set, the SQL UPDATE/INSERT calls and pushed into the array reference set in 'cache'. This is to allow performance improvements when processing a large amount of sensor/device data.
* Updated Log->variables() to take a 'prefix' parameter that, when set, will prefix the string to each variable line.
* Updated scan-ipmitool to use Database->insert_or_update_health() and ->insert_or_update_temperature().

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 51de6c721f
commit 1c00060d6e
  1. 2
      Anvil/Tools.pm
  2. 48
      Anvil/Tools/Alert.pm
  3. 116
      Anvil/Tools/Database.pm
  4. 19
      Anvil/Tools/Log.pm
  5. 7
      rpm/SPECS/anvil.spec
  6. 316
      scancore-agents/scan-apc-pdu/scan-apc-pdu
  7. 142
      scancore-agents/scan-apc-ups/scan-apc-ups
  8. 22
      scancore-agents/scan-cluster/scan-cluster
  9. 116
      scancore-agents/scan-hardware/scan-hardware
  10. 329
      scancore-agents/scan-ipmitool/scan-ipmitool
  11. 2
      scancore-agents/scan-ipmitool/scan-ipmitool.xml
  12. 62
      scancore-agents/scan-lvm/scan-lvm
  13. 26
      scancore-agents/scan-server/scan-server
  14. 10076
      scancore-agents/scan-storcli/scan-storcli
  15. 640
      scancore-agents/scan-storcli/scan-storcli.sql
  16. 1011
      scancore-agents/scan-storcli/scan-storcli.xml
  17. 58
      tools/test.pl

@ -1181,6 +1181,7 @@ sub _set_paths
openssl => "/usr/bin/openssl", openssl => "/usr/bin/openssl",
passwd => "/usr/bin/passwd", passwd => "/usr/bin/passwd",
pcs => "/usr/sbin/pcs", pcs => "/usr/sbin/pcs",
perccli64 => "/opt/MegaRAID/perccli/perccli64",
ping => "/usr/bin/ping", ping => "/usr/bin/ping",
pgrep => "/usr/bin/pgrep", pgrep => "/usr/bin/pgrep",
ps => "/usr/bin/ps", ps => "/usr/bin/ps",
@ -1201,6 +1202,7 @@ sub _set_paths
'ssh-keyscan' => "/usr/bin/ssh-keyscan", 'ssh-keyscan' => "/usr/bin/ssh-keyscan",
'stat' => "/usr/bin/stat", 'stat' => "/usr/bin/stat",
stonith_admin => "/usr/sbin/stonith_admin", stonith_admin => "/usr/sbin/stonith_admin",
storcli64 => "/opt/MegaRAID/storcli/storcli64",
strings => "/usr/bin/strings", strings => "/usr/bin/strings",
'striker-get-peer-data' => "/usr/sbin/striker-get-peer-data", 'striker-get-peer-data' => "/usr/sbin/striker-get-peer-data",
'striker-initialize-host' => "/usr/sbin/striker-initialize-host", 'striker-initialize-host' => "/usr/sbin/striker-initialize-host",

@ -405,11 +405,7 @@ This is the message body of the alert. It is expected to be in the format C<< <s
Example with a message alone; C<< foo_0001 >>. Example with a message alone; C<< foo_0001 >>.
Example with two variables; C<< foo_0002,!!bar!abc!!,!!baz!123!! >>. Example with two variables; C<< foo_0002,!!bar!abc!!,!!baz!123!! >>.
B<< Note >>: See C<< message_variables >> for an alternate method of passing variables B<< Note >>: See C<< variables >> for an alternate method of passing variables
=head3 message_variables (optional)
This can be set as a hash reference containing key / variable pairs to inject into the message key. the C<< variable => value >> pairs will be appended to the C<< message >> key automatically. This is meant to simplify when an alert is also being longed, or when a large number of variables are being injected into the string.
=head3 set_by (required) =head3 set_by (required)
@ -442,6 +438,10 @@ This is the title of the alert. It is expected to be in the format C<< <string_k
Example with a message alone; C<< foo_0001 >>. Example with a message alone; C<< foo_0001 >>.
Example with two variables; C<< foo_0002,!!bar!abc!!,!!baz!123!! >>. Example with two variables; C<< foo_0002,!!bar!abc!!,!!baz!123!! >>.
=head3 variables (optional)
This can be set as a hash reference containing key / variable pairs to inject into the message key. the C<< variable => value >> pairs will be appended to the C<< message >> key automatically. This is meant to simplify when an alert is also being longed, or when a large number of variables are being injected into the string.
=cut =cut
sub register sub register
{ {
@ -451,23 +451,23 @@ sub register
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Alert->register()" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Alert->register()" }});
my $alert_level = defined $parameter->{alert_level} ? $parameter->{alert_level} : 0; my $alert_level = defined $parameter->{alert_level} ? $parameter->{alert_level} : 0;
my $clear_alert = defined $parameter->{clear_alert} ? $parameter->{clear_alert} : 0; my $clear_alert = defined $parameter->{clear_alert} ? $parameter->{clear_alert} : 0;
my $message = defined $parameter->{message} ? $parameter->{message} : ""; my $message = defined $parameter->{message} ? $parameter->{message} : "";
my $message_variables = defined $parameter->{message_variables} ? $parameter->{message_variables} : "", my $set_by = defined $parameter->{set_by} ? $parameter->{set_by} : "";
my $set_by = defined $parameter->{set_by} ? $parameter->{set_by} : ""; my $show_header = defined $parameter->{show_header} ? $parameter->{show_header} : 1;
my $show_header = defined $parameter->{show_header} ? $parameter->{show_header} : 1; my $sort_position = defined $parameter->{sort_position} ? $parameter->{sort_position} : 9999;
my $sort_position = defined $parameter->{sort_position} ? $parameter->{sort_position} : 9999; my $title = defined $parameter->{title} ? $parameter->{title} : "";
my $title = defined $parameter->{title} ? $parameter->{title} : ""; my $variables = defined $parameter->{variables} ? $parameter->{variables} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
show_header => $show_header, show_header => $show_header,
clear_alert => $clear_alert, clear_alert => $clear_alert,
alert_level => $alert_level, alert_level => $alert_level,
message => $message, message => $message,
message_variables => ref($message_variables), set_by => $set_by,
set_by => $set_by, sort_position => $sort_position,
sort_position => $sort_position, title => $title,
title => $title, variables => ref($variables),
}}); }});
# Missing parameters? # Missing parameters?
@ -487,11 +487,11 @@ sub register
return("!!error!!"); return("!!error!!");
} }
if (ref($message_variables) eq "HASH") if (ref($variables) eq "HASH")
{ {
foreach my $variable (sort {$a cmp $b} keys %{$message_variables}) foreach my $variable (sort {$a cmp $b} keys %{$variables})
{ {
my $value = defined $message_variables->{$variable} ? $message_variables->{$variable} : "undefined:".$variable; my $value = defined $variables->{$variable} ? $variables->{$variable} : "undefined:".$variable;
$message .= ",!!".$variable."!".$value."!!"; $message .= ",!!".$variable."!".$value."!!";
} }
} }

@ -1601,12 +1601,12 @@ sub connect
# if ($cleared) # if ($cleared)
# { # {
# $anvil->Alert->register({ # $anvil->Alert->register({
# debug => $debug, # debug => $debug,
# level => "warning", # level => "warning",
# agent_name => "Anvil!", # agent_name => "Anvil!",
# title_key => "an_title_0006", # title_key => "an_title_0006",
# message_key => "cleared_log_0055", # message => "cleared_log_0055",
# message_variables => { # variables => {
# name => $database_name, # name => $database_name,
# host => $anvil->data->{database}{$uuid}{host}, # host => $anvil->data->{database}{$uuid}{host},
# port => defined $anvil->data->{database}{$uuid}{port} ? $anvil->data->{database}{$uuid}{port} : 5432, # port => defined $anvil->data->{database}{$uuid}{port} ? $anvil->data->{database}{$uuid}{port} : 5432,
@ -5785,6 +5785,16 @@ If there is a problem, an empty string is returned. Otherwise, the C<< health_uu
parameters; parameters;
=head3 cache (optional)
If this is passed an array reference, SQL queries will be pushed into the array instead of actually committed to databases. It will be up to the caller to commit the queries.
=head3 delete (optional, default '0')
If set, the associated C<< health_uuid >> will be deleted.
B<< Note >>: If set, C<< health_uuid >> becomes required and no other parameter is required.
=head3 health_uuid (optional) =head3 health_uuid (optional)
Is passed, the specific entry will be updated. Is passed, the specific entry will be updated.
@ -5819,6 +5829,8 @@ sub insert_or_update_health
my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : ""; my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : "";
my $file = defined $parameter->{file} ? $parameter->{file} : ""; my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $line = defined $parameter->{line} ? $parameter->{line} : ""; my $line = defined $parameter->{line} ? $parameter->{line} : "";
my $cache = defined $parameter->{cache} ? $parameter->{cache} : "";
my $delete = defined $parameter->{'delete'} ? $parameter->{'delete'} : "";
my $health_uuid = defined $parameter->{health_uuid} ? $parameter->{health_uuid} : ""; my $health_uuid = defined $parameter->{health_uuid} ? $parameter->{health_uuid} : "";
my $health_host_uuid = defined $parameter->{health_host_uuid} ? $parameter->{health_host_uuid} : $anvil->Get->host_uuid; my $health_host_uuid = defined $parameter->{health_host_uuid} ? $parameter->{health_host_uuid} : $anvil->Get->host_uuid;
my $health_agent_name = defined $parameter->{health_agent_name} ? $parameter->{health_agent_name} : ""; my $health_agent_name = defined $parameter->{health_agent_name} ? $parameter->{health_agent_name} : "";
@ -5828,6 +5840,7 @@ sub insert_or_update_health
uuid => $uuid, uuid => $uuid,
file => $file, file => $file,
line => $line, line => $line,
'delete' => $delete,
health_uuid => $health_uuid, health_uuid => $health_uuid,
health_host_uuid => $health_host_uuid, health_host_uuid => $health_host_uuid,
health_agent_name => $health_agent_name, health_agent_name => $health_agent_name,
@ -5835,17 +5848,49 @@ sub insert_or_update_health
health_source_weight => $health_source_weight, health_source_weight => $health_source_weight,
}}); }});
if (not $health_agent_name) if ($delete)
{ {
# Throw an error and exit. if (not $health_uuid)
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_health()", parameter => "health_agent_name" }}); {
return(""); # Throw an error and exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_health()", parameter => "health_uuid" }});
return("");
}
my $query = "
UPDATE
health
SET
health_source_name = 'DELETED',
modified_date = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
WHERE
health_uuid = ".$anvil->Database->quote($health_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
$query = "
DELETE FROM
health
WHERE
health_uuid = ".$anvil->Database->quote($health_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
} }
if (not $health_source_name) else
{ {
# Throw an error and exit. if (not $health_agent_name)
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_health()", parameter => "health_source_name" }}); {
return(""); # Throw an error and exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_health()", parameter => "health_agent_name" }});
return("");
}
if (not $health_source_name)
{
# Throw an error and exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_health()", parameter => "health_source_name" }});
return("");
}
} }
# If we don't have a health UUID, see if we can find one. # If we don't have a health UUID, see if we can find one.
@ -5936,7 +5981,14 @@ WHERE
health_uuid = ".$anvil->Database->quote($health_uuid)." health_uuid = ".$anvil->Database->quote($health_uuid)."
;"; ;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__}); if (ref($cache) eq "ARRAY")
{
push @{$cache}, $query;
}
else
{
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
} }
} }
else else
@ -5963,7 +6015,14 @@ INSERT INTO
); );
"; ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__}); if (ref($cache) eq "ARRAY")
{
push @{$cache}, $query;
}
else
{
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
} }
return($health_uuid); return($health_uuid);
@ -10430,6 +10489,10 @@ If there is a problem, an empty string is returned. Otherwise, the C<< temperatu
parameters; parameters;
=head3 cache (optional)
If this is passed an array reference, SQL queries will be pushed into the array instead of actually committed to databases. It will be up to the caller to commit the queries.
=head3 temperature_uuid (optional) =head3 temperature_uuid (optional)
Is passed, the specific entry will be updated. Is passed, the specific entry will be updated.
@ -10484,6 +10547,7 @@ sub insert_or_update_temperature
my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : ""; my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : "";
my $file = defined $parameter->{file} ? $parameter->{file} : ""; my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $line = defined $parameter->{line} ? $parameter->{line} : ""; my $line = defined $parameter->{line} ? $parameter->{line} : "";
my $cache = defined $parameter->{cache} ? $parameter->{cache} : "";
my $temperature_uuid = defined $parameter->{temperature_uuid} ? $parameter->{temperature_uuid} : ""; my $temperature_uuid = defined $parameter->{temperature_uuid} ? $parameter->{temperature_uuid} : "";
my $temperature_host_uuid = defined $parameter->{temperature_host_uuid} ? $parameter->{temperature_host_uuid} : $anvil->Get->host_uuid; my $temperature_host_uuid = defined $parameter->{temperature_host_uuid} ? $parameter->{temperature_host_uuid} : $anvil->Get->host_uuid;
my $temperature_agent_name = defined $parameter->{temperature_agent_name} ? $parameter->{temperature_agent_name} : ""; my $temperature_agent_name = defined $parameter->{temperature_agent_name} ? $parameter->{temperature_agent_name} : "";
@ -10671,14 +10735,21 @@ WHERE
temperature_uuid = ".$anvil->Database->quote($temperature_uuid)." temperature_uuid = ".$anvil->Database->quote($temperature_uuid)."
;"; ;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__}); if (ref($cache) eq "ARRAY")
{
push @{$cache}, $query;
}
else
{
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
} }
} }
else else
{ {
# INSERT # INSERT
$temperature_uuid = $anvil->Get->uuid(); $temperature_uuid = $anvil->Get->uuid();
my $query = " my $query = "
INSERT INTO INSERT INTO
temperature temperature
( (
@ -10706,7 +10777,14 @@ INSERT INTO
); );
"; ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__}); if (ref($cache) eq "ARRAY")
{
push @{$cache}, $query;
}
else
{
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
} }
return($temperature_uuid); return($temperature_uuid);

@ -763,6 +763,14 @@ Would generate a sorted log entry that looks like:
All other key names are left alone and output is sorted alphabetically. All other key names are left alone and output is sorted alphabetically.
=head3 prefix (optional)
If set, this string will be prefixed to all variable names. The string passed will be separated from variable names by a space-padded hyphen.
For example, if C<< prefix >> is set to C<< foo >>, and the variables in the list are C<< bar >> and C<< baz >>, the logged variables will be C<< foo - bar >> and C<< foo - baz >>.
B<< Note >>: If the list is short enough to be displayed on one line (three or less keys), the prefix is prepended to the list, not each variable name.
=cut =cut
sub variables sub variables
{ {
@ -777,6 +785,7 @@ sub variables
my $line = defined $parameter->{line} ? $parameter->{line} : ""; my $line = defined $parameter->{line} ? $parameter->{line} : "";
my $list = defined $parameter->{list} ? $parameter->{list} : {}; my $list = defined $parameter->{list} ? $parameter->{list} : {};
my $facility = defined $parameter->{facility} ? $parameter->{facility} : $anvil->data->{defaults}{'log'}{facility}; my $facility = defined $parameter->{facility} ? $parameter->{facility} : $anvil->data->{defaults}{'log'}{facility};
my $prefix = defined $parameter->{prefix} ? $parameter->{prefix} : "";
my $priority = defined $parameter->{priority} ? $parameter->{priority} : ""; my $priority = defined $parameter->{priority} ? $parameter->{priority} : "";
my $secure = defined $parameter->{secure} ? $parameter->{secure} : 0; my $secure = defined $parameter->{secure} ? $parameter->{secure} : 0;
my $server = defined $parameter->{server} ? $parameter->{server} : $anvil->data->{defaults}{'log'}{server}; my $server = defined $parameter->{server} ? $parameter->{server} : $anvil->data->{defaults}{'log'}{server};
@ -827,6 +836,10 @@ sub variables
if ($entries <= 3) if ($entries <= 3)
{ {
# Put all the entries on one line. # Put all the entries on one line.
if ($prefix)
{
$raw = $prefix." - ";
}
foreach my $key (sort {$a cmp $b} keys %{$list}) foreach my $key (sort {$a cmp $b} keys %{$list})
{ {
print $THIS_FILE." ".__LINE__."; key: [".$key."]\n" if $test; print $THIS_FILE." ".__LINE__."; key: [".$key."]\n" if $test;
@ -866,7 +879,11 @@ sub variables
# Strip a leading 'sX:' in case the user is sorting the output. # Strip a leading 'sX:' in case the user is sorting the output.
my $say_key = $key; my $say_key = $key;
$say_key =~ s/^s(\d+)://; $say_key =~ s/^s(\d+)://;
$say_key .= ":"; if ($prefix)
{
$say_key = $prefix." - ".$say_key;
}
$say_key .= ":";
my $difference = $length - length($say_key); my $difference = $length - length($say_key);
print $THIS_FILE." ".__LINE__."; say_key: [".$say_key."], difference: [".$difference."]\n" if $test; print $THIS_FILE." ".__LINE__."; say_key: [".$say_key."], difference: [".$difference."]\n" if $test;
if ($difference) if ($difference)

@ -3,7 +3,7 @@
%define anvilgroup admin %define anvilgroup admin
Name: anvil Name: anvil
Version: 3.0 Version: 3.0
Release: 36%{?dist} Release: 37%{?dist}
Summary: Alteeve Anvil! complete package. Summary: Alteeve Anvil! complete package.
License: GPLv2+ License: GPLv2+
@ -381,7 +381,10 @@ fi
%changelog %changelog
* tbd Madison Kelly <mkelly@alteeve.ca> 3.0-36 * tbd Madison Kelly <mkelly@alteeve.ca> 3.0-37
- Updated source.
* Tue Nov 17 2020 Madison Kelly <mkelly@alteeve.ca> 3.0-36
- Updated source. - Updated source.
* Thu Sep 03 2020 Madison Kelly <mkelly@alteeve.ca> 3.0-35 * Thu Sep 03 2020 Madison Kelly <mkelly@alteeve.ca> 3.0-35

@ -589,11 +589,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0006", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0006", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0006", message => "scan_apc_pdu_message_0006",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
else else
@ -605,11 +605,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0007", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0007", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0007", message => "scan_apc_pdu_message_0007",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
} }
@ -620,17 +620,17 @@ sub find_changes
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { changes => $changes }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { changes => $changes }});
my $variables = { my $variables = {
name => $pdu_host_name, name => $pdu_host_name,
old_serial_number => $old_scan_apc_pdu_serial_number, old_serial_number => $old_scan_apc_pdu_serial_number,
new_serial_number => $new_scan_apc_pdu_serial_number, new_serial_number => $new_scan_apc_pdu_serial_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0008", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0008", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0008", message => "scan_apc_pdu_message_0008",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_manufacture_date ne $old_scan_apc_pdu_manufacture_date) if ($new_scan_apc_pdu_manufacture_date ne $old_scan_apc_pdu_manufacture_date)
@ -646,11 +646,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0009", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0009", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0009", message => "scan_apc_pdu_message_0009",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_firmware_version ne $old_scan_apc_pdu_firmware_version) if ($new_scan_apc_pdu_firmware_version ne $old_scan_apc_pdu_firmware_version)
@ -666,11 +666,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0010", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0010", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0010", message => "scan_apc_pdu_message_0010",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_hardware_version ne $old_scan_apc_pdu_hardware_version) if ($new_scan_apc_pdu_hardware_version ne $old_scan_apc_pdu_hardware_version)
@ -686,11 +686,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0011", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0011", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0011", message => "scan_apc_pdu_message_0011",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_ipv4_address ne $old_scan_apc_pdu_ipv4_address) if ($new_scan_apc_pdu_ipv4_address ne $old_scan_apc_pdu_ipv4_address)
@ -706,11 +706,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0012", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0012", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0012", message => "scan_apc_pdu_message_0012",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_mac_address ne $old_scan_apc_pdu_mac_address) if ($new_scan_apc_pdu_mac_address ne $old_scan_apc_pdu_mac_address)
@ -726,11 +726,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0013", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0013", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0013", message => "scan_apc_pdu_message_0013",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_mtu_size ne $old_scan_apc_pdu_mtu_size) if ($new_scan_apc_pdu_mtu_size ne $old_scan_apc_pdu_mtu_size)
@ -740,17 +740,17 @@ sub find_changes
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { changes => $changes }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { changes => $changes }});
my $variables = { my $variables = {
name => $pdu_host_name, name => $pdu_host_name,
old_mtu_size => $old_scan_apc_pdu_mtu_size, old_mtu_size => $old_scan_apc_pdu_mtu_size,
new_mtu_size => $new_scan_apc_pdu_mtu_size, new_mtu_size => $new_scan_apc_pdu_mtu_size,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0014", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0014", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0014", message => "scan_apc_pdu_message_0014",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_link_speed ne $old_scan_apc_pdu_link_speed) if ($new_scan_apc_pdu_link_speed ne $old_scan_apc_pdu_link_speed)
@ -777,11 +777,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0015", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0015", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0015", message => "scan_apc_pdu_message_0015",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_phase_count ne $old_scan_apc_pdu_phase_count) if ($new_scan_apc_pdu_phase_count ne $old_scan_apc_pdu_phase_count)
@ -797,11 +797,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0016", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0016", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0016", message => "scan_apc_pdu_message_0016",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_outlet_count ne $old_scan_apc_pdu_outlet_count) if ($new_scan_apc_pdu_outlet_count ne $old_scan_apc_pdu_outlet_count)
@ -817,11 +817,11 @@ sub find_changes
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0017", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0017", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0017", message => "scan_apc_pdu_message_0017",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
@ -885,11 +885,11 @@ WHERE
# Normal, info-level # Normal, info-level
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0018", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0018", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "info", alert_level => "info",
message => "scan_apc_pdu_message_0018", message => "scan_apc_pdu_message_0018",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
elsif (($new_uptime < $old_uptime) && ($new_uptime < 300)) elsif (($new_uptime < $old_uptime) && ($new_uptime < 300))
@ -898,11 +898,11 @@ WHERE
# the NIC rebooting and doesn't interfere with power. # the NIC rebooting and doesn't interfere with power.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0019", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0019", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0019", message => "scan_apc_pdu_message_0019",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
} }
@ -935,11 +935,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0009", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0009", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0009", message => "scan_apc_pdu_message_0009",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
update_variables($anvil, $scan_apc_pdu_variable_uuid, "total_wattage_draw", $new_total_wattage_draw); update_variables($anvil, $scan_apc_pdu_variable_uuid, "total_wattage_draw", $new_total_wattage_draw);
@ -991,11 +991,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0021", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0021", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0021", message => "scan_apc_pdu_message_0021",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
@ -1014,11 +1014,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0022", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0022", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0022", message => "scan_apc_pdu_message_0022",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($old_scan_apc_pdu_phase_current_amperage ne $new_scan_apc_pdu_phase_current_amperage) if ($old_scan_apc_pdu_phase_current_amperage ne $new_scan_apc_pdu_phase_current_amperage)
@ -1037,11 +1037,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0023", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0023", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "info", alert_level => "info",
message => "scan_apc_pdu_message_0023", message => "scan_apc_pdu_message_0023",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
# Cheack for low alerts to set or high alerts to clear # Cheack for low alerts to set or high alerts to clear
@ -1065,11 +1065,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0024", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0024", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0024", message => "scan_apc_pdu_message_0024",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
@ -1163,11 +1163,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0030", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0030", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0030", message => "scan_apc_pdu_message_0030",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
} }
@ -1213,11 +1213,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0031", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0031", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0031", message => "scan_apc_pdu_message_0031",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_outlet_name ne $old_scan_apc_pdu_outlet_name) if ($new_scan_apc_pdu_outlet_name ne $old_scan_apc_pdu_outlet_name)
@ -1234,11 +1234,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0032", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0032", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "notice", alert_level => "notice",
message => "scan_apc_pdu_message_0032", message => "scan_apc_pdu_message_0032",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_outlet_on_phase ne $old_scan_apc_pdu_outlet_on_phase) if ($new_scan_apc_pdu_outlet_on_phase ne $old_scan_apc_pdu_outlet_on_phase)
@ -1255,11 +1255,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0033", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0033", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0033", message => "scan_apc_pdu_message_0033",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
if ($new_scan_apc_pdu_outlet_state ne $old_scan_apc_pdu_outlet_state) if ($new_scan_apc_pdu_outlet_state ne $old_scan_apc_pdu_outlet_state)
@ -1276,11 +1276,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0034", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0034", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0034", message => "scan_apc_pdu_message_0034",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
@ -1331,11 +1331,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0035", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0035", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0035", message => "scan_apc_pdu_message_0035",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
@ -1377,11 +1377,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0036", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0036", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0036", message => "scan_apc_pdu_message_0036",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
} }
@ -1485,11 +1485,11 @@ INSERT INTO
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0037", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0037", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0037", message => "scan_apc_pdu_message_0037",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
# Insert the phase data # Insert the phase data
@ -1529,11 +1529,11 @@ INSERT INTO
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0038", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0038", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0038", message => "scan_apc_pdu_message_0038",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
@ -1573,11 +1573,11 @@ INSERT INTO
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0039", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0039", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0039", message => "scan_apc_pdu_message_0039",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
} }
@ -1620,11 +1620,11 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0040", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0040", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0040", message => "scan_apc_pdu_message_0040",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
} }
} }
@ -2385,7 +2385,7 @@ sub gather_pdu_data
if ($changed) if ($changed)
{ {
# Register an alert. # Register an alert.
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_pdu_message_0002", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_pdu_message_0002", variables => $variables, set_by => $THIS_FILE});
} }
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -2403,7 +2403,7 @@ sub gather_pdu_data
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_pdu_message_0003", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_pdu_message_0003", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_pdu_message_0003", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_pdu_message_0003", variables => $variables, set_by => $THIS_FILE});
} }
} }
# Now read the phase data # Now read the phase data
@ -2453,7 +2453,7 @@ sub gather_pdu_data
if ($changed) if ($changed)
{ {
# Register an alert. # Register an alert.
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_pdu_message_0004", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_pdu_message_0004", variables => $variables, set_by => $THIS_FILE});
} }
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -2471,7 +2471,7 @@ sub gather_pdu_data
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_pdu_message_0005", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_pdu_message_0005", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_pdu_message_0005", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_pdu_message_0005", variables => $variables, set_by => $THIS_FILE});
} }
} }
# Now read the outlet data # Now read the outlet data

@ -386,7 +386,7 @@ INSERT INTO
last_transfer_reason => "#!string!scan_apc_ups_last_xfer_".sprintf("%04d", $scan_apc_ups_last_transfer_reason)."!#", last_transfer_reason => "#!string!scan_apc_ups_last_xfer_".sprintf("%04d", $scan_apc_ups_last_transfer_reason)."!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0002", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_pdu_message_0002", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_pdu_message_0002", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_pdu_message_0002", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
# Add any batteries. # Add any batteries.
foreach my $battery_number (sort {$a cmp $b} keys %{$anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}}) foreach my $battery_number (sort {$a cmp $b} keys %{$anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}})
@ -450,7 +450,7 @@ INSERT INTO
new_name => $old_scan_apc_ups_name, new_name => $old_scan_apc_ups_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0005", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0005", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0005", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0005", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_serial_number ne $old_scan_apc_ups_serial_number) if ($scan_apc_ups_serial_number ne $old_scan_apc_ups_serial_number)
{ {
@ -464,7 +464,7 @@ INSERT INTO
new_value => $scan_apc_ups_serial_number, new_value => $scan_apc_ups_serial_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0006", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0006", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0006", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0006", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_ip ne $old_scan_apc_ups_ip) if ($scan_apc_ups_ip ne $old_scan_apc_ups_ip)
{ {
@ -477,7 +477,7 @@ INSERT INTO
new_value => $scan_apc_ups_ip, new_value => $scan_apc_ups_ip,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0007", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0007", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0007", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0007", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_model ne $old_scan_apc_ups_model) if ($scan_apc_ups_model ne $old_scan_apc_ups_model)
{ {
@ -491,7 +491,7 @@ INSERT INTO
new_value => $scan_apc_ups_model, new_value => $scan_apc_ups_model,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0008", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0008", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0008", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0008", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_ac_restore_delay ne $old_scan_apc_ups_ac_restore_delay) if ($scan_apc_ups_ac_restore_delay ne $old_scan_apc_ups_ac_restore_delay)
{ {
@ -504,7 +504,7 @@ INSERT INTO
new_value => $scan_apc_ups_ac_restore_delay, new_value => $scan_apc_ups_ac_restore_delay,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0009", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0009", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0009", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0009", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_shutdown_delay ne $old_scan_apc_ups_shutdown_delay) if ($scan_apc_ups_shutdown_delay ne $old_scan_apc_ups_shutdown_delay)
{ {
@ -517,7 +517,7 @@ INSERT INTO
new_value => $scan_apc_ups_shutdown_delay, new_value => $scan_apc_ups_shutdown_delay,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0010", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0010", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0010", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0010", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_firmware_version ne $old_scan_apc_ups_firmware_version) if ($scan_apc_ups_firmware_version ne $old_scan_apc_ups_firmware_version)
{ {
@ -530,7 +530,7 @@ INSERT INTO
new_value => $scan_apc_ups_firmware_version, new_value => $scan_apc_ups_firmware_version,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0011", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0011", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0011", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0011", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
# Has the health changed? This is fairly complex as there are many possible health # Has the health changed? This is fairly complex as there are many possible health
@ -669,7 +669,7 @@ INSERT INTO
old_value => "#!string!scan_apc_ups_health_".sprintf("%04d", $say_old_scan_apc_ups_health)."!#", old_value => "#!string!scan_apc_ups_health_".sprintf("%04d", $say_old_scan_apc_ups_health)."!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0012", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0012", variables => $variables});
$anvil->Alert->register({alert_level => $level, message => "scan_apc_ups_warning_0012", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => $level, message => "scan_apc_ups_warning_0012", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_low_transfer_voltage ne $old_scan_apc_ups_low_transfer_voltage) if ($scan_apc_ups_low_transfer_voltage ne $old_scan_apc_ups_low_transfer_voltage)
@ -691,7 +691,7 @@ INSERT INTO
old_value => $old_scan_apc_ups_low_transfer_voltage, old_value => $old_scan_apc_ups_low_transfer_voltage,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => $message_key, message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => $message_key, variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
# Has the last transfer reason changed? There are 10 reasons why this might happen, # Has the last transfer reason changed? There are 10 reasons why this might happen,
@ -735,7 +735,7 @@ INSERT INTO
old_value => "#!string!scan_apc_ups_last_transfer_".sprintf("%04d", $say_old_scan_apc_ups_last_transfer_reason)."!#", old_value => "#!string!scan_apc_ups_last_transfer_".sprintf("%04d", $say_old_scan_apc_ups_last_transfer_reason)."!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0015", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0015", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0015", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0015", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($scan_apc_ups_manufactured_date ne $old_scan_apc_ups_manufactured_date) if ($scan_apc_ups_manufactured_date ne $old_scan_apc_ups_manufactured_date)
{ {
@ -749,7 +749,7 @@ INSERT INTO
new_value => $scan_apc_ups_manufactured_date, new_value => $scan_apc_ups_manufactured_date,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0016", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0016", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0016", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0016", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
# Has the NMC's firmware changed? # Has the NMC's firmware changed?
@ -765,7 +765,7 @@ INSERT INTO
new_value => $scan_apc_ups_nmc_firmware_version, new_value => $scan_apc_ups_nmc_firmware_version,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0017", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0017", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0017", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0017", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
# Has the NMC serial number changed? If the user changed the network card, # Has the NMC serial number changed? If the user changed the network card,
@ -782,7 +782,7 @@ INSERT INTO
new_value => $scan_apc_ups_nmc_serial_number, new_value => $scan_apc_ups_nmc_serial_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0018", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0018", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0018", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0018", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
# As with above, if the MAC address changed, it is probably because the NMC # As with above, if the MAC address changed, it is probably because the NMC
@ -799,7 +799,7 @@ INSERT INTO
new_value => $scan_apc_ups_nmc_mac_address, new_value => $scan_apc_ups_nmc_mac_address,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0019", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_apc_ups_warning_0019", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0019", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0019", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
if ($ups_changed) if ($ups_changed)
@ -888,7 +888,7 @@ WHERE
old_value => "#!string!scan_apc_ups_sensitivity_".sprintf("%04d", $say_old_scan_apc_ups_input_sensitivity)."!#", old_value => "#!string!scan_apc_ups_sensitivity_".sprintf("%04d", $say_old_scan_apc_ups_input_sensitivity)."!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0020", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0020", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0020", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_warning_0020", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++});
} }
# Has the input voltage changed? # Has the input voltage changed?
@ -942,7 +942,7 @@ WHERE
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0021", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0021", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0021", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0021", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
elsif ($scan_apc_ups_input_voltage > $high_transfer_voltage) elsif ($scan_apc_ups_input_voltage > $high_transfer_voltage)
@ -954,7 +954,7 @@ WHERE
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0022", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0022", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0022", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0022", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
elsif ($scan_apc_ups_input_voltage > $clear_low_transfer) elsif ($scan_apc_ups_input_voltage > $clear_low_transfer)
@ -966,7 +966,7 @@ WHERE
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0023", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0023", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0023", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0023", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
} }
@ -986,7 +986,7 @@ WHERE
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0026", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0026", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0026", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0026", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
elsif ($scan_apc_ups_input_voltage < $low_transfer_voltage) elsif ($scan_apc_ups_input_voltage < $low_transfer_voltage)
@ -998,7 +998,7 @@ WHERE
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0027", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0027", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0027", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0027", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
elsif ($scan_apc_ups_input_voltage < $clear_high_transfer) elsif ($scan_apc_ups_input_voltage < $clear_high_transfer)
@ -1010,12 +1010,12 @@ WHERE
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0028", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0028", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0028", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0028", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
} }
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => "info", message => $message_key, message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => $message_key, variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# Has the maximum input voltage seen in the last 60 seconds changed? # Has the maximum input voltage seen in the last 60 seconds changed?
@ -1031,7 +1031,7 @@ WHERE
old_value => $anvil->Convert->round({places => 1, number => $old_scan_apc_ups_input_1m_maximum_input_voltage}), old_value => $anvil->Convert->round({places => 1, number => $old_scan_apc_ups_input_1m_maximum_input_voltage}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0029", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0029", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0029", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0029", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# Has the minimum input voltage seen in the last 60 seconds changed? # Has the minimum input voltage seen in the last 60 seconds changed?
@ -1046,7 +1046,7 @@ WHERE
old_value => $anvil->Convert->round({places => 1, number => $old_scan_apc_ups_input_1m_minimum_input_voltage}), old_value => $anvil->Convert->round({places => 1, number => $old_scan_apc_ups_input_1m_minimum_input_voltage}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0030", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0030", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0030", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0030", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { input_changed => $input_changed }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { input_changed => $input_changed }});
@ -1103,7 +1103,7 @@ WHERE
# Register an alert. # Register an alert.
$log_normal = 0; $log_normal = 0;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0032", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0032", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0032", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0032", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
} }
@ -1124,7 +1124,7 @@ WHERE
# Register an alert. # Register an alert.
$log_normal = 0; $log_normal = 0;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0033", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0033", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0033", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0033", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
} }
@ -1133,7 +1133,7 @@ WHERE
{ {
# This is an info level alert as it changes all the time. # This is an info level alert as it changes all the time.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0031", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0031", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0031", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0031", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
} }
@ -1174,7 +1174,7 @@ WHERE
}}); }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => $level, message => $message_key, message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => $level, message => $message_key, variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# Has the estimated runtime changed? # Has the estimated runtime changed?
@ -1204,7 +1204,7 @@ WHERE
# Register an alert. # Register an alert.
$send_alert = 0; $send_alert = 0;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0038", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0038", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0038", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0038", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
elsif ($scan_apc_ups_output_estimated_runtime > $anvil->data->{'scan-apc-ups'}{low_hold_up_clear_threshold}) elsif ($scan_apc_ups_output_estimated_runtime > $anvil->data->{'scan-apc-ups'}{low_hold_up_clear_threshold})
@ -1217,7 +1217,7 @@ WHERE
# Register an alert. # Register an alert.
$send_alert = 0; $send_alert = 0;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0039", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0039", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0039", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0039", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
@ -1225,7 +1225,7 @@ WHERE
{ {
# A normal minor change. # A normal minor change.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0037", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0037", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0037", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0037", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
} }
@ -1243,7 +1243,7 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0040", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0040", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0040", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0040", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# Has the output voltage changed? # Has the output voltage changed?
@ -1260,7 +1260,7 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0041", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0041", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0041", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0041", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# This is always changing... # This is always changing...
@ -1281,7 +1281,7 @@ WHERE
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0042", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_warning_0042", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0042", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_warning_0042", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output_changed => $output_changed }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output_changed => $output_changed }});
@ -1376,7 +1376,7 @@ WHERE
battery_number => $battery_number, battery_number => $battery_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0008", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0008", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_message_0008", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_message_0008", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# Has the battery health changed? # Has the battery health changed?
@ -1431,7 +1431,7 @@ WHERE
battery_model => $scan_apc_ups_battery_model, battery_model => $scan_apc_ups_battery_model,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => $level, message => $message_key, message_variables => $variables, sort_position => $sort_position, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => $level, message => $message_key, variables => $variables, sort_position => $sort_position, set_by => $THIS_FILE});
} }
# Has the battery model changed? # Has the battery model changed?
@ -1447,7 +1447,7 @@ WHERE
old_value => $old_scan_apc_ups_battery_model, old_value => $old_scan_apc_ups_battery_model,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0012", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0012", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0012", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0012", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# If the battery charge percentage has changed, it will usually be an 'info' # If the battery charge percentage has changed, it will usually be an 'info'
@ -1539,7 +1539,7 @@ LIMIT 1
# Register an alert. # Register an alert.
$alert_sent = 1; $alert_sent = 1;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_message_0014", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_message_0014", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_message_0014", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_message_0014", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
} }
@ -1558,7 +1558,7 @@ LIMIT 1
# Register an alert. # Register an alert.
$alert_sent = 1; $alert_sent = 1;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_message_0016", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_message_0016", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_message_0016", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_message_0016", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
} }
@ -1569,7 +1569,7 @@ LIMIT 1
{ {
my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-apc-pdu'}{alert_sort}++; my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-apc-pdu'}{alert_sort}++;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => $level, message => $message_key, message_variables => $variables, sort_position => $sort_position, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => $level, message => $message_key, variables => $variables, sort_position => $sort_position, set_by => $THIS_FILE});
} }
} }
@ -1586,7 +1586,7 @@ LIMIT 1
battery_number => $battery_number, battery_number => $battery_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0017", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0017", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0017", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0017", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# Has the battery state changed? There are four possible battery states. # Has the battery state changed? There are four possible battery states.
@ -1640,7 +1640,7 @@ LIMIT 1
battery_number => $battery_number, battery_number => $battery_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => $level, clear_alert => $clear_alert, message => $message_key, message_variables => $variables, sort_position => $sort_position, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => $level, clear_alert => $clear_alert, message => $message_key, variables => $variables, sort_position => $sort_position, set_by => $THIS_FILE});
} }
# Has the battery's temperature changed? Alerts will be processed # Has the battery's temperature changed? Alerts will be processed
@ -1678,7 +1678,7 @@ LIMIT 1
time_span => $time_span, time_span => $time_span,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0023", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0023", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0023", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0023", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
@ -1692,7 +1692,7 @@ LIMIT 1
battery_number => $battery_number, battery_number => $battery_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0020", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0020", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_message_0020", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_message_0020", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
} }
@ -1710,7 +1710,7 @@ LIMIT 1
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0021", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0021", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0021", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_apc_ups_message_0021", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
# Has the UPS battery voltage changed? # Has the UPS battery voltage changed?
@ -1727,7 +1727,7 @@ LIMIT 1
battery_number => $battery_number, battery_number => $battery_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0022", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_ups_message_0022", variables => $variables});
$anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_message_0022", message_variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "info", message => "scan_apc_ups_message_0022", variables => $variables, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, set_by => $THIS_FILE});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { battery_changed => $battery_changed }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { battery_changed => $battery_changed }});
@ -2192,7 +2192,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_ac_restore_delay} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_ac_restore_delay} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_ac_restore_delay} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_ac_restore_delay} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_ac_restore_delay", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_ac_restore_delay",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_ac_restore_delay}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_ac_restore_delay},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2217,7 +2217,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_shutdown_delay} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_shutdown_delay} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_shutdown_delay} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_shutdown_delay} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_shutdown_delay", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_shutdown_delay",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_shutdown_delay}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_shutdown_delay},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2496,7 +2496,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_percentage_charge} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_percentage_charge} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_percentage_charge} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_percentage_charge} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_percentage_charge", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_percentage_charge",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_percentage_charge}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_percentage_charge},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2567,7 +2567,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_temperature} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_temperature} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_temperature} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_temperature} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_temperature", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_temperature",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_temperature}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_temperature},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2597,7 +2597,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_alarm_temperature} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_alarm_temperature} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_alarm_temperature} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_alarm_temperature} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_alarm_temperature", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_alarm_temperature",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_alarm_temperature}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_alarm_temperature},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2632,7 +2632,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_voltage} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_voltage} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_voltage", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::battery::${battery_number}::scan_apc_ups_battery_voltage",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_voltage}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{battery}{$battery_number}{scan_apc_ups_battery_voltage},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2666,7 +2666,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_frequency} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_frequency} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_frequency} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_frequency} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_frequency", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_frequency",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_frequency}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_frequency},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2698,7 +2698,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_sensitivity} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_sensitivity} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_sensitivity} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_sensitivity} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_sensitivity", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_sensitivity",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_sensitivity}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_sensitivity},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2727,7 +2727,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_voltage} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_voltage} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_voltage", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_voltage",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_voltage}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_voltage},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2756,7 +2756,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_maximum_input_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_maximum_input_voltage} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_maximum_input_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_maximum_input_voltage} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_1m_maximum_input_voltage", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_1m_maximum_input_voltage",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_maximum_input_voltage}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_maximum_input_voltage},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2784,7 +2784,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_minimum_input_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_minimum_input_voltage} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_minimum_input_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_minimum_input_voltage} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_1m_minimum_input_voltage", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_input_1m_minimum_input_voltage",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_minimum_input_voltage}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_input_1m_minimum_input_voltage},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2818,7 +2818,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_load_percentage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_load_percentage} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_load_percentage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_load_percentage} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_load_percentage", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_load_percentage",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_load_percentage}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_load_percentage},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2848,7 +2848,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_time_on_batteries} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_time_on_batteries} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_time_on_batteries} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_time_on_batteries} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_time_on_batteries", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_time_on_batteries",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_time_on_batteries}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_time_on_batteries},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2876,7 +2876,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_estimated_runtime} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_estimated_runtime} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_estimated_runtime} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_estimated_runtime} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_estimated_runtime", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_estimated_runtime",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_estimated_runtime}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_estimated_runtime},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2905,7 +2905,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_frequency} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_frequency} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_frequency} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_frequency} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_frequency", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_frequency",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_frequency}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_frequency},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2934,7 +2934,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_voltage} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_voltage} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_voltage} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_voltage", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_voltage",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_voltage}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_voltage},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -2964,7 +2964,7 @@ sub gather_ups_data
}}); }});
if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_total_output} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_total_output} =~ /\D/)) if (($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_total_output} eq "--") or ($anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_total_output} =~ /\D/))
{ {
$anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", message_variables => { $anvil->Log->entry({log_level => 1, message_key => "scan_apc_ups_error_0001", variables => {
name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_total_output", name => "ups::scan_apc_ups_uuid::${scan_apc_ups_uuid}::scan_apc_ups_output_total_output",
value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_total_output}, value => $anvil->data->{ups}{scan_apc_ups_uuid}{$scan_apc_ups_uuid}{scan_apc_ups_output_total_output},
}, file => $THIS_FILE, line => __LINE__}); }, file => $THIS_FILE, line => __LINE__});
@ -3114,7 +3114,7 @@ INSERT INTO
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0002", message => "scan_apc_pdu_message_0002",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
@ -3177,7 +3177,7 @@ INSERT INTO
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0004", message => "scan_apc_pdu_message_0004",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
@ -3244,7 +3244,7 @@ INSERT INTO
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "warning", alert_level => "warning",
message => "scan_apc_pdu_message_0005", message => "scan_apc_pdu_message_0005",
message_variables => $variables, variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++,
}); });
@ -3304,7 +3304,7 @@ sub process_temperature
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0001", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0001", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0001", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0001", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
elsif ($battery_temperature > $critical_temperature) elsif ($battery_temperature > $critical_temperature)
@ -3323,7 +3323,7 @@ sub process_temperature
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0003", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0003", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0003", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_apc_ups_warning_0003", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
@ -3338,7 +3338,7 @@ sub process_temperature
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0004", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0004", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0004", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0004", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
elsif ($battery_temperature < $clear_critical_temperature) elsif ($battery_temperature < $clear_critical_temperature)
@ -3352,7 +3352,7 @@ sub process_temperature
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0002", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_apc_ups_warning_0002", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0002", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_apc_ups_warning_0002", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }

@ -151,7 +151,7 @@ WHERE
old_cluster_name => $old_cluster_name, old_cluster_name => $old_cluster_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0002", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0002", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0002", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0002", variables => $variables, set_by => $THIS_FILE});
} }
} }
else else
@ -177,7 +177,7 @@ INSERT INTO
my $variables = { cluster_name => $cluster_name }; my $variables = { cluster_name => $cluster_name };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0001", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0001", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0001", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0001", variables => $variables, set_by => $THIS_FILE});
} }
$anvil->Database->get_anvils(); $anvil->Database->get_anvils();
@ -230,7 +230,7 @@ INSERT INTO
old_node_name => $old_scan_cluster_node_name, old_node_name => $old_scan_cluster_node_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0008", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0008", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0009", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0009", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_cluster_node_pacemaker_id ne $old_scan_cluster_node_pacemaker_id) if ($scan_cluster_node_pacemaker_id ne $old_scan_cluster_node_pacemaker_id)
{ {
@ -243,7 +243,7 @@ INSERT INTO
old_pacemaker_id => $old_scan_cluster_node_pacemaker_id ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#", old_pacemaker_id => $old_scan_cluster_node_pacemaker_id ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0004", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0004", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0004", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0004", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_cluster_node_in_ccm ne $old_scan_cluster_node_in_ccm) if ($scan_cluster_node_in_ccm ne $old_scan_cluster_node_in_ccm)
{ {
@ -256,7 +256,7 @@ INSERT INTO
old_in_ccm => $old_scan_cluster_node_in_ccm ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#", old_in_ccm => $old_scan_cluster_node_in_ccm ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0005", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0005", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0005", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0005", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_cluster_node_crmd_member ne $old_scan_cluster_node_crmd_member) if ($scan_cluster_node_crmd_member ne $old_scan_cluster_node_crmd_member)
{ {
@ -269,7 +269,7 @@ INSERT INTO
old_crmd_member => $old_scan_cluster_node_crmd_member ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#", old_crmd_member => $old_scan_cluster_node_crmd_member ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0006", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0006", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0006", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0006", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_cluster_node_cluster_member ne $old_scan_cluster_node_cluster_member) if ($scan_cluster_node_cluster_member ne $old_scan_cluster_node_cluster_member)
{ {
@ -282,7 +282,7 @@ INSERT INTO
old_cluster_member => $old_scan_cluster_node_cluster_member ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#", old_cluster_member => $old_scan_cluster_node_cluster_member ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0007", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0007", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0007", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0007", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_cluster_node_maintenance_mode ne $old_scan_cluster_node_maintenance_mode) if ($scan_cluster_node_maintenance_mode ne $old_scan_cluster_node_maintenance_mode)
{ {
@ -295,7 +295,7 @@ INSERT INTO
old_maintenance_mode => $old_scan_cluster_node_maintenance_mode ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#", old_maintenance_mode => $old_scan_cluster_node_maintenance_mode ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0008", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0008", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0008", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0008", variables => $variables, set_by => $THIS_FILE});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update => $update }});
@ -365,7 +365,7 @@ INSERT INTO
maintenance_mode => $scan_cluster_node_maintenance_mode ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#", maintenance_mode => $scan_cluster_node_maintenance_mode ? "#!string!scan_cluster_unit_0001!#" : "#!string!scan_cluster_unit_0002!#",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0003", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0003", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0003", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_cluster_alert_0003", variables => $variables, set_by => $THIS_FILE});
} }
} }
@ -530,7 +530,7 @@ sub collect_data
# Register an alert. # Register an alert.
my $variables = { host_name => $anvil->Get->host_name() }; my $variables = { host_name => $anvil->Get->host_name() };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0010", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0010", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_cluster_alert_0010", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_cluster_alert_0010", variables => $variables, set_by => $THIS_FILE});
# See if I need to mark us as out of the cluster. Normally, our peer would do this, # See if I need to mark us as out of the cluster. Normally, our peer would do this,
# but if we went down at the same time as our peer, both of us might not update the # but if we went down at the same time as our peer, both of us might not update the
@ -606,7 +606,7 @@ WHERE
# Register an alert. # Register an alert.
my $variables = { host_name => $anvil->Get->host_name() }; my $variables = { host_name => $anvil->Get->host_name() };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0011", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0011", variables => $variables});
$anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_cluster_alert_0011", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", clear_alert => 1, message => "scan_cluster_alert_0011", variables => $variables, set_by => $THIS_FILE});
} }
} }

@ -200,13 +200,15 @@ sub collect_cpu_data
if ($changed) if ($changed)
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0001", variables => { my $variables = {
these_flags => $these_flags, these_flags => $these_flags,
flags => $flags, flags => $flags,
}}); };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0001", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "notice", alert_level => "notice",
message => "scan_hardware_alert_0001,!!these_flags!".$these_flags."!!,!!flags!".$flags."!!", message => "scan_hardware_alert_0001",
variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
}); });
} }
@ -268,13 +270,15 @@ sub collect_cpu_data
if ($changed) if ($changed)
{ {
# Register an alert. # Register an alert.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0005", variables => { my $variables = {
this_model => $this_model, this_model => $this_model,
model => $model, model => $model,
}}); };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0005", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({
alert_level => "notice", alert_level => "notice",
message => "scan_hardware_alert_0005,!!this_model!".$this_model."!!,!!model!".$model."!!", message => "scan_hardware_alert_0005",
variables => $variables,
set_by => $THIS_FILE, set_by => $THIS_FILE,
}); });
} }
@ -728,37 +732,57 @@ sub find_changes
if ($new_scan_hardware_cpu_model ne $old_scan_hardware_cpu_model) if ($new_scan_hardware_cpu_model ne $old_scan_hardware_cpu_model)
{ {
# CPU model changed, probably from a CPU upgrade or firmware flash, so just a notice level alert. # CPU model changed, probably from a CPU upgrade or firmware flash, so just a notice level alert.
$update = 1; $update = 1;
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0007,!!new!".$new_scan_hardware_cpu_model."!!,!!old!".$old_scan_hardware_cpu_model."!!"}); my $variables = {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0007", variables => { new => $new_scan_hardware_cpu_model, old => $old_scan_hardware_cpu_model }}); new => $new_scan_hardware_cpu_model,
old => $old_scan_hardware_cpu_model,
};
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0007", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0007", variables => $variables});
} }
if ($new_scan_hardware_cpu_bugs ne $old_scan_hardware_cpu_bugs) if ($new_scan_hardware_cpu_bugs ne $old_scan_hardware_cpu_bugs)
{ {
# This is probably from a CPU upgrade or firward flash # This is probably from a CPU upgrade or firward flash
$update = 1; $update = 1;
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0008,!!new!".$new_scan_hardware_cpu_bugs."!!,!!old!".$old_scan_hardware_cpu_bugs."!!"}); my $variables = {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0008", variables => { new => $new_scan_hardware_cpu_bugs, old => $old_scan_hardware_cpu_bugs }}); new => $new_scan_hardware_cpu_bugs,
old => $old_scan_hardware_cpu_bugs,
};
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0008", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0008", variables => $variables});
} }
if ($new_scan_hardware_cpu_flags ne $old_scan_hardware_cpu_flags) if ($new_scan_hardware_cpu_flags ne $old_scan_hardware_cpu_flags)
{ {
# This is probably from a CPU upgrade or firward flash # This is probably from a CPU upgrade or firward flash
$update = 1; $update = 1;
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0009,!!new!".$new_scan_hardware_cpu_flags."!!,!!old!".$old_scan_hardware_cpu_flags."!!"}); my $variables = {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0009", variables => { new => $new_scan_hardware_cpu_flags, old => $old_scan_hardware_cpu_flags }}); new => $new_scan_hardware_cpu_flags,
old => $old_scan_hardware_cpu_flags,
};
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0009", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0009", variables => $variables});
} }
if ($new_scan_hardware_cpu_cores ne $old_scan_hardware_cpu_cores) if ($new_scan_hardware_cpu_cores ne $old_scan_hardware_cpu_cores)
{ {
# This is probably from a CPU upgrade # This is probably from a CPU upgrade
$update = 1; $update = 1;
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0010,!!new!".$new_scan_hardware_cpu_cores."!!,!!old!".$old_scan_hardware_cpu_cores."!!"}); my $variables = {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0010", variables => { new => $new_scan_hardware_cpu_cores, old => $old_scan_hardware_cpu_cores }}); new => $new_scan_hardware_cpu_cores,
old => $old_scan_hardware_cpu_cores,
};
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0010", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0010", variables => $variables});
} }
if ($new_scan_hardware_cpu_threads ne $old_scan_hardware_cpu_threads) if ($new_scan_hardware_cpu_threads ne $old_scan_hardware_cpu_threads)
{ {
# This is probably from a CPU upgrade # This is probably from a CPU upgrade
$update = 1; $update = 1;
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0011,!!new!".$new_scan_hardware_cpu_threads."!!,!!old!".$old_scan_hardware_cpu_threads."!!"}); my $variables = {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0011", variables => { new => $new_scan_hardware_cpu_threads, old => $old_scan_hardware_cpu_threads }}); new => $new_scan_hardware_cpu_threads,
old => $old_scan_hardware_cpu_threads,
};
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0011", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0011", variables => $variables});
} }
if ($new_scan_hardware_ram_total ne $old_scan_hardware_ram_total) if ($new_scan_hardware_ram_total ne $old_scan_hardware_ram_total)
{ {
@ -774,7 +798,7 @@ sub find_changes
old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_ram_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_ram_total})." #!string!scan_hardware_unit_0001!#)", old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_ram_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_ram_total})." #!string!scan_hardware_unit_0001!#)",
difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)", difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)",
}; };
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "warning", message => "scan_hardware_alert_0012", message_variables => $variables}); $anvil->Alert->register({set_by => $THIS_FILE, alert_level => "warning", message => "scan_hardware_alert_0012", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0012", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0012", variables => $variables});
} }
else else
@ -787,7 +811,7 @@ sub find_changes
old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_ram_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_ram_total})." #!string!scan_hardware_unit_0001!#)", old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_ram_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_ram_total})." #!string!scan_hardware_unit_0001!#)",
difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)", difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)",
}; };
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0029", message_variables => $variables}); $anvil->Alert->register({set_by => $THIS_FILE, alert_level => "notice", message => "scan_hardware_alert_0029", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0029", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0029", variables => $variables});
} }
} }
@ -808,7 +832,7 @@ sub find_changes
old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_memory_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_memory_total})." #!string!scan_hardware_unit_0001!#)", old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_memory_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_memory_total})." #!string!scan_hardware_unit_0001!#)",
difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)", difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)",
}; };
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "warning", message => "scan_hardware_alert_0013", message_variables => $variables}); $anvil->Alert->register({set_by => $THIS_FILE, alert_level => "warning", message => "scan_hardware_alert_0013", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0013", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0013", variables => $variables});
} }
} }
@ -830,7 +854,7 @@ sub find_changes
old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_swap_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_swap_total})." #!string!scan_hardware_unit_0001!#)", old => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_swap_total})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_swap_total})." #!string!scan_hardware_unit_0001!#)",
difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)", difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!scan_hardware_unit_0001!#)",
}; };
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "warning", message => "scan_hardware_alert_0014", message_variables => $variables}); $anvil->Alert->register({set_by => $THIS_FILE, alert_level => "warning", message => "scan_hardware_alert_0014", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0014", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0014", variables => $variables});
} }
} }
@ -936,13 +960,7 @@ sub find_changes
swap_percent => $new_swap_percent_used, swap_percent => $new_swap_percent_used,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0020", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0020", variables => $variables});
$anvil->Alert->register({ $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0020", variables => $variables, set_by => $THIS_FILE });
debug => 2,
alert_level => "warning",
message => "scan_hardware_alert_0020",
message_variables => $variables,
set_by => $THIS_FILE,
});
} }
} }
elsif ($new_scan_hardware_swap_free < $anvil->data->{scancore}{'scan-hardware'}{swap}{clear_threshold}) elsif ($new_scan_hardware_swap_free < $anvil->data->{scancore}{'scan-hardware'}{swap}{clear_threshold})
@ -958,19 +976,15 @@ sub find_changes
if ($changed) if ($changed)
{ {
# Log and register that the alert has cleared. # Log and register that the alert has cleared.
my $say_used = $anvil->Convert->bytes_to_human_readable({'bytes' => $new_swap_bytes_used}); my $say_used = $anvil->Convert->bytes_to_human_readable({'bytes' => $new_swap_bytes_used});
my $say_swap = $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_hardware_swap_total}); my $say_swap = $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_hardware_swap_total});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0021", variables => { my $variables = {
say_used => $say_used, say_used => $say_used,
say_swap => $say_swap, say_swap => $say_swap,
swap_percent => $new_swap_percent_used, swap_percent => $new_swap_percent_used,
}}); };
$anvil->Alert->register({ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0021", variables => $variables});
debug => 2, $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0021", variables => $variables, set_by => $THIS_FILE });
alert_level => "warning",
message => "scan_hardware_alert_0021,!!say_used!".$say_used."!!,!!say_swap!".$say_swap."!!,!!swap_percent!".$new_swap_percent_used."!!",
set_by => $THIS_FILE,
});
} }
} }
} }
@ -1008,7 +1022,7 @@ WHERE
else else
{ {
# New record, send an alert telling that we've found data. # New record, send an alert telling that we've found data.
my $message_variables = { my $variables = {
total_cores => $new_scan_hardware_cpu_cores, total_cores => $new_scan_hardware_cpu_cores,
total_threads => $new_scan_hardware_cpu_threads, total_threads => $new_scan_hardware_cpu_threads,
cpu_bugs => $new_scan_hardware_cpu_bugs, cpu_bugs => $new_scan_hardware_cpu_bugs,
@ -1022,8 +1036,8 @@ WHERE
ram_swap_total => $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_hardware_swap_total})." (".$anvil->Convert->add_commas({number => $new_scan_hardware_swap_total})." #!string!scan_hardware_unit_0001!#)", ram_swap_total => $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_hardware_swap_total})." (".$anvil->Convert->add_commas({number => $new_scan_hardware_swap_total})." #!string!scan_hardware_unit_0001!#)",
ram_swap_free => $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_hardware_swap_free})." (".$anvil->Convert->add_commas({number => $new_scan_hardware_swap_free})." #!string!scan_hardware_unit_0001!#)", ram_swap_free => $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_hardware_swap_free})." (".$anvil->Convert->add_commas({number => $new_scan_hardware_swap_free})." #!string!scan_hardware_unit_0001!#)",
}; };
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_hardware_alert_0022", message_variables => $message_variables, set_by => $THIS_FILE }); $anvil->Alert->register({alert_level => "notice", message => "scan_hardware_alert_0022", variables => $variables, set_by => $THIS_FILE });
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0019", variables => $message_variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0019", variables => $variables});
# INSERT # INSERT
my $scan_hardware_uuid = $anvil->Get->uuid(); my $scan_hardware_uuid = $anvil->Get->uuid();
@ -1129,7 +1143,7 @@ INSERT INTO
old_serial_number => $old_scan_hardware_ram_module_serial_number, old_serial_number => $old_scan_hardware_ram_module_serial_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0023", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0023", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "warning", message => "scan_hardware_alert_0023", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0023", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
@ -1146,7 +1160,7 @@ INSERT INTO
old_serial_number => $old_scan_hardware_ram_module_serial_number, old_serial_number => $old_scan_hardware_ram_module_serial_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0024", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0024", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "warning", message => "scan_hardware_alert_0024", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0024", variables => $variables, set_by => $THIS_FILE});
} }
my $query = " my $query = "
@ -1178,7 +1192,7 @@ WHERE
serial_number => $new_scan_hardware_ram_module_serial_number, serial_number => $new_scan_hardware_ram_module_serial_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "scan_hardware_alert_0025", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "scan_hardware_alert_0025", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "notice", message => "scan_hardware_alert_0025", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_hardware_alert_0025", variables => $variables, set_by => $THIS_FILE});
# INSERT # INSERT
my $scan_hardware_ram_module_uuid = $anvil->Get->uuid(); my $scan_hardware_ram_module_uuid = $anvil->Get->uuid();
@ -1243,7 +1257,7 @@ INSERT INTO
old_serial_number => $old_scan_hardware_ram_module_serial_number, old_serial_number => $old_scan_hardware_ram_module_serial_number,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "scan_hardware_alert_0026", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "scan_hardware_alert_0026", variables => $variables});
$anvil->Alert->register({debug => 2, alert_level => "warning", message => "scan_hardware_alert_0026", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0026", variables => $variables, set_by => $THIS_FILE});
my $query = " my $query = "
UPDATE UPDATE
@ -1331,7 +1345,7 @@ sub process_health
difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!suffix_0009!#)", difference => $anvil->Convert->bytes_to_human_readable({'bytes' => $difference})." (".$anvil->Convert->add_commas({number => $difference})." #!string!suffix_0009!#)",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0027", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0027", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0027", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0027", variables => $variables, set_by => $THIS_FILE});
} }
} }
my ($health_uuid) = $anvil->Database->insert_or_update_health({ my ($health_uuid) = $anvil->Database->insert_or_update_health({
@ -1364,7 +1378,7 @@ sub process_health
ram => $anvil->Convert->bytes_to_human_readable({'bytes' => $hardware_ram_total})." (".$anvil->Convert->add_commas({number => $hardware_ram_total})." #!string!suffix_0009!#)", ram => $anvil->Convert->bytes_to_human_readable({'bytes' => $hardware_ram_total})." (".$anvil->Convert->add_commas({number => $hardware_ram_total})." #!string!suffix_0009!#)",
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0028", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0028", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0028", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0028", variables => $variables, set_by => $THIS_FILE});
} }
my ($health_uuid) = $anvil->Database->insert_or_update_health({ my ($health_uuid) = $anvil->Database->insert_or_update_health({
debug => 2, debug => 2,

@ -108,14 +108,13 @@ if (($< != 0) && ($> != 0))
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
### TODO: Rework this whole agent... # Here we store data and variables for this agent.
# Get the handle to the AN::Tools and preset some variables I will use.
$anvil->data->{'scan-ipmitool'} = { $anvil->data->{'scan-ipmitool'} = {
disable => 0, disable => 0,
# It will be marked as 'clear' when the temperature drops this many °C below the # It will be marked as 'clear' when the temperature drops this many °C below the
# critical temperature. # critical temperature.
machine => {}, machine => {},
alert_sort => 0, alert_sort => 2,
# These are used when no other limits are set for a given sensor. # These are used when no other limits are set for a given sensor.
thresholds => { thresholds => {
'default' => { 'default' => {
@ -261,95 +260,27 @@ sub process_health
# This will hold our updates. # This will hold our updates.
$anvil->data->{'scan-ipmitool'}{queries} = []; $anvil->data->{'scan-ipmitool'}{queries} = [];
# Read in previous health values.
my $query = "
SELECT
health_uuid,
health_source_name,
health_source_weight
FROM
health
WHERE
health_host_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)."
AND
health_agent_name = ".$anvil->Database->quote($THIS_FILE)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { results => $results }});
foreach my $row (@{$results})
{
my $health_uuid = $row->[0];
my $health_source_name = $row->[1];
my $health_source_weight = $row->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
health_uuid => $health_uuid,
health_source_name => $health_source_name,
health_source_weight => $health_source_weight,
}});
$anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{uuid} = $health_uuid;
$anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{value} = $health_source_weight;
}
# Read in the new ones # Read in the new ones
foreach my $health_source_name (sort {$a cmp $b} keys %{$anvil->data->{'scan-ipmitool'}{health}{new}}) foreach my $health_source_name (sort {$a cmp $b} keys %{$anvil->data->{'scan-ipmitool'}{health}{new}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"health::new::$health_source_name" => $anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name}, "health::new::$health_source_name" => $anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name},
}}); }});
if (exists $anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name})
{
# We've seen this before. Has it changed?
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"health::old::${health_source_name}::value" => $anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{value},
}});
if ($anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name} ne $anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{value})
{
# It has changed, update it.
my $query = "
UPDATE
health
SET
health_source_weight = ".$anvil->Database->quote($anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name}).",
modified_date = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
WHERE
health_uuid = ".$anvil->Database->quote($anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{uuid})."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query; my $health_uuid = $anvil->Database->insert_or_update_health({
} debug => 2,
cache => $anvil->data->{'scan-ipmitool'}{queries},
health_host_uuid => $anvil->Get->host_uuid,
health_agent_name => $THIS_FILE,
health_source_name => $health_source_name,
health_source_weight => $anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name},
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { health_uuid => $health_uuid }});
# Delete the new old key, regardless of whether it has changed now. # Delete the new old key, if it existed
delete $anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}; if ($anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name})
}
else
{ {
# New entry, INSERT it. delete $anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name};
my $query = "
INSERT INTO
health
(
health_uuid,
health_host_uuid,
health_agent_name,
health_source_name,
health_source_weight,
modified_date
) VALUES (
".$anvil->Database->quote($anvil->Get->uuid).",
".$anvil->Database->quote($anvil->Get->host_uuid).",
".$anvil->Database->quote($THIS_FILE).",
".$anvil->Database->quote($health_source_name).",
".$anvil->Database->quote($anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name}).",
".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
);";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query;
} }
} }
@ -357,26 +288,13 @@ INSERT INTO
foreach my $health_source_name (sort {$a cmp $b} keys %{$anvil->data->{'scan-ipmitool'}{health}{old}}) foreach my $health_source_name (sort {$a cmp $b} keys %{$anvil->data->{'scan-ipmitool'}{health}{old}})
{ {
# Well set the source name to 'DELETED'. # Well set the source name to 'DELETED'.
my $query = " my $health_uuid = $anvil->Database->insert_or_update_health({
UPDATE debug => 2,
health cache => $anvil->data->{'scan-ipmitool'}{queries},
SET health_uuid => $anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{uuid},
health_source_name = 'DELETED', 'delete' => 1,
modified_date = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})." });
WHERE $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { health_uuid => $health_uuid }});
health_uuid = ".$anvil->Database->quote($anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{uuid})."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query;
$query = "
DELETE FROM
health
WHERE
health_uuid = ".$anvil->Database->quote($anvil->data->{'scan-ipmitool'}{health}{old}{$health_source_name}{uuid})."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query;
} }
# Now commit the changes. # Now commit the changes.
@ -436,7 +354,7 @@ sub find_changes
sensor => $scan_ipmitool_sensor_name, sensor => $scan_ipmitool_sensor_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_ipmitool_message_0002", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_ipmitool_message_0002", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0002", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0002", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-ipmitool'}{alert_sort}++});
next; next;
} }
if (not $new_scan_ipmitool_value_sensor_value) if (not $new_scan_ipmitool_value_sensor_value)
@ -446,7 +364,7 @@ sub find_changes
sensor => $scan_ipmitool_sensor_name, sensor => $scan_ipmitool_sensor_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_ipmitool_message_0003", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_ipmitool_message_0003", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0003", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0003", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-ipmitool'}{alert_sort}++});
next; next;
} }
@ -597,10 +515,10 @@ WHERE
old_high_warning => $old_scan_ipmitool_sensor_high_warning eq "" ? "--" : $old_scan_ipmitool_sensor_high_warning, old_high_warning => $old_scan_ipmitool_sensor_high_warning eq "" ? "--" : $old_scan_ipmitool_sensor_high_warning,
old_low_warning => $old_scan_ipmitool_sensor_low_warning eq "" ? "--" : $old_scan_ipmitool_sensor_low_warning, old_low_warning => $old_scan_ipmitool_sensor_low_warning eq "" ? "--" : $old_scan_ipmitool_sensor_low_warning,
}; };
my $sort_position = (($level eq "warning") or ($level eq "critical")) ? 1 : $anvil->data->{'scan-apc-pdu'}{alert_sort}++; my $sort_position = (($level eq "warning") or ($level eq "critical")) ? 1 : $anvil->data->{'scan-ipmitool'}{alert_sort}++;
my $log_level = (($level eq "warning") or ($level eq "critical")) ? 1 : 2; my $log_level = (($level eq "warning") or ($level eq "critical")) ? 1 : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => $level, message => $message_key, message_variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); $anvil->Alert->register({alert_level => $level, message => $message_key, variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position});
} }
else else
{ {
@ -613,7 +531,7 @@ WHERE
old_sensor_value => $old_sensor_value old_sensor_value => $old_sensor_value
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => $level, message => $message_key, message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => $level, message => $message_key, variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-ipmitool'}{alert_sort}++});
} }
} }
else else
@ -632,18 +550,18 @@ WHERE
{ {
# Huh, interesting. Well, update # Huh, interesting. Well, update
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
new_scan_ipmitool_sensor_units => $new_scan_ipmitool_sensor_units, new_scan_ipmitool_sensor_units => $new_scan_ipmitool_sensor_units,
new_scan_ipmitool_sensor_status => $new_scan_ipmitool_sensor_status, new_scan_ipmitool_sensor_status => $new_scan_ipmitool_sensor_status,
new_scan_ipmitool_sensor_high_critical => $new_scan_ipmitool_sensor_high_critical, new_scan_ipmitool_sensor_high_critical => $new_scan_ipmitool_sensor_high_critical,
new_scan_ipmitool_sensor_high_warning => $new_scan_ipmitool_sensor_high_warning, new_scan_ipmitool_sensor_high_warning => $new_scan_ipmitool_sensor_high_warning,
new_scan_ipmitool_sensor_low_critical => $new_scan_ipmitool_sensor_low_critical, new_scan_ipmitool_sensor_low_critical => $new_scan_ipmitool_sensor_low_critical,
new_scan_ipmitool_sensor_low_warning => $new_scan_ipmitool_sensor_low_warning, new_scan_ipmitool_sensor_low_warning => $new_scan_ipmitool_sensor_low_warning,
old_scan_ipmitool_sensor_units => $old_scan_ipmitool_sensor_units, old_scan_ipmitool_sensor_units => $old_scan_ipmitool_sensor_units,
old_scan_ipmitool_sensor_status => $old_scan_ipmitool_sensor_status, old_scan_ipmitool_sensor_status => $old_scan_ipmitool_sensor_status,
old_scan_ipmitool_sensor_high_critical => $old_scan_ipmitool_sensor_high_critical, old_scan_ipmitool_sensor_high_critical => $old_scan_ipmitool_sensor_high_critical,
old_scan_ipmitool_sensor_high_warning => $old_scan_ipmitool_sensor_high_warning, old_scan_ipmitool_sensor_high_warning => $old_scan_ipmitool_sensor_high_warning,
old_scan_ipmitool_sensor_low_critical => $old_scan_ipmitool_sensor_low_critical, old_scan_ipmitool_sensor_low_critical => $old_scan_ipmitool_sensor_low_critical,
old_scan_ipmitool_sensor_low_warning => $old_scan_ipmitool_sensor_low_warning, old_scan_ipmitool_sensor_low_warning => $old_scan_ipmitool_sensor_low_warning,
}}); }});
### NOTE: These were added to debug duplicate scan_ipmitool_values entries. ### NOTE: These were added to debug duplicate scan_ipmitool_values entries.
@ -654,7 +572,7 @@ WHERE
sensor => $scan_ipmitool_sensor_name, sensor => $scan_ipmitool_sensor_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_ipmitool_message_0015", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_ipmitool_message_0015", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0015", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0015", variables => $variables, set_by => $THIS_FILE, show_header => 0, sort_position => $anvil->data->{'scan-ipmitool'}{alert_sort}++});
next; next;
} }
@ -709,10 +627,10 @@ AND
old_low_warning => $old_scan_ipmitool_sensor_low_warning eq "" ? "--" : $old_scan_ipmitool_sensor_low_warning." ".$old_scan_ipmitool_sensor_units, old_low_warning => $old_scan_ipmitool_sensor_low_warning eq "" ? "--" : $old_scan_ipmitool_sensor_low_warning." ".$old_scan_ipmitool_sensor_units,
}; };
my $sort_position = (($level eq "warning") or ($level eq "critical")) ? 1 : $anvil->data->{'scan-apc-pdu'}{alert_sort}++; my $sort_position = (($level eq "warning") or ($level eq "critical")) ? 1 : $anvil->data->{'scan-ipmitool'}{alert_sort}++;
my $log_level = (($level eq "warning") or ($level eq "critical")) ? 1 : 2; my $log_level = (($level eq "warning") or ($level eq "critical")) ? 1 : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => $message_key, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => $message_key, variables => $variables});
$anvil->Alert->register({alert_level => $level, message => $message_key, message_variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); $anvil->Alert->register({alert_level => $level, message => $message_key, variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position});
} }
# Delete the old key so that I can check to see what sensors # Delete the old key so that I can check to see what sensors
@ -726,7 +644,7 @@ AND
if ($anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name}{scan_ipmitool_value_sensor_value} eq "") if ($anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name}{scan_ipmitool_value_sensor_value} eq "")
{ {
# Ignore it. # Ignore it.
$anvil->Log->entry({log_level => 3, message_key => "scan_ipmitool_log_0005", message_variables => { sensor_name => $scan_ipmitool_sensor_name }, file => $THIS_FILE, line => __LINE__}); $anvil->Log->entry({log_level => 3, message_key => "scan_ipmitool_log_0005", variables => { sensor_name => $scan_ipmitool_sensor_name }, file => $THIS_FILE, line => __LINE__});
delete $anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name}; delete $anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name};
next; next;
} }
@ -746,7 +664,7 @@ AND
sensor => $scan_ipmitool_sensor_name, sensor => $scan_ipmitool_sensor_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_ipmitool_message_0017", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_ipmitool_message_0017", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0017", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0017", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-ipmitool'}{alert_sort}++});
next; next;
} }
if (not $new_scan_ipmitool_value_sensor_value) if (not $new_scan_ipmitool_value_sensor_value)
@ -756,7 +674,7 @@ AND
sensor => $scan_ipmitool_sensor_name, sensor => $scan_ipmitool_sensor_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_ipmitool_message_0018", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_ipmitool_message_0018", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0018", message_variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++}); $anvil->Alert->register({alert_level => "notice", message => "scan_ipmitool_message_0018", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-ipmitool'}{alert_sort}++});
next; next;
} }
@ -841,10 +759,10 @@ INSERT INTO
}}); }});
} }
my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-apc-pdu'}{alert_sort}++; my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-ipmitool'}{alert_sort}++;
my $log_level = $level eq "warning" ? 1 : 2; my $log_level = $level eq "warning" ? 1 : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => "scan_ipmitool_message_0019", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => "scan_ipmitool_message_0019", variables => $variables});
$anvil->Alert->register({alert_level => $level, message => "scan_ipmitool_message_0019", message_variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); $anvil->Alert->register({alert_level => $level, message => "scan_ipmitool_message_0019", variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position});
} }
} }
} }
@ -860,7 +778,7 @@ INSERT INTO
if ($anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name}{scan_ipmitool_value_sensor_value} eq "") if ($anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name}{scan_ipmitool_value_sensor_value} eq "")
{ {
# Ignore it. # Ignore it.
$anvil->Log->entry({log_level => 3, message_key => "scan_ipmitool_log_0005", message_variables => { sensor_name => $scan_ipmitool_sensor_name }, file => $THIS_FILE, line => __LINE__}); $anvil->Log->entry({log_level => 3, message_key => "scan_ipmitool_log_0005", variables => { sensor_name => $scan_ipmitool_sensor_name }, file => $THIS_FILE, line => __LINE__});
delete $anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name}; delete $anvil->data->{ipmi}{$machine}{scan_ipmitool_sensor_name}{$scan_ipmitool_sensor_name};
next; next;
} }
@ -983,10 +901,10 @@ INSERT INTO
low_critical => $new_scan_ipmitool_sensor_low_critical eq "" ? "--" : $new_scan_ipmitool_sensor_low_critical." ".$new_scan_ipmitool_sensor_units, low_critical => $new_scan_ipmitool_sensor_low_critical eq "" ? "--" : $new_scan_ipmitool_sensor_low_critical." ".$new_scan_ipmitool_sensor_units,
low_warning => $new_scan_ipmitool_sensor_low_warning eq "" ? "--" : $new_scan_ipmitool_sensor_low_warning." ".$new_scan_ipmitool_sensor_units, low_warning => $new_scan_ipmitool_sensor_low_warning eq "" ? "--" : $new_scan_ipmitool_sensor_low_warning." ".$new_scan_ipmitool_sensor_units,
}; };
my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-apc-pdu'}{alert_sort}++; my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-ipmitool'}{alert_sort}++;
my $log_level = $level eq "warning" ? 1 : 2; my $log_level = $level eq "warning" ? 1 : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => "scan_ipmitool_message_0019", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => "scan_ipmitool_message_0019", variables => $variables});
$anvil->Alert->register({alert_level => $level, message => "scan_ipmitool_message_0019", message_variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); $anvil->Alert->register({alert_level => $level, message => "scan_ipmitool_message_0019", variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position});
} }
} }
@ -1112,6 +1030,8 @@ sub process_temperature
my ($anvil, $machine) = @_; my ($anvil, $machine) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { machine => $machine }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { machine => $machine }});
$anvil->data->{'scan-ipmitool'}{queries} = [];
# First, read in all existing entries. We'll compare and UPDATE or INSERT as needed and DELETE any # First, read in all existing entries. We'll compare and UPDATE or INSERT as needed and DELETE any
# stale entries. # stale entries.
my $query = " my $query = "
@ -1160,11 +1080,11 @@ AND
my $new_temperature_state = $anvil->data->{new}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_state}; my $new_temperature_state = $anvil->data->{new}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_state};
my $new_temperature_is = $anvil->data->{new}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_is}; my $new_temperature_is = $anvil->data->{new}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_is};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"scan_ipmitool_sensor_name" => $scan_ipmitool_sensor_name, scan_ipmitool_sensor_name => $scan_ipmitool_sensor_name,
"new_temperature_uuid" => $new_temperature_uuid, new_temperature_uuid => $new_temperature_uuid,
"new_temperature_value_c" => $new_temperature_value_c, new_temperature_value_c => $new_temperature_value_c,
"new_temperature_state" => $new_temperature_state, new_temperature_state => $new_temperature_state,
"new_temperature_is" => $new_temperature_is, new_temperature_is => $new_temperature_is,
}}); }});
if ($new_temperature_value_c eq "na") if ($new_temperature_value_c eq "na")
@ -1205,7 +1125,7 @@ AND
# If it's not OK, set the weight # If it's not OK, set the weight
if ($new_temperature_state ne "ok") if ($new_temperature_state ne "ok")
{ {
my $health_source_name = "temperature:".$scan_ipmitool_sensor_name; my $health_source_name = "temperature:".$scan_ipmitool_sensor_name;
$anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name} = $new_temperature_weight; $anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name} = $new_temperature_weight;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"health::new::$health_source_name" => $anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name}, "health::new::$health_source_name" => $anvil->data->{'scan-ipmitool'}{health}{new}{$health_source_name},
@ -1214,123 +1134,50 @@ AND
} }
# Now see if the variable was seen before and, if so, if it changed. # Now see if the variable was seen before and, if so, if it changed.
my $temperature_uuid = "";
if (ref($anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name})) if (ref($anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}))
{ {
# Update the existing entry, if needed. # Update the existing entry, if needed.
my $old_temperature_uuid = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_uuid}; my $temperature_uuid = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_uuid};
my $old_temperature_value_c = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_value_c}; }
my $old_temperature_weight = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_weight};
my $old_temperature_state = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_state};
my $old_temperature_is = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_is};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
old_temperature_uuid => $old_temperature_uuid,
old_temperature_value_c => $old_temperature_value_c,
old_temperature_weight => $old_temperature_weight,
old_temperature_state => $old_temperature_state,
old_temperature_is => $old_temperature_is,
}});
if (($new_temperature_value_c ne $old_temperature_value_c) or
($new_temperature_weight ne $old_temperature_weight) or
($new_temperature_state ne $old_temperature_state) or
($new_temperature_is ne $old_temperature_is))
{
my $query = "
UPDATE
temperature
SET
temperature_value_c = ".$anvil->Database->quote($new_temperature_value_c).",
temperature_weight = ".$anvil->Database->quote($new_temperature_weight).",
temperature_state = ".$anvil->Database->quote($new_temperature_state).",
temperature_is = ".$anvil->Database->quote($new_temperature_is).",
modified_date = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
WHERE
temperature_uuid = ".$anvil->Database->quote($old_temperature_uuid).";
";
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
name1 => "query", value1 => $query
}});
}
# We still want this value, so delete it from the hash so it doesn't get deleted in # Generate and store the UUID.
# the next step. my $sensor_host_uuid = $anvil->Get->host_uuid_from_name({host_name => $machine});
delete $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}; if (not $sensor_host_uuid)
{
$sensor_host_uuid = $machine;
} }
else $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sensor_host_uuid => $sensor_host_uuid }});
$temperature_uuid = $anvil->Database->insert_or_update_temperature({
cache => $anvil->data->{'scan-ipmitool'}{queries},
debug => 2,
temperature_uuid => $temperature_uuid,
temperature_host_uuid => $anvil->Get->host_uuid,
temperature_agent_name => $THIS_FILE,
temperature_sensor_host => $sensor_host_uuid,
temperature_sensor_name => $scan_ipmitool_sensor_name,
temperature_value_c => $new_temperature_value_c,
temperature_state => $new_temperature_state,
temperature_is => $new_temperature_is,
temperature_weight => $new_temperature_weigh,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { temperature_uuid => $temperature_uuid }});
# We still want this value, so delete it from the hash.
if (exists $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name})
{ {
### New entry delete $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name};
# Generate and store the UUID.
my $scan_ipmitool_uuid = $anvil->Get->uuid() or $anvil->Alert->error({title_key => "error_title_0020", message_key => "error_message_0024", code => 2, file => $THIS_FILE, line => __LINE__});;
$anvil->data->{new}{$machine}{temperature}{$scan_ipmitool_sensor_name}{scan_ipmitool_uuid} = $scan_ipmitool_uuid;
my $query = "
INSERT INTO
temperature
(
temperature_uuid,
temperature_host_uuid,
temperature_sensor_host,
temperature_sensor_name,
temperature_agent_name,
temperature_value_c,
temperature_weight,
temperature_state,
temperature_is,
modified_date
) VALUES (
".$anvil->Database->quote($scan_ipmitool_uuid).",
".$anvil->Database->quote($anvil->Get->host_uuid).",
".$anvil->Database->quote($machine).",
".$anvil->Database->quote($scan_ipmitool_sensor_name).",
".$anvil->Database->quote($THIS_FILE).",
".$anvil->Database->quote($new_temperature_value_c).",
".$anvil->Database->quote($new_temperature_weight).",
".$anvil->Database->quote($new_temperature_state).",
".$anvil->Database->quote($new_temperature_is).",
".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
);
";
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
} }
}
# Now, if any undeleted old entries remain, delete them from the database. $anvil->data->{new}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_uuid} = $temperature_uuid;
foreach my $scan_ipmitool_sensor_name (sort {$a cmp $b} keys %{$anvil->data->{old}{$machine}{temperature}})
{
my $temperature_uuid = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_uuid};
my $old_temperature_value_c = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_value_c};
my $old_temperature_state = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_state};
my $old_temperature_is = $anvil->data->{old}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_is};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
temperature_uuid => $temperature_uuid, "new::${machine}::temperature::${scan_ipmitool_sensor_name}::temperature_uuid" => $anvil->data->{new}{$machine}{temperature}{$scan_ipmitool_sensor_name}{temperature_uuid},
old_temperature_value_c => $old_temperature_value_c,
old_temperature_state => $old_temperature_state,
old_temperature_is => $old_temperature_is,
}}); }});
# Mark the sensor as DELETEd.
my $query = "
UPDATE
temperature
SET
temperature_state = 'DELETED',
modified_date = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
WHERE
temperature_uuid = ".$anvil->Database->quote($temperature_uuid)."
;";
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$query = "
DELETE FROM
temperature
WHERE
temperature_uuid = ".$anvil->Database->quote($temperature_uuid)."
";
push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
} }
# Now commit the changes.
$anvil->Database->write({query => $anvil->data->{'scan-ipmitool'}{queries}, source => $THIS_FILE, line => __LINE__});
return(0); return(0);
} }
@ -1835,7 +1682,7 @@ sub process_temperature_change
old_sensor_value => $old_sensor_value old_sensor_value => $old_sensor_value
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_ipmitool_message_0010", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "scan_ipmitool_message_0010", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_ipmitool_message_0010", message_variables => $variables, sort_position => 1, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_ipmitool_message_0010", variables => $variables, sort_position => 1, set_by => $THIS_FILE});
} }
} }
} }

@ -11,7 +11,7 @@ NOTE: All string keys MUST be prefixed with the agent name! ie: 'scan_ipmitool_l
<words> <words>
<meta version="3.0.0" languages="en_CA,jp"/> <meta version="3.0.0" languages="en_CA,jp"/>
<!-- Canadian English --> <!-- Canadian English -->
<language name="en_CA" long_name="Canadian English" description="ScanCore scan agent that monitors hardware, like RAM modules, CSS LED status, CPU information, etc."> <language name="en_CA" long_name="Canadian English" description="ScanCore scan agent that monitors sensors available via IPMI BMCs.">
<!-- Messages entries --> <!-- Messages entries -->
<key name="scan_ipmitool_message_0001">No IPMI BMC found on this host nor where any other machines with IPMI found or where accessible. Nothing to do.</key> <key name="scan_ipmitool_message_0001">No IPMI BMC found on this host nor where any other machines with IPMI found or where accessible. Nothing to do.</key>

@ -174,7 +174,7 @@ sub find_changes_in_lvs
lv_name => $scan_lvm_lv_name, lv_name => $scan_lvm_lv_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0021", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0021", variables => $variables});
$anvil->Alert->register({debug => 3, clear_alert => 1, alert_level => "warning", message => "scan_lvm_alert_0021", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({clear_alert => 1, alert_level => "warning", message => "scan_lvm_alert_0021", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
@ -185,7 +185,7 @@ sub find_changes_in_lvs
old_lv_name => $old_scan_lvm_lv_name, old_lv_name => $old_scan_lvm_lv_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0022", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0022", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0022", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0022", variables => $variables, set_by => $THIS_FILE});
} }
} }
if ($scan_lvm_lv_attributes ne $old_scan_lvm_lv_attributes) if ($scan_lvm_lv_attributes ne $old_scan_lvm_lv_attributes)
@ -200,7 +200,7 @@ sub find_changes_in_lvs
old_attributes => $old_scan_lvm_lv_attributes, old_attributes => $old_scan_lvm_lv_attributes,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0023", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0023", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0023", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0023", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_lvm_lv_on_vg ne $old_scan_lvm_lv_on_vg) if ($scan_lvm_lv_on_vg ne $old_scan_lvm_lv_on_vg)
{ {
@ -214,7 +214,7 @@ sub find_changes_in_lvs
old_lv_on_vg => $old_scan_lvm_lv_on_vg, old_lv_on_vg => $old_scan_lvm_lv_on_vg,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0024", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0024", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0024", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0024", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_lvm_lv_size ne $old_scan_lvm_lv_size) if ($scan_lvm_lv_size ne $old_scan_lvm_lv_size)
{ {
@ -233,13 +233,13 @@ sub find_changes_in_lvs
{ {
# Grew, probably added a new PV # Grew, probably added a new PV
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0025", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0025", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0025", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0025", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
# Shrank, # Shrank,
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0026", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0026", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0026", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0026", variables => $variables, set_by => $THIS_FILE});
} }
} }
if ($scan_lvm_lv_path ne $old_scan_lvm_lv_path) if ($scan_lvm_lv_path ne $old_scan_lvm_lv_path)
@ -254,7 +254,7 @@ sub find_changes_in_lvs
old_lv_path => $old_scan_lvm_lv_path, old_lv_path => $old_scan_lvm_lv_path,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0027", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0027", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0027", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0027", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_lvm_lv_on_pvs ne $old_scan_lvm_lv_on_pvs) if ($scan_lvm_lv_on_pvs ne $old_scan_lvm_lv_on_pvs)
{ {
@ -267,7 +267,7 @@ sub find_changes_in_lvs
old_lv_on_pvs => $old_scan_lvm_lv_path, old_lv_on_pvs => $old_scan_lvm_lv_path,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0028", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0028", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0028", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0028", variables => $variables, set_by => $THIS_FILE});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update => $update }});
@ -308,7 +308,7 @@ WHERE
lv_on_pvs => $scan_lvm_lv_on_pvs, lv_on_pvs => $scan_lvm_lv_on_pvs,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0029", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0029", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0029", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0029", variables => $variables, set_by => $THIS_FILE});
my $scan_lvm_lv_uuid = $anvil->Get->uuid(); my $scan_lvm_lv_uuid = $anvil->Get->uuid();
my $query = " my $query = "
@ -360,7 +360,7 @@ INSERT INTO
lv_name => $old_scan_lvm_lv_name, lv_name => $old_scan_lvm_lv_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0031", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0031", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0031", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0031", variables => $variables, set_by => $THIS_FILE});
# Update it PV name to be 'DELTED' # Update it PV name to be 'DELTED'
my $query = " my $query = "
@ -431,7 +431,7 @@ sub find_changes_in_vgs
vg_name => $scan_lvm_vg_name, vg_name => $scan_lvm_vg_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0011", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0011", variables => $variables});
$anvil->Alert->register({debug => 3, clear_alert => 1, alert_level => "warning", message => "scan_lvm_alert_0011", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({clear_alert => 1, alert_level => "warning", message => "scan_lvm_alert_0011", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
@ -442,7 +442,7 @@ sub find_changes_in_vgs
old_vg_name => $old_scan_lvm_vg_name, old_vg_name => $old_scan_lvm_vg_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0012", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0012", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0012", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0012", variables => $variables, set_by => $THIS_FILE});
} }
} }
if ($scan_lvm_vg_attributes ne $old_scan_lvm_vg_attributes) if ($scan_lvm_vg_attributes ne $old_scan_lvm_vg_attributes)
@ -457,7 +457,7 @@ sub find_changes_in_vgs
old_attributes => $old_scan_lvm_vg_attributes, old_attributes => $old_scan_lvm_vg_attributes,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0013", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0013", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0013", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0013", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_lvm_vg_extent_size ne $old_scan_lvm_vg_extent_size) if ($scan_lvm_vg_extent_size ne $old_scan_lvm_vg_extent_size)
{ {
@ -473,7 +473,7 @@ sub find_changes_in_vgs
old_vg_extent_size_bytes => $anvil->Convert->add_commas({number => $old_scan_lvm_vg_extent_size}), old_vg_extent_size_bytes => $anvil->Convert->add_commas({number => $old_scan_lvm_vg_extent_size}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0014", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0014", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0014", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0014", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_lvm_vg_size ne $old_scan_lvm_vg_size) if ($scan_lvm_vg_size ne $old_scan_lvm_vg_size)
{ {
@ -492,13 +492,13 @@ sub find_changes_in_vgs
{ {
# Grew, probably added a new PV # Grew, probably added a new PV
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0015", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0015", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0015", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0015", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
# Shrank, wat? # Shrank, wat?
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0016", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0016", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0016", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0016", variables => $variables, set_by => $THIS_FILE});
} }
} }
if ($scan_lvm_vg_free ne $old_scan_lvm_vg_free) if ($scan_lvm_vg_free ne $old_scan_lvm_vg_free)
@ -518,13 +518,13 @@ sub find_changes_in_vgs
{ {
# Likely a new LV was created or an existing one was extended. # Likely a new LV was created or an existing one was extended.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0017", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0017", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0017", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0017", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
# An old LV was probably removed. # An old LV was probably removed.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0018", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0018", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0018", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0018", variables => $variables, set_by => $THIS_FILE});
} }
} }
@ -566,7 +566,7 @@ WHERE
vg_free_bytes => $anvil->Convert->add_commas({number => $scan_lvm_vg_free}), vg_free_bytes => $anvil->Convert->add_commas({number => $scan_lvm_vg_free}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0020", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0020", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0020", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0020", variables => $variables, set_by => $THIS_FILE});
my $scan_lvm_vg_uuid = $anvil->Get->uuid(); my $scan_lvm_vg_uuid = $anvil->Get->uuid();
my $query = " my $query = "
@ -616,7 +616,7 @@ INSERT INTO
vg_name => $old_scan_lvm_vg_name, vg_name => $old_scan_lvm_vg_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0030", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0030", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0030", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0030", variables => $variables, set_by => $THIS_FILE});
# Update it PV name to be 'DELTED' # Update it PV name to be 'DELTED'
my $query = " my $query = "
@ -686,7 +686,7 @@ sub find_changes_in_pvs
pv_name => $scan_lvm_pv_name, pv_name => $scan_lvm_pv_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0001", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0001", variables => $variables});
$anvil->Alert->register({debug => 3, clear_alert => 1, alert_level => "warning", message => "scan_lvm_alert_0001", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({clear_alert => 1, alert_level => "warning", message => "scan_lvm_alert_0001", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
@ -697,7 +697,7 @@ sub find_changes_in_pvs
old_pv_name => $old_scan_lvm_pv_name, old_pv_name => $old_scan_lvm_pv_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0002", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0002", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0002", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0002", variables => $variables, set_by => $THIS_FILE});
} }
} }
if ($scan_lvm_pv_used_by_vg ne $old_scan_lvm_pv_used_by_vg) if ($scan_lvm_pv_used_by_vg ne $old_scan_lvm_pv_used_by_vg)
@ -714,7 +714,7 @@ sub find_changes_in_pvs
vg_name => $scan_lvm_pv_used_by_vg, vg_name => $scan_lvm_pv_used_by_vg,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0004", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0004", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0004", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0004", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
@ -726,7 +726,7 @@ sub find_changes_in_pvs
old_vg_name => $old_scan_lvm_pv_used_by_vg, old_vg_name => $old_scan_lvm_pv_used_by_vg,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0005", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0005", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0005", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0005", variables => $variables, set_by => $THIS_FILE});
} }
} }
if ($scan_lvm_pv_attributes ne $old_scan_lvm_pv_attributes) if ($scan_lvm_pv_attributes ne $old_scan_lvm_pv_attributes)
@ -741,7 +741,7 @@ sub find_changes_in_pvs
old_attributes => $old_scan_lvm_pv_attributes, old_attributes => $old_scan_lvm_pv_attributes,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0006", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0006", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0006", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0006", variables => $variables, set_by => $THIS_FILE});
} }
if ($scan_lvm_pv_size ne $old_scan_lvm_pv_size) if ($scan_lvm_pv_size ne $old_scan_lvm_pv_size)
{ {
@ -760,13 +760,13 @@ sub find_changes_in_pvs
{ {
# Yup # Yup
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0007", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0007", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0007", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0007", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
# Uhhhh... We'll make this a warning as it shouldn't happen. # Uhhhh... We'll make this a warning as it shouldn't happen.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0008", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0008", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0008", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0008", variables => $variables, set_by => $THIS_FILE});
} }
} }
if ($scan_lvm_pv_free ne $old_scan_lvm_pv_free) if ($scan_lvm_pv_free ne $old_scan_lvm_pv_free)
@ -786,13 +786,13 @@ sub find_changes_in_pvs
{ {
# Yup # Yup
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0009", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0009", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0009", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0009", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
# Uhhhh... We'll make this a warning as it shouldn't happen. # Uhhhh... We'll make this a warning as it shouldn't happen.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0010", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0010", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0010", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0010", variables => $variables, set_by => $THIS_FILE});
} }
} }
@ -833,7 +833,7 @@ WHERE
pv_free_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_free}), pv_free_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_free}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0019", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0019", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "notice", message => "scan_lvm_alert_0019", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0019", variables => $variables, set_by => $THIS_FILE});
my $scan_lvm_pv_uuid = $anvil->Get->uuid(); my $scan_lvm_pv_uuid = $anvil->Get->uuid();
my $query = " my $query = "
@ -883,7 +883,7 @@ INSERT INTO
pv_name => $old_scan_lvm_pv_name, pv_name => $old_scan_lvm_pv_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0003", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0003", variables => $variables});
$anvil->Alert->register({debug => 3, alert_level => "warning", message => "scan_lvm_alert_0003", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0003", variables => $variables, set_by => $THIS_FILE});
# Update it PV name to be 'DELTED' # Update it PV name to be 'DELTED'
my $query = " my $query = "

@ -255,7 +255,7 @@ DELETED - Marks a server as no longer existing
definition => $virsh_definition, definition => $virsh_definition,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0006", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0006", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0006", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0006", variables => $variables, set_by => $THIS_FILE});
} }
$anvil->data->{'scan-server'}{server_name}{$server_name}{server_uuid} = $server_uuid; $anvil->data->{'scan-server'}{server_name}{$server_name}{server_uuid} = $server_uuid;
@ -366,7 +366,7 @@ DELETED - Marks a server as no longer existing
new_definition => $database_definition, new_definition => $database_definition,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0001", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0001", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0001", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0001", variables => $variables, set_by => $THIS_FILE});
} }
else else
{ {
@ -383,7 +383,7 @@ DELETED - Marks a server as no longer existing
new_definition => $on_disk_definition, new_definition => $on_disk_definition,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0002", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0002", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0002", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0002", variables => $variables, set_by => $THIS_FILE});
} }
# In either case, update the virsh definition from the disk now (either to load the # In either case, update the virsh definition from the disk now (either to load the
@ -413,7 +413,7 @@ DELETED - Marks a server as no longer existing
new_definition => $virsh_definition, new_definition => $virsh_definition,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0003", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0003", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0003", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0003", variables => $variables, set_by => $THIS_FILE});
} }
my ($virsh_live_definition, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." dumpxml ".$server_name, source => $THIS_FILE, line => __LINE__}); my ($virsh_live_definition, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." dumpxml ".$server_name, source => $THIS_FILE, line => __LINE__});
@ -472,7 +472,7 @@ DELETED - Marks a server as no longer existing
new_name => $server_name, new_name => $server_name,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0004", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0004", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0004", message_variables => $variables, set_by => $THIS_FILE }); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0004", variables => $variables, set_by => $THIS_FILE });
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
} }
@ -485,7 +485,7 @@ DELETED - Marks a server as no longer existing
new_state => $server_state, new_state => $server_state,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0005", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0005", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0005", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0005", variables => $variables, set_by => $THIS_FILE});
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
@ -511,7 +511,7 @@ DELETED - Marks a server as no longer existing
new_boot_time_epoch => $anvil->Convert->add_commas({number => $server_boot_time}), new_boot_time_epoch => $anvil->Convert->add_commas({number => $server_boot_time}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0008", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0008", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0008", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0008", variables => $variables, set_by => $THIS_FILE});
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
} }
@ -526,7 +526,7 @@ DELETED - Marks a server as no longer existing
new_anvil_uuid => $server_anvil_uuid, new_anvil_uuid => $server_anvil_uuid,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0009", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0009", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0009", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0009", variables => $variables, set_by => $THIS_FILE});
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
} }
@ -536,7 +536,7 @@ DELETED - Marks a server as no longer existing
my $say_user_stop = $server_user_stop eq "TRUE" ? "scan_server_alert_0010" : "scan_server_alert_0011"; my $say_user_stop = $server_user_stop eq "TRUE" ? "scan_server_alert_0010" : "scan_server_alert_0011";
my $variables = { server => $server_name }; my $variables = { server => $server_name };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => $say_user_stop, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => $say_user_stop, variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => $say_user_stop, message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => $say_user_stop, variables => $variables, set_by => $THIS_FILE});
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
} }
@ -551,7 +551,7 @@ DELETED - Marks a server as no longer existing
new_host_uuid => $server_host_uuid, new_host_uuid => $server_host_uuid,
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0012", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0012", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0012", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0012", variables => $variables, set_by => $THIS_FILE});
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
} }
@ -567,7 +567,7 @@ DELETED - Marks a server as no longer existing
new_ram_in_use_bytes => $anvil->Convert->add_commas({number => $old_server_ram_in_use}), new_ram_in_use_bytes => $anvil->Convert->add_commas({number => $old_server_ram_in_use}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0013", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0013", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0013", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0013", variables => $variables, set_by => $THIS_FILE});
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
} }
@ -584,7 +584,7 @@ DELETED - Marks a server as no longer existing
new_configured_ram_bytes => $anvil->Convert->add_commas({number => $old_server_configured_ram}), new_configured_ram_bytes => $anvil->Convert->add_commas({number => $old_server_configured_ram}),
}; };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => $say_ram, variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => $say_ram, variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => $say_ram, message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => $say_ram, variables => $variables, set_by => $THIS_FILE});
$update = 1; $update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update => $update }});
} }
@ -720,7 +720,7 @@ WHERE
# Now register an alert. # Now register an alert.
my $variables = { server => $server_name }; my $variables = { server => $server_name };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0007", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_alert_0007", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0007", message_variables => $variables, set_by => $THIS_FILE}); $anvil->Alert->register({alert_level => "notice", message => "scan_server_alert_0007", variables => $variables, set_by => $THIS_FILE});
} }
} }

File diff suppressed because it is too large Load Diff

@ -0,0 +1,640 @@
-- This is the database schema for the 'storcli Scan Agent'.
--
-- Things that change rarely should go in the main tables (even if we won't explicitely watch for them
-- to change with specific alerts).
-- ------------------------------------------------------------------------------------------------------- --
-- Adapter --
-- ------------------------------------------------------------------------------------------------------- --
-- Here is the basic controller information. All connected devices will reference back to this table's
-- 'storcli_controller_serial_number' column.
-- Key variables;
-- - "ROC temperature"
CREATE TABLE scan_storcli_controllers (
scan_storcli_controller_uuid uuid not null primary key,
scan_storcli_controller_host_uuid uuid not null,
scan_storcli_controller_serial_number text not null, -- This is the core identifier
scan_storcli_controller_model text not null, -- "model"
scan_storcli_controller_alarm_state text not null, -- "alarm_state"
scan_storcli_controller_cache_size numeric not null, -- "on_board_memory_size"
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_storcli_controller_host_uuid) REFERENCES hosts(host_uuid)
);
ALTER TABLE scan_storcli_controllers OWNER TO admin;
CREATE TABLE history.scan_storcli_controllers (
history_id bigserial,
scan_storcli_controller_uuid uuid,
scan_storcli_controller_host_uuid uuid,
scan_storcli_controller_serial_number text,
scan_storcli_controller_model text,
scan_storcli_controller_alarm_state text,
scan_storcli_controller_cache_size numeric,
modified_date timestamp with time zone
);
ALTER TABLE history.scan_storcli_controllers OWNER TO admin;
CREATE FUNCTION history_scan_storcli_controllers() RETURNS trigger
AS $$
DECLARE
history_scan_storcli_controllers RECORD;
BEGIN
SELECT INTO history_scan_storcli_controllers * FROM scan_storcli_controllers WHERE scan_storcli_controller_uuid=new.scan_storcli_controller_uuid;
INSERT INTO history.scan_storcli_controllers
(scan_storcli_controller_uuid,
scan_storcli_controller_host_uuid,
scan_storcli_controller_serial_number,
scan_storcli_controller_model,
scan_storcli_controller_alarm_state,
scan_storcli_controller_cache_size,
modified_date)
VALUES
(history_scan_storcli_controllers.scan_storcli_controller_uuid,
history_scan_storcli_controllers.scan_storcli_controller_host_uuid,
history_scan_storcli_controllers.scan_storcli_controller_serial_number,
history_scan_storcli_controllers.scan_storcli_controller_model,
history_scan_storcli_controllers.scan_storcli_controller_alarm_state,
history_scan_storcli_controllers.scan_storcli_controller_cache_size,
history_scan_storcli_controllers.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_scan_storcli_controllers() OWNER TO admin;
CREATE TRIGGER trigger_scan_storcli_controllers
AFTER INSERT OR UPDATE ON scan_storcli_controllers
FOR EACH ROW EXECUTE PROCEDURE history_scan_storcli_controllers();
-- ------------------------------------------------------------------------------------------------------- --
-- Cachevault --
-- ------------------------------------------------------------------------------------------------------- --
-- Key variables;
-- - "Temperature"
-- - "Capacitance"
-- - "Pack Energy"
-- - "Next Learn time"
-- This records the basic information about the cachevault (FBU) unit.
CREATE TABLE scan_storcli_cachevaults (
scan_storcli_cachevault_uuid uuid not null primary key,
scan_storcli_cachevault_host_uuid uuid not null,
scan_storcli_cachevault_controller_uuid uuid not null,
scan_storcli_cachevault_serial_number text not null, -- "Serial Number"
scan_storcli_cachevault_state text not null, -- "State"
scan_storcli_cachevault_design_capacity text not null, -- "Design Capacity"
scan_storcli_cachevault_replacement_needed text not null, -- "Replacement required"
scan_storcli_cachevault_type text not null, -- "Type"
scan_storcli_cachevault_model text not null, -- "Device Name"
scan_storcli_cachevault_manufacture_date text not null, -- "Date of Manufacture"
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_storcli_cachevault_host_uuid) REFERENCES hosts(host_uuid),
FOREIGN KEY(scan_storcli_cachevault_controller_uuid) REFERENCES scan_storcli_controllers(scan_storcli_controller_uuid)
);
ALTER TABLE scan_storcli_cachevaults OWNER TO admin;
CREATE TABLE history.scan_storcli_cachevaults (
history_id bigserial,
scan_storcli_cachevault_uuid uuid,
scan_storcli_cachevault_host_uuid uuid,
scan_storcli_cachevault_controller_uuid uuid,
scan_storcli_cachevault_serial_number text,
scan_storcli_cachevault_state text,
scan_storcli_cachevault_design_capacity text,
scan_storcli_cachevault_replacement_needed text,
scan_storcli_cachevault_type text,
scan_storcli_cachevault_model text,
scan_storcli_cachevault_manufacture_date text,
modified_date timestamp with time zone
);
ALTER TABLE history.scan_storcli_cachevaults OWNER TO admin;
CREATE FUNCTION history_scan_storcli_cachevaults() RETURNS trigger
AS $$
DECLARE
history_scan_storcli_cachevaults RECORD;
BEGIN
SELECT INTO history_scan_storcli_cachevaults * FROM scan_storcli_cachevaults WHERE scan_storcli_cachevault_uuid=new.scan_storcli_cachevault_uuid;
INSERT INTO history.scan_storcli_cachevaults
(scan_storcli_cachevault_uuid,
scan_storcli_cachevault_host_uuid,
scan_storcli_cachevault_controller_uuid,
scan_storcli_cachevault_serial_number,
scan_storcli_cachevault_state,
scan_storcli_cachevault_design_capacity,
scan_storcli_cachevault_replacement_needed,
scan_storcli_cachevault_type,
scan_storcli_cachevault_model,
scan_storcli_cachevault_manufacture_date,
modified_date)
VALUES
(history_scan_storcli_cachevaults.scan_storcli_cachevault_uuid,
history_scan_storcli_cachevaults.scan_storcli_cachevault_host_uuid,
history_scan_storcli_cachevaults.scan_storcli_cachevault_controller_uuid,
history_scan_storcli_cachevaults.scan_storcli_cachevault_serial_number,
history_scan_storcli_cachevaults.scan_storcli_cachevault_state,
history_scan_storcli_cachevaults.scan_storcli_cachevault_design_capacity,
history_scan_storcli_cachevaults.scan_storcli_cachevault_replacement_needed,
history_scan_storcli_cachevaults.scan_storcli_cachevault_type,
history_scan_storcli_cachevaults.scan_storcli_cachevault_model,
history_scan_storcli_cachevaults.scan_storcli_cachevault_manufacture_date,
history_scan_storcli_cachevaults.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_scan_storcli_cachevaults() OWNER TO admin;
CREATE TRIGGER trigger_scan_storcli_cachevaults
AFTER INSERT OR UPDATE ON scan_storcli_cachevaults
FOR EACH ROW EXECUTE PROCEDURE history_scan_storcli_cachevaults();
-- ------------------------------------------------------------------------------------------------------- --
-- Battery Backup Units --
-- ------------------------------------------------------------------------------------------------------- --
-- Key variables;
-- - "Temperature"
-- - "Absolute state of charge"
-- - "Cycle Count"
-- - "Full Charge Capacity"
-- - "Fully Charged"
-- - "Learn Cycle Active"
-- - "Next Learn time"
-- - "Over Charged"
-- - "Over Temperature"
-- This records the basic information about the cachevault (FBU) unit.
CREATE TABLE scan_storcli_bbus (
scan_storcli_bbu_uuid uuid not null primary key,
scan_storcli_bbu_host_uuid uuid not null,
scan_storcli_bbu_controller_uuid uuid not null,
scan_storcli_bbu_serial_number text not null, -- "Serial Number"
scan_storcli_bbu_type text not null, -- "Type"
scan_storcli_bbu_model text not null, -- "Manufacture Name"
scan_storcli_bbu_state text not null, -- "Battery State"
scan_storcli_bbu_manufacture_date text not null, -- "Date of Manufacture"
scan_storcli_bbu_design_capacity text not null, -- "Design Capacity"
scan_storcli_bbu_replacement_needed text not null, -- "Pack is about to fail & should be replaced"
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_storcli_bbu_host_uuid) REFERENCES hosts(host_uuid),
FOREIGN KEY(scan_storcli_bbu_controller_uuid) REFERENCES scan_storcli_controllers(scan_storcli_controller_uuid)
);
ALTER TABLE scan_storcli_bbus OWNER TO admin;
CREATE TABLE history.scan_storcli_bbus (
history_id bigserial,
scan_storcli_bbu_uuid uuid,
scan_storcli_bbu_host_uuid uuid,
scan_storcli_bbu_controller_uuid uuid,
scan_storcli_bbu_serial_number text,
scan_storcli_bbu_type text,
scan_storcli_bbu_model text,
scan_storcli_bbu_state text,
scan_storcli_bbu_manufacture_date text,
scan_storcli_bbu_design_capacity text,
scan_storcli_bbu_replacement_needed text,
modified_date timestamp with time zone
);
ALTER TABLE history.scan_storcli_bbus OWNER TO admin;
CREATE FUNCTION history_scan_storcli_bbus() RETURNS trigger
AS $$
DECLARE
history_scan_storcli_bbus RECORD;
BEGIN
SELECT INTO history_scan_storcli_bbus * FROM scan_storcli_bbus WHERE scan_storcli_bbu_uuid=new.scan_storcli_bbu_uuid;
INSERT INTO history.scan_storcli_bbus
(scan_storcli_bbu_uuid,
scan_storcli_bbu_host_uuid,
scan_storcli_bbu_controller_uuid,
scan_storcli_bbu_serial_number,
scan_storcli_bbu_type,
scan_storcli_bbu_model,
scan_storcli_bbu_state,
scan_storcli_bbu_manufacture_date,
scan_storcli_bbu_design_capacity,
scan_storcli_bbu_replacement_needed,
modified_date)
VALUES
(history_scan_storcli_bbus.scan_storcli_bbu_uuid,
history_scan_storcli_bbus.scan_storcli_bbu_host_uuid,
history_scan_storcli_bbus.scan_storcli_bbu_controller_uuid,
history_scan_storcli_bbus.scan_storcli_bbu_serial_number,
history_scan_storcli_bbus.scan_storcli_bbu_type,
history_scan_storcli_bbus.scan_storcli_bbu_model,
history_scan_storcli_bbus.scan_storcli_bbu_state,
history_scan_storcli_bbus.scan_storcli_bbu_manufacture_date,
history_scan_storcli_bbus.scan_storcli_bbu_design_capacity,
history_scan_storcli_bbus.scan_storcli_bbu_replacement_needed,
history_scan_storcli_bbus.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_scan_storcli_bbus() OWNER TO admin;
CREATE TRIGGER trigger_scan_storcli_bbus
AFTER INSERT OR UPDATE ON scan_storcli_bbus
FOR EACH ROW EXECUTE PROCEDURE history_scan_storcli_bbus();
-- ------------------------------------------------------------------------------------------------------- --
-- Virtual Drives --
-- ------------------------------------------------------------------------------------------------------- --
-- This records the basic virtual drives. These contain one or more drive groups to form an array
CREATE TABLE scan_storcli_virtual_drives (
scan_storcli_virtual_drive_uuid uuid not null primary key,
scan_storcli_virtual_drive_host_uuid uuid not null,
scan_storcli_virtual_drive_controller_uuid uuid not null,
scan_storcli_virtual_drive_id_string text not null, -- This is '<host_controller_sn>-vd<x>' where 'x' is the virtual drive number.
scan_storcli_virtual_drive_creation_date text not null, -- "Creation Date" and "Creation Time"
scan_storcli_virtual_drive_data_protection text not null, -- "Data Protection"
scan_storcli_virtual_drive_disk_cache_policy text not null, -- "Disk Cache Policy"
scan_storcli_virtual_drive_emulation_type text not null, -- "Emulation type"
scan_storcli_virtual_drive_encryption text not null, -- "Encryption"
scan_storcli_virtual_drive_blocks numeric not null, -- "Number of Blocks"
scan_storcli_virtual_drive_strip_size text not null, -- "Strip Size" (has the suffix 'Bytes', so not numeric)
scan_storcli_virtual_drive_drives_per_span numeric not null, -- "Number of Drives Per Span"
scan_storcli_virtual_drive_span_depth numeric not null, -- "Span Depth"
scan_storcli_virtual_drive_scsi_naa_id text not null, -- "SCSI NAA Id" - https://en.wikipedia.org/wiki/ISCSI#Addressing
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_storcli_virtual_drive_host_uuid) REFERENCES hosts(host_uuid),
FOREIGN KEY(scan_storcli_virtual_drive_controller_uuid) REFERENCES scan_storcli_controllers(scan_storcli_controller_uuid)
);
ALTER TABLE scan_storcli_virtual_drives OWNER TO admin;
CREATE TABLE history.scan_storcli_virtual_drives (
history_id bigserial,
scan_storcli_virtual_drive_uuid uuid,
scan_storcli_virtual_drive_host_uuid uuid,
scan_storcli_virtual_drive_controller_uuid uuid,
scan_storcli_virtual_drive_id_string text,
scan_storcli_virtual_drive_creation_date text,
scan_storcli_virtual_drive_data_protection text,
scan_storcli_virtual_drive_disk_cache_policy text,
scan_storcli_virtual_drive_emulation_type text,
scan_storcli_virtual_drive_encryption text,
scan_storcli_virtual_drive_blocks numeric,
scan_storcli_virtual_drive_strip_size text,
scan_storcli_virtual_drive_drives_per_span numeric,
scan_storcli_virtual_drive_span_depth numeric,
scan_storcli_virtual_drive_scsi_naa_id text,
modified_date timestamp with time zone
);
ALTER TABLE history.scan_storcli_virtual_drives OWNER TO admin;
CREATE FUNCTION history_scan_storcli_virtual_drives() RETURNS trigger
AS $$
DECLARE
history_scan_storcli_virtual_drives RECORD;
BEGIN
SELECT INTO history_scan_storcli_virtual_drives * FROM scan_storcli_virtual_drives WHERE scan_storcli_virtual_drive_uuid=new.scan_storcli_virtual_drive_uuid;
INSERT INTO history.scan_storcli_virtual_drives
(scan_storcli_virtual_drive_uuid,
scan_storcli_virtual_drive_host_uuid,
scan_storcli_virtual_drive_controller_uuid,
scan_storcli_virtual_drive_id_string,
scan_storcli_virtual_drive_creation_date,
scan_storcli_virtual_drive_data_protection,
scan_storcli_virtual_drive_disk_cache_policy,
scan_storcli_virtual_drive_emulation_type,
scan_storcli_virtual_drive_encryption,
scan_storcli_virtual_drive_blocks,
scan_storcli_virtual_drive_strip_size,
scan_storcli_virtual_drive_drives_per_span,
scan_storcli_virtual_drive_span_depth,
scan_storcli_virtual_drive_scsi_naa_id,
modified_date)
VALUES
(history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_uuid,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_host_uuid,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_controller_uuid,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_id_string,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_creation_date,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_data_protection,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_disk_cache_policy,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_emulation_type,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_encryption,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_blocks,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_strip_size,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_drives_per_span,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_span_depth,
history_scan_storcli_virtual_drives.scan_storcli_virtual_drive_scsi_naa_id,
history_scan_storcli_virtual_drives.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_scan_storcli_virtual_drives() OWNER TO admin;
CREATE TRIGGER trigger_scan_storcli_virtual_drives
AFTER INSERT OR UPDATE ON scan_storcli_virtual_drives
FOR EACH ROW EXECUTE PROCEDURE history_scan_storcli_virtual_drives();
-- ------------------------------------------------------------------------------------------------------- --
-- Drive Groups --
-- ------------------------------------------------------------------------------------------------------- --
-- This records the basic drive group information.
CREATE TABLE scan_storcli_drive_groups (
scan_storcli_drive_group_uuid uuid not null primary key,
scan_storcli_drive_group_host_uuid uuid not null,
scan_storcli_drive_group_virtual_drive_uuid uuid not null,
scan_storcli_drive_group_id_string text not null, -- This is '<host_controller_sn>-vd<x>-dg<y>' where 'x' is the virtual drive number and 'y' is the drive group number.
scan_storcli_drive_group_access text not null, -- "access"
scan_storcli_drive_group_array_size text not null, -- "array_size"
scan_storcli_drive_group_array_state text not null, -- "array_state"
scan_storcli_drive_group_cache text not null, -- "cache"
scan_storcli_drive_group_cachecade text not null, -- "cachecade"
scan_storcli_drive_group_consistent text not null, -- "consistent"
scan_storcli_drive_group_disk_cache text not null, -- "disk_cache"
scan_storcli_drive_group_raid_type text not null, -- "raid_type"
scan_storcli_drive_group_read_cache text not null, -- "read_cache"
scan_storcli_drive_group_scheduled_cc text not null, -- "scheduled_consistency_check"
scan_storcli_drive_group_write_cache text not null, -- "write_cache"
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_storcli_drive_group_host_uuid) REFERENCES hosts(host_uuid),
FOREIGN KEY(scan_storcli_drive_group_virtual_drive_uuid) REFERENCES scan_storcli_virtual_drives(scan_storcli_virtual_drive_uuid)
);
ALTER TABLE scan_storcli_drive_groups OWNER TO admin;
CREATE TABLE history.scan_storcli_drive_groups (
history_id bigserial,
scan_storcli_drive_group_uuid uuid,
scan_storcli_drive_group_host_uuid uuid,
scan_storcli_drive_group_virtual_drive_uuid uuid,
scan_storcli_drive_group_id_string text,
scan_storcli_drive_group_access text,
scan_storcli_drive_group_array_size text,
scan_storcli_drive_group_array_state text,
scan_storcli_drive_group_cache text,
scan_storcli_drive_group_cachecade text,
scan_storcli_drive_group_consistent text,
scan_storcli_drive_group_disk_cache text,
scan_storcli_drive_group_raid_type text,
scan_storcli_drive_group_read_cache text,
scan_storcli_drive_group_scheduled_cc text,
scan_storcli_drive_group_write_cache text,
modified_date timestamp with time zone
);
ALTER TABLE history.scan_storcli_drive_groups OWNER TO admin;
CREATE FUNCTION history_scan_storcli_drive_groups() RETURNS trigger
AS $$
DECLARE
history_scan_storcli_drive_groups RECORD;
BEGIN
SELECT INTO history_scan_storcli_drive_groups * FROM scan_storcli_drive_groups WHERE scan_storcli_drive_group_uuid=new.scan_storcli_drive_group_uuid;
INSERT INTO history.scan_storcli_drive_groups
(scan_storcli_drive_group_uuid,
scan_storcli_drive_group_host_uuid,
scan_storcli_drive_group_virtual_drive_uuid,
scan_storcli_drive_group_id_string,
scan_storcli_drive_group_access,
scan_storcli_drive_group_array_size,
scan_storcli_drive_group_array_state,
scan_storcli_drive_group_cache,
scan_storcli_drive_group_cachecade,
scan_storcli_drive_group_consistent,
scan_storcli_drive_group_disk_cache,
scan_storcli_drive_group_raid_type,
scan_storcli_drive_group_read_cache,
scan_storcli_drive_group_scheduled_cc,
scan_storcli_drive_group_write_cache,
modified_date)
VALUES
(history_scan_storcli_drive_groups.scan_storcli_drive_group_uuid,
history_scan_storcli_drive_groups.scan_storcli_drive_group_host_uuid,
history_scan_storcli_drive_groups.scan_storcli_drive_group_virtual_drive_uuid,
history_scan_storcli_drive_groups.scan_storcli_drive_group_id_string,
history_scan_storcli_drive_groups.scan_storcli_drive_group_access,
history_scan_storcli_drive_groups.scan_storcli_drive_group_array_size,
history_scan_storcli_drive_groups.scan_storcli_drive_group_array_state,
history_scan_storcli_drive_groups.scan_storcli_drive_group_cache,
history_scan_storcli_drive_groups.scan_storcli_drive_group_cachecade,
history_scan_storcli_drive_groups.scan_storcli_drive_group_consistent,
history_scan_storcli_drive_groups.scan_storcli_drive_group_disk_cache,
history_scan_storcli_drive_groups.scan_storcli_drive_group_raid_type,
history_scan_storcli_drive_groups.scan_storcli_drive_group_read_cache,
history_scan_storcli_drive_groups.scan_storcli_drive_group_scheduled_cc,
history_scan_storcli_drive_groups.scan_storcli_drive_group_write_cache,
history_scan_storcli_drive_groups.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_scan_storcli_drive_groups() OWNER TO admin;
CREATE TRIGGER trigger_scan_storcli_drive_groups
AFTER INSERT OR UPDATE ON scan_storcli_drive_groups
FOR EACH ROW EXECUTE PROCEDURE history_scan_storcli_drive_groups();
-- ------------------------------------------------------------------------------------------------------- --
-- Physical Drives --
-- ------------------------------------------------------------------------------------------------------- --
-- NOTE: More information to T10-PI (protection information) is available here:
-- https://www.seagate.com/files/staticfiles/docs/pdf/whitepaper/safeguarding-data-from-corruption-technology-paper-tp621us.pdf
-- This records the basic drive group information.
-- Key variables;
-- - "Drive Temperature"
-- - "spun_up"
-- - "state"
-- - "Certified"
-- - "Device Speed"
-- - "Link Speed"
-- - "sas_port_0_link_speed"
-- - "sas_port_0_port_status"
-- - "sas_port_0_sas_address"
-- - "sas_port_1_link_speed"
-- - "sas_port_1_port_status"
-- - "sas_port_1_sas_address"
-- - "drive_media"
-- - "interface"
-- - "NAND Vendor"
-- - "Firmware Revision"
-- - "World Wide Name"
-- - "device_id"
-- - "SED Enabled"
-- - "Secured"
-- - "Locked"
-- - "Needs External Key Management Attention"
-- - "protection_info", "Protection Information Eligible"
-- - "Emergency Spare"
-- - "Commissioned Spare"
-- - "S.M.A.R.T alert flagged by drive"
-- - "Media Error Count"
-- - "Other Error Count"
-- - "Predictive Failure Count"
CREATE TABLE scan_storcli_physical_drives (
scan_storcli_physical_drive_uuid uuid not null primary key,
scan_storcli_physical_drive_host_uuid uuid not null,
scan_storcli_physical_drive_controller_uuid uuid not null,
scan_storcli_physical_drive_virtual_drive text not null,
scan_storcli_physical_drive_drive_group text not null,
scan_storcli_physical_drive_enclosure_id text not null,
scan_storcli_physical_drive_slot_number text not null,
scan_storcli_physical_drive_serial_number text not null, -- "Serial Number"
scan_storcli_physical_drive_size text not null, -- In 'text' because of 'Bytes' suffix - "drive_size" but also; "Raw size", "Non Coerced size" and "Coerced size"
scan_storcli_physical_drive_sector_size text not null, -- In 'text' because of 'Bytes' suffix - "sector_size", "Sector Size"
scan_storcli_physical_drive_vendor text not null, -- "Manufacturer Identification"
scan_storcli_physical_drive_model text not null, -- "drive_model", "Model Number"
scan_storcli_physical_drive_self_encrypting_drive text not null, -- "self_encrypting_drive", "SED Capable"
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_storcli_physical_drive_host_uuid) REFERENCES hosts(host_uuid),
FOREIGN KEY(scan_storcli_physical_drive_controller_uuid) REFERENCES scan_storcli_controllers(scan_storcli_controller_uuid)
);
ALTER TABLE scan_storcli_physical_drives OWNER TO admin;
CREATE TABLE history.scan_storcli_physical_drives (
history_id bigserial,
scan_storcli_physical_drive_uuid uuid,
scan_storcli_physical_drive_host_uuid uuid,
scan_storcli_physical_drive_controller_uuid uuid,
scan_storcli_physical_drive_serial_number text,
scan_storcli_physical_drive_virtual_drive text,
scan_storcli_physical_drive_drive_group text,
scan_storcli_physical_drive_enclosure_id text,
scan_storcli_physical_drive_slot_number text,
scan_storcli_physical_drive_size text,
scan_storcli_physical_drive_sector_size text,
scan_storcli_physical_drive_vendor text,
scan_storcli_physical_drive_model text,
scan_storcli_physical_drive_self_encrypting_drive text,
modified_date timestamp with time zone
);
ALTER TABLE history.scan_storcli_physical_drives OWNER TO admin;
CREATE FUNCTION history_scan_storcli_physical_drives() RETURNS trigger
AS $$
DECLARE
history_scan_storcli_physical_drives RECORD;
BEGIN
SELECT INTO history_scan_storcli_physical_drives * FROM scan_storcli_physical_drives WHERE scan_storcli_physical_drive_uuid=new.scan_storcli_physical_drive_uuid;
INSERT INTO history.scan_storcli_physical_drives
(scan_storcli_physical_drive_uuid,
scan_storcli_physical_drive_host_uuid,
scan_storcli_physical_drive_controller_uuid,
scan_storcli_physical_drive_virtual_drive,
scan_storcli_physical_drive_drive_group,
scan_storcli_physical_drive_enclosure_id,
scan_storcli_physical_drive_slot_number,
scan_storcli_physical_drive_serial_number,
scan_storcli_physical_drive_size,
scan_storcli_physical_drive_sector_size,
scan_storcli_physical_drive_vendor,
scan_storcli_physical_drive_model,
scan_storcli_physical_drive_self_encrypting_drive,
modified_date)
VALUES
(history_scan_storcli_physical_drives.scan_storcli_physical_drive_uuid,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_host_uuid,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_controller_uuid,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_virtual_drive,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_drive_group,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_enclosure_id,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_slot_number,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_serial_number,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_size,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_sector_size,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_vendor,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_model,
history_scan_storcli_physical_drives.scan_storcli_physical_drive_self_encrypting_drive,
history_scan_storcli_physical_drives.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_scan_storcli_physical_drives() OWNER TO admin;
CREATE TRIGGER trigger_scan_storcli_physical_drives
AFTER INSERT OR UPDATE ON scan_storcli_physical_drives
FOR EACH ROW EXECUTE PROCEDURE history_scan_storcli_physical_drives();
-- ------------------------------------------------------------------------------------------------------- --
-- Each data type has several variables that we're not storing in the component-specific tables. To do so --
-- would be to create massive tables that would miss variables not shown for all controllers or when new --
-- variables are added or renamed. So this table is used to store all those myriade of variables. Each --
-- entry will reference the table it is attached to and the UUID of the record in that table. The column --
-- 'storcli_variable_is_temperature' will be used to know what data is a temperature and will be then used --
-- to inform on the host's thermal health. --
-- ------------------------------------------------------------------------------------------------------- --
-- This stores various variables found for a given controller but not explicitely checked for (or that
-- change frequently).
CREATE TABLE scan_storcli_variables (
scan_storcli_variable_uuid uuid not null primary key,
scan_storcli_variable_host_uuid uuid not null,
scan_storcli_variable_source_table text not null,
scan_storcli_variable_source_uuid uuid not null,
scan_storcli_variable_is_temperature boolean not null default FALSE,
scan_storcli_variable_name text not null,
scan_storcli_variable_value text not null,
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_storcli_variable_host_uuid) REFERENCES hosts(host_uuid)
);
ALTER TABLE scan_storcli_variables OWNER TO admin;
CREATE TABLE history.scan_storcli_variables (
history_id bigserial,
scan_storcli_variable_uuid uuid,
scan_storcli_variable_host_uuid uuid,
scan_storcli_variable_source_table text,
scan_storcli_variable_source_uuid uuid,
scan_storcli_variable_is_temperature boolean,
scan_storcli_variable_name text,
scan_storcli_variable_value text,
modified_date timestamp with time zone
);
ALTER TABLE history.scan_storcli_variables OWNER TO admin;
CREATE FUNCTION history_scan_storcli_variables() RETURNS trigger
AS $$
DECLARE
history_scan_storcli_variables RECORD;
BEGIN
SELECT INTO history_scan_storcli_variables * FROM scan_storcli_variables WHERE scan_storcli_variable_uuid=new.scan_storcli_variable_uuid;
INSERT INTO history.scan_storcli_variables
(scan_storcli_variable_uuid,
scan_storcli_variable_host_uuid,
scan_storcli_variable_source_table,
scan_storcli_variable_source_uuid,
scan_storcli_variable_is_temperature,
scan_storcli_variable_name,
scan_storcli_variable_value,
modified_date)
VALUES
(history_scan_storcli_variables.scan_storcli_variable_uuid,
history_scan_storcli_variables.scan_storcli_variable_host_uuid,
history_scan_storcli_variables.scan_storcli_variable_source_table,
history_scan_storcli_variables.scan_storcli_variable_source_uuid,
history_scan_storcli_variables.scan_storcli_variable_is_temperature,
history_scan_storcli_variables.scan_storcli_variable_name,
history_scan_storcli_variables.scan_storcli_variable_value,
history_scan_storcli_variables.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_scan_storcli_variables() OWNER TO admin;
CREATE TRIGGER trigger_scan_storcli_variables
AFTER INSERT OR UPDATE ON scan_storcli_variables
FOR EACH ROW EXECUTE PROCEDURE history_scan_storcli_variables();

File diff suppressed because it is too large Load Diff

@ -1,43 +1,37 @@
#!/usr/bin/perl #!/usr/bin/perl
# #
use strict;
use warnings; use warnings;
use Anvil::Tools; use strict;
use Data::Dumper;
use String::ShellQuote;
use utf8;
binmode(STDERR, ':encoding(utf-8)');
binmode(STDOUT, ':encoding(utf-8)');
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0]; my $sysstat_directory = "/var/log/sa/";
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0]; my $hostname = `hostname | cut -f 1 -d .`;
if (($running_directory =~ /^\./) && ($ENV{PWD}))
{
$running_directory =~ s/^\./$ENV{PWD}/;
}
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete. opendir(my $directory_handle, $sysstat_directory) || die "Can't locate ".$sysstat_directory."\n";
$| = 1;
my $anvil = Anvil::Tools->new(); my @file_list = grep { /^sa[0-9]./ } readdir($directory_handle);
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
$anvil->data->{switches}{'shutdown'} = ""; printf "Hostname is ... ".$hostname."\n";
$anvil->data->{switches}{boot} = ""; foreach my $filename (sort {$a cmp $b} @file_list)
$anvil->data->{switches}{server} = ""; {
$anvil->Get->switches; #printf "Filepath: ....".$sysstat_directory.$filepath."\n"
my $shell_call = "sadf -dht ".$sysstat_directory.$filename." -- -S -u -r -p -q -n DEV";
printf "Shell Call - ... ".$shell_call."\n";
open(my $file_handle, "$shell_call 2>&1 |") || die "Failed to parse output of [".$shell_call."].\n";
while (<$file_handle>)
{
chomp;
my $csv_line = $_;
print "Connecting to the database(s);\n"; if ($csv_line =~ /$hostname/)
$anvil->Database->connect({debug => 3}); {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, secure => 0, key => "log_0132"}); #printf "CSV Line... ".$csv_line."\n";
printf "Variable Match!\n";
}
if ($csv_line =~ 'thinkpad-06HCV0')
{
printf "String Match!\n";
}
}
my $agent = "scan-apc-ups";
my $schema_file = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.".sql";
my $tables = $anvil->Database->get_tables_from_schema({debug => 2, schema_file => $schema_file});
print "Schema file: [".$schema_file."]\n";
foreach my $table (@{$tables})
{
print "- ".$table."\n";
} }
Loading…
Cancel
Save