From 1d03a386d3c2949b779e04184ff611a965b2b266 Mon Sep 17 00:00:00 2001 From: Digimer Date: Wed, 23 Dec 2020 01:10:23 -0500 Subject: [PATCH] * Created Database->get_bridges() that, surprise, loads data from the 'bridges' table. * Started work on Get->available_resources() that will take an 'anvil_uuid' and figure out what resources are still available for use by new servers or that can be added to existing servers. * Fixed a bug in ScanCore->agent_startup() where tables weren't being generated properly from the agent's SQL file. * Made Storage->change_mode() return silently if it's called without a mode being passed. This happens frequently and is harmless so it's not worth filling the logs with errors. * Renamed the 'start_time' key to 'at_start' when recording files' MD5 sums in Storage->record_md5sums and ->check_md5sums. * When we moved the directory scan logic out of the 'scancore' daemon and into 'Storage->scan_directory', the logic to record scan agent names in 'scancore::agent::' was removed. This broke a few things and, so, it was restored when it was found that a file starts with 'scan-' and the directory matches the scancore agent directory. * Moved the 'scancore' daemon's 'load_agent_strings' to 'Words' * Updated Words->parse_banged_string() to look for variables in the format 'value=X:units=Y' and translate it properly. * Fixed a bug in scan-ipmitool where discovered sensor INSERT SQL queries were queued, but not committed. * Fixed a bug in scan-storcli where a while loop was broken, preventing execution. * Fixed a bug in the 'scancore' daemon where it wouldn't exit if sums changed. Fixed a bug where alerts weren't being sent between loops. Fixed a bug where command-line log level wasn't surviving inside the main loop. Signed-off-by: Digimer --- Anvil/Tools/Database.pm | 118 ++++++++++++++++- Anvil/Tools/Email.pm | 12 +- Anvil/Tools/Get.pm | 102 +++++++++++++++ Anvil/Tools/ScanCore.pm | 12 +- Anvil/Tools/Storage.pm | 137 +++++++++++--------- Anvil/Tools/Striker.pm | 1 + Anvil/Tools/System.pm | 1 + Anvil/Tools/Words.pm | 68 ++++++++++ ocf/alteeve/server | 11 +- scancore-agents/scan-apc-pdu/scan-apc-pdu | 6 +- scancore-agents/scan-drbd/scan-drbd | 2 +- scancore-agents/scan-hardware/scan-hardware | 12 +- scancore-agents/scan-ipmitool/scan-ipmitool | 27 ++-- scancore-agents/scan-storcli/scan-storcli | 25 ++-- share/words.xml | 16 ++- tools/anvil-join-anvil | 8 +- tools/scancore | 53 +++----- tools/test.pl | 31 +---- 18 files changed, 453 insertions(+), 189 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index d5da2fe9..f747f5dc 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -24,6 +24,7 @@ my $THIS_FILE = "Database.pm"; # disconnect # get_alerts # get_anvils +# get_bridges # get_fences # get_host_from_uuid # get_hosts @@ -2054,6 +2055,115 @@ WHERE } +=head2 get_bridges + +This loads the known bridge devices into the C<< anvil::data >> hash at: + +* bridges::bridge_host_uuid::::bridge_uuid::::bridge_name +* bridges::bridge_host_uuid::::bridge_uuid::::bridge_id +* bridges::bridge_host_uuid::::bridge_uuid::::bridge_mac_address +* bridges::bridge_host_uuid::::bridge_uuid::::bridge_mtu +* bridges::bridge_host_uuid::::bridge_uuid::::bridge_stp_enabled +* bridges::bridge_host_uuid::::bridge_uuid::::modified_date + +And, to allow for lookup by name; + +* bridges::bridge_host_uuid::::bridge_name::::bridge_uuid + +If the hash was already populated, it is cleared before repopulating to ensure no stale data remains. + +B<>: Deleted bridges (ones where C<< bridge_id >> is set to C<< DELETED >>) are ignored. See the C<< include_deleted >> parameter to include them. + +Parameters; + +=head3 include_deleted (Optional, default 0) + +If set to C<< 1 >>, deleted bridges are included when loading the data. When C<< 0 >> is set, the default, any bridges with C<< bridge_id >> set to C<< DELETED >> are ignored. + +=cut +sub get_bridges +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_bridges()" }}); + + my $include_deleted = defined $parameter->{include_deleted} ? $parameter->{include_deleted} : 0; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + include_deleted => $include_deleted, + }}); + + if (exists $anvil->data->{bridges}) + { + delete $anvil->data->{bridges}; + } + + my $query = " +SELECT + bridge_uuid, + bridge_host_uuid, + bridge_name, + bridge_id, + bridge_mac_address, + bridge_mtu, + bridge_stp_enabled, + modified_date +FROM + bridges "; + if (not $include_deleted) + { + $query .= " +WHERE + bridge_id != 'DELETED'"; + } + $query .= " +;"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); + my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); + my $count = @{$results}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + results => $results, + count => $count, + }}); + foreach my $row (@{$results}) + { + my $bridge_uuid = $row->[0]; + my $bridge_host_uuid = $row->[1]; + my $bridge_name = $row->[2]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + bridge_uuid => $bridge_uuid, + bridge_host_uuid => $bridge_host_uuid, + bridge_name => $bridge_name, + }}); + + # Record the data in the hash, too. + $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_uuid}{$bridge_uuid}{bridge_name} = $bridge_name; + $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_uuid}{$bridge_uuid}{bridge_id} = $row->[3]; + $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_uuid}{$bridge_uuid}{bridge_mac_address} = $row->[4]; + $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_uuid}{$bridge_uuid}{bridge_mtu} = $row->[5]; + $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_uuid}{$bridge_uuid}{bridge_stp_enabled} = $row->[6]; + $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_uuid}{$bridge_uuid}{modified_date} = $row->[7]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "bridges::bridge_host_uuid::${bridge_host_uuid}::bridge_uuid::${bridge_uuid}::bridge_name" => $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_uuid}{$bridge_uuid}{bridge_name}, + "bridges::bridge_host_uuid::${bridge_host_uuid}::bridge_uuid::${bridge_uuid}::bridge_id" => $anvil->data->{bridges}{bridge_uuid}{$bridge_uuid}{bridge_id}, + "bridges::bridge_host_uuid::${bridge_host_uuid}::bridge_uuid::${bridge_uuid}::bridge_mac_address" => $anvil->data->{bridges}{bridge_uuid}{$bridge_uuid}{bridge_mac_address}, + "bridges::bridge_host_uuid::${bridge_host_uuid}::bridge_uuid::${bridge_uuid}::bridge_mtu" => $anvil->data->{bridges}{bridge_uuid}{$bridge_uuid}{bridge_mtu}, + "bridges::bridge_host_uuid::${bridge_host_uuid}::bridge_uuid::${bridge_uuid}::bridge_stp_enabled" => $anvil->data->{bridges}{bridge_uuid}{$bridge_uuid}{bridge_stp_enabled}, + "bridges::bridge_host_uuid::${bridge_host_uuid}::bridge_uuid::${bridge_uuid}::modified_date" => $anvil->data->{bridges}{bridge_uuid}{$bridge_uuid}{modified_date}, + }}); + + # Make it easier to look up by bridge name. + $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_name}{$bridge_name}{bridge_uuid} = $bridge_uuid; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "bridges::bridge_host_uuid::${bridge_host_uuid}::bridge_name::${bridge_name}::bridge_uuid" => $anvil->data->{bridges}{bridge_host_uuid}{$bridge_host_uuid}{bridge_name}{$bridge_name}{bridge_uuid}, + }}); + } + + return(0); +} + + =head2 get_fences This loads the known fence devices into the C<< anvil::data >> hash at: @@ -2070,7 +2180,7 @@ And, to allow for lookup by name; * fences::fence_name::::fence_arguments * fences::fence_name::::modified_date -If the hash was already populated, it is cleared before repopulating to ensure no stray data remains. +If the hash was already populated, it is cleared before repopulating to ensure no stale data remains. B<>: Deleted devices (ones where C<< fence_arguments >> is set to C<< DELETED >>) are ignored. See the C<< include_deleted >> parameter to include them. @@ -3224,7 +3334,7 @@ And, to allow for lookup by name; * manifests::manifest_name::::manifest_note * manifests::manifest_name::::modified_date -If the hash was already populated, it is cleared before repopulating to ensure no stray data remains. +If the hash was already populated, it is cleared before repopulating to ensure no stale data remains. B<>: Deleted devices (ones where C<< manifest_note >> is set to C<< DELETED >>) are ignored. See the C<< include_deleted >> parameter to include them. @@ -3906,7 +4016,7 @@ And, to allow for lookup by name; B<< Note >>: The C<< modified_date >> is cast as a unix time stamp. -If the hash was already populated, it is cleared before repopulating to ensure no stray data remains. +If the hash was already populated, it is cleared before repopulating to ensure no stale data remains. This method takes no parameters. @@ -4009,7 +4119,7 @@ And, to allow for lookup by name; * upses::ups_name::::modified_date * upses::ups_name::::power_uuid -If the hash was already populated, it is cleared before repopulating to ensure no stray data remains. +If the hash was already populated, it is cleared before repopulating to ensure no stale data remains. B<>: Deleted devices (ones where C<< ups_ip_address >> is set to C<< DELETED >>) are ignored. See the C<< include_deleted >> parameter to include them. diff --git a/Anvil/Tools/Email.pm b/Anvil/Tools/Email.pm index 3e4c2bfb..9be790ee 100755 --- a/Anvil/Tools/Email.pm +++ b/Anvil/Tools/Email.pm @@ -386,8 +386,9 @@ sub send_alerts } # Load the alerts - $anvil->Database->get_alerts({debug => 2}); - $anvil->Database->get_recipients({debug => 2}); + $anvil->Database->get_alerts({debug => $debug}); + $anvil->Database->get_recipients({debug => $debug}); + my $host_uuid = $anvil->Get->host_uuid; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host_uuid => $host_uuid }}); foreach my $alert_uuid (keys %{$anvil->data->{alerts}{alert_uuid}}) @@ -447,10 +448,14 @@ sub send_alerts key_string => $alert_message, }); + # A lot of multi-line strings start with an opening new line. This removes that. + $message =~ s/^\n//; + $message =~ s/\n$//s; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { message => $message }}); if ($alert_title) { - my $title = $anvil->Words->parse_banged_string({ + my $title = "[ ".$alert_set_by." ] ".$anvil->Words->parse_banged_string({ language => $recipient_language, key_string => $alert_title, @@ -528,7 +533,6 @@ sub send_alerts }); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { footer => $footer }}); - ### TODO: Determine if any of the sorts need to be reversed # Build the message body now. my $body = ""; foreach my $alert_sort_position (sort {$a cmp $b} keys %{$anvil->data->{alerts}{queue}{$recipient_uuid}}) diff --git a/Anvil/Tools/Get.pm b/Anvil/Tools/Get.pm index b796acb0..dc8a82d9 100644 --- a/Anvil/Tools/Get.pm +++ b/Anvil/Tools/Get.pm @@ -18,6 +18,7 @@ my $THIS_FILE = "Get.pm"; ### Methods; # anvil_name_from_uuid # anvil_version +# available_resources # bridges # cgi # date_and_time @@ -311,6 +312,107 @@ fi; return($version); } + +=head2 available_resources + + +Parameters; + +=head3 anvil_uuid (required) + +This is the Anvil! UUID for which we're getting available resources from. + +=cut +sub available_resources +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->available_resources()" }}); + + my $anvil_uuid = defined $parameter->{anvil_uuid} ? $parameter->{anvil_uuid} : ""; + + if (not $anvil_uuid) + { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Get->available_resources()", parameter => "anvil_uuid" }}); + return("!!error!!"); + } + + # Get the node UUIDs for this anvil. + my $query = " +SELECT + anvil_name, + anvil_node1_host_uuid, + anvil_node2_host_uuid, + anvil_dr1_host_uuid +FROM + anvils +WHERE + anvil_uuid = ".$anvil->Database->quote($anvil_uuid)." +;"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); + my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); + my $count = @{$results}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + results => $results, + count => $count, + }}); + if (not $count) + { + # Not found. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0169", variables => { anvil_uuid => $anvil_uuid }}); + return("!!error!!"); + } + + # Load data + $anvil->Database->get_hosts({debug => $debug}); + $anvil->Database->get_bridges({debug => $debug}); + + # Get the details. + my $anvil_name = $results->[0]->[0]; + my $node1_host_uuid = $results->[0]->[1]; + my $node2_host_uuid = $results->[0]->[2]; + my $dr1_host_uuid = $results->[0]->[3]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + anvil_name => $anvil_name, + node1_host_uuid => $node1_host_uuid, + node2_host_uuid => $node2_host_uuid, + dr1_host_uuid => $dr1_host_uuid, + }}); + + foreach my $host_uuid ($node1_host_uuid, $node2_host_uuid, $dr1_host_uuid) + { + # Start collecting data. + my $host_name = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_name}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + host_uuid => $host_uuid, + host_name => $host_name, + }}); + + # Gather bridge data. + foreach my $bridge_name (sort {$a cmp $b} keys %{$anvil->data->{bridges}{bridge_host_uuid}{$host_uuid}{bridge_name}}) + { + my $bridge_uuid = $anvil->data->{bridges}{bridge_host_uuid}{$host_uuid}{bridge_name}{$bridge_name}{bridge_uuid}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + bridge_uuid => $bridge_uuid, + bridge_name => $bridge_name, + }}); + + if (not exists $anvil->data->{anvil_resources}{$anvil_uuid}{bridges}{$bridge_name}) + { + $anvil->data->{anvil_resources}{$anvil_uuid}{bridges}{$bridge_name}{on} = []; + } + push @{$anvil->data->{anvil_resources}{$anvil_uuid}{bridges}{$bridge_name}{on}}, $host_uuid; + } + + # Get the CPU and RAM data + } + + return(0); +} + + =head2 bridges This finds a list of bridges on the host. Bridges that are found are stored is ' diff --git a/Anvil/Tools/ScanCore.pm b/Anvil/Tools/ScanCore.pm index 8eeb8611..663b48f2 100755 --- a/Anvil/Tools/ScanCore.pm +++ b/Anvil/Tools/ScanCore.pm @@ -117,14 +117,10 @@ sub agent_startup tables => $tables, }}); - if (not $agent) - { - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "ScanCore->agent_startup()", parameter => "agent" }}); - return("!!error!!"); - } if ((not $tables) or (ref($tables) ne "ARRAY")) { my $schema_file = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.".sql"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { schema_file => $schema_file }}); if (-e $schema_file) { $tables = $anvil->Database->get_tables_from_schema({debug => $debug, schema_file => $schema_file}); @@ -136,6 +132,7 @@ sub agent_startup } else { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { schema_file => $schema_file }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "ScanCore->agent_startup()", parameter => "tables" }}); return("!!error!!"); } @@ -254,6 +251,7 @@ sub call_scan_agents $timeout = $anvil->data->{scancore}{$agent_name}{timeout}; } my $shell_call = $agent_path; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'sys::log::level' => $anvil->data->{sys}{'log'}{level} }}); if ($anvil->data->{sys}{'log'}{level}) { $shell_call .= " ".$anvil->data->{sys}{'log'}{level}; @@ -261,7 +259,7 @@ sub call_scan_agents $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }}); # Tell the user this agent is about to run... - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => $debug, key => "log_0252", variables => { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0252", variables => { agent_name => $agent_name, timeout => $timeout, }}); @@ -271,7 +269,7 @@ sub call_scan_agents { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }}); } - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => $debug, key => "log_0557", variables => { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0557", variables => { agent_name => $agent_name, runtime => (time - $start_time), return_code => $return_code, diff --git a/Anvil/Tools/Storage.pm b/Anvil/Tools/Storage.pm index 7b4ca8c0..048fc0d7 100644 --- a/Anvil/Tools/Storage.pm +++ b/Anvil/Tools/Storage.pm @@ -374,7 +374,7 @@ sub change_mode my $password = defined $parameter->{password} ? $parameter->{password} : ""; my $remote_user = defined $parameter->{remote_user} ? $parameter->{remote_user} : "root"; my $target = defined $parameter->{target} ? $parameter->{target} : ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { mode => $mode, path => $path, port => $port, @@ -383,56 +383,52 @@ sub change_mode remote_user => $remote_user, }}); - my $error = 0; + # This is often called without a mode, just return if that's the case. + if (not $mode) + { + return(0); + } + if (not $path) { # No path... $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Storage->change_mode()", parameter => "path" }}); - $error = 1; + return('!!error!!'); } - if (not $mode) - { - # No mode... - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Storage->change_mode()", parameter => "mode" }}); - $error = 1; - } - elsif (($mode !~ /^\d\d\d$/) && ($mode !~ /^\d\d\d\d$/) && ($mode !~ /^\w\+\w$/) && ($mode !~ /^\w\-\w$/)) + if (($mode !~ /^\d\d\d$/) && ($mode !~ /^\d\d\d\d$/) && ($mode !~ /^\w\+\w$/) && ($mode !~ /^\w\-\w$/)) { # Invalid mode $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0038", variables => { mode => $mode }}); - $error = 1; + return('!!error!!'); } - if (not $error) + my $shell_call = $anvil->data->{path}{exe}{'chmod'}." $mode $path"; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0011", variables => { shell_call => $shell_call }}); + if ($anvil->Network->is_local({host => $target})) { - my $shell_call = $anvil->data->{path}{exe}{'chmod'}." $mode $path"; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0011", variables => { shell_call => $shell_call }}); - if ($anvil->Network->is_local({host => $target})) - { - # Local call - my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - output => $output, - return_code => $return_code, - }}); - } - else - { - # Remote call. - my ($output, $error, $return_code) = $anvil->Remote->call({ - debug => $debug, - shell_call => $shell_call, - target => $target, - port => $port, - password => $password, - remote_user => $remote_user, - }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - error => $error, - output => $output, - return_code => $return_code, - }}); - } + # Local call + my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + output => $output, + return_code => $return_code, + }}); + } + else + { + # Remote call. + my ($output, $error, $return_code) = $anvil->Remote->call({ + debug => $debug, + shell_call => $shell_call, + target => $target, + port => $port, + password => $password, + remote_user => $remote_user, + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + error => $error, + output => $output, + return_code => $return_code, + }}); } return(0); @@ -596,17 +592,17 @@ sub check_md5sums # Have we changed? $anvil->data->{md5sum}{$caller}{now} = $anvil->Get->md5sum({file => $0}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "md5sum::${caller}::start_time" => $anvil->data->{md5sum}{$caller}{start_time}, - "md5sum::${caller}::now" => $anvil->data->{md5sum}{$caller}{now}, + "md5sum::${caller}::at_start" => $anvil->data->{md5sum}{$caller}{at_start}, + "md5sum::${caller}::now" => $anvil->data->{md5sum}{$caller}{now}, }}); - if ($anvil->data->{md5sum}{$caller}{start_time} ne $anvil->data->{md5sum}{$caller}{now}) + if ($anvil->data->{md5sum}{$caller}{at_start} ne $anvil->data->{md5sum}{$caller}{now}) { # Exit. $exit = 1; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0250", variables => { file => $0, - old_sum => $anvil->data->{md5sum}{$caller}{start_time}, + old_sum => $anvil->data->{md5sum}{$caller}{at_start}, new_sum => $anvil->data->{md5sum}{$caller}{now}, }}); } @@ -624,26 +620,26 @@ sub check_md5sums }}); # Is this the first time I've seen this module? - if (not defined $anvil->data->{md5sum}{$module_file}{start_time}) + if (not defined $anvil->data->{md5sum}{$module_file}{at_start}) { # New one! - $anvil->data->{md5sum}{$module_file}{start_time} = $module_sum; + $anvil->data->{md5sum}{$module_file}{at_start} = $module_sum; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "md5sum::${module_file}::start_time" => $anvil->data->{md5sum}{$module_file}{start_time}, + "md5sum::${module_file}::at_start" => $anvil->data->{md5sum}{$module_file}{at_start}, }}); } $anvil->data->{md5sum}{$module_file}{now} = $module_sum; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "md5sum::${module_file}::start_time" => $anvil->data->{md5sum}{$module_file}{start_time}, - "md5sum::${module_file}::now" => $anvil->data->{md5sum}{$module_file}{now}, + "md5sum::${module_file}::at_start" => $anvil->data->{md5sum}{$module_file}{at_start}, + "md5sum::${module_file}::now" => $anvil->data->{md5sum}{$module_file}{now}, }}); - if ($anvil->data->{md5sum}{$module_file}{start_time} ne $anvil->data->{md5sum}{$module_file}{now}) + if ($anvil->data->{md5sum}{$module_file}{at_start} ne $anvil->data->{md5sum}{$module_file}{now}) { # Changed. $exit = 1; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0250", variables => { file => $module_file, - old_sum => $anvil->data->{md5sum}{$module_file}{start_time}, + old_sum => $anvil->data->{md5sum}{$module_file}{at_start}, new_sum => $anvil->data->{md5sum}{$module_file}{now}, }}); } @@ -660,15 +656,15 @@ sub check_md5sums $anvil->data->{md5sum}{$file}{now} = $words_sum; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "md5sum::${file}::start_time" => $anvil->data->{md5sum}{$file}{start_time}, - "md5sum::${file}::now" => $anvil->data->{md5sum}{$file}{now}, + "md5sum::${file}::at_start" => $anvil->data->{md5sum}{$file}{at_start}, + "md5sum::${file}::now" => $anvil->data->{md5sum}{$file}{now}, }}); - if ($anvil->data->{md5sum}{$file}{start_time} ne $anvil->data->{md5sum}{$file}{now}) + if ($anvil->data->{md5sum}{$file}{at_start} ne $anvil->data->{md5sum}{$file}{now}) { $exit = 1; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0250", variables => { file => $file, - old_sum => $anvil->data->{md5sum}{$file}{start_time}, + old_sum => $anvil->data->{md5sum}{$file}{at_start}, new_sum => $anvil->data->{md5sum}{$file}{now}, }}); } @@ -2410,9 +2406,9 @@ sub record_md5sums $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->record_md5sums()" }}); # Record the caller's MD5 sum - my $caller = $0; - $anvil->data->{md5sum}{$caller}{start_time} = $anvil->Get->md5sum({file => $0}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "md5sum::${caller}::start_time" => $anvil->data->{md5sum}{$caller}{start_time} }}); + my $caller = $0; + $anvil->data->{md5sum}{$caller}{at_start} = $anvil->Get->md5sum({file => $0}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "md5sum::${caller}::at_start" => $anvil->data->{md5sum}{$caller}{at_start} }}); # Record the sums of our perl modules. foreach my $module (sort {$a cmp $b} keys %INC) @@ -2425,8 +2421,8 @@ sub record_md5sums module_sum => $module_sum, }}); - $anvil->data->{md5sum}{$module_file}{start_time} = $module_sum; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "md5sum::${module_file}::start_time" => $anvil->data->{md5sum}{$module_file}{start_time} }}); + $anvil->data->{md5sum}{$module_file}{at_start} = $module_sum; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "md5sum::${module_file}::at_start" => $anvil->data->{md5sum}{$module_file}{at_start} }}); } # Record sum(s) for the words file(s). @@ -2438,8 +2434,8 @@ sub record_md5sums words_sum => $words_sum, }}); - $anvil->data->{md5sum}{$file}{start_time} = $words_sum; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "md5sum::${file}::start_time" => $anvil->data->{md5sum}{$file}{start_time} }}); + $anvil->data->{md5sum}{$file}{at_start} = $words_sum; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "md5sum::${file}::at_start" => $anvil->data->{md5sum}{$file}{at_start} }}); } return(0); @@ -2697,6 +2693,10 @@ If the file is an actual file, the following information is set; scan::directories::::mimetype = mimetype> scan::directories::::executable = '0' or '1' +B<< Note >>: If the directory being scanned in the scan agent directory, and the file is executable and starts with c<< scan- >>, the file will be treated as a scan agent and stored in the special hash: + +* scancore::agent:: = + Parameters; =head3 directory (required) @@ -2739,6 +2739,9 @@ sub scan_directory search_for => $search_for, }}); + # This is used for storing scan agents we've found, when appropriate. + my $scan_agent_directory = $anvil->data->{path}{directories}{scan_agents}; + # Setup the search variable, if needed. $anvil->data->{scan}{searched} = "" if not exists $anvil->data->{scan}{searched}; @@ -2838,6 +2841,16 @@ sub scan_directory "scan::directories::${full_path}::mimetype" => $anvil->data->{scan}{directories}{$full_path}{mimetype}, "scan::directories::${full_path}::executable" => $anvil->data->{scan}{directories}{$full_path}{executable}, }}); + + # If this is a scan agent, we'll store info about it in a special hash. + if ((-x $full_path) && ($file =~ /^scan-/) && ($full_path =~ /^$scan_agent_directory/)) + { + # Found a scan agent. + $anvil->data->{scancore}{agent}{$file} = $full_path; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "scancore::agent::${file}" => $anvil->data->{scancore}{agent}{$file}, + }}); + } } } closedir(DIRECTORY); diff --git a/Anvil/Tools/Striker.pm b/Anvil/Tools/Striker.pm index 449d23b1..d2b2a683 100644 --- a/Anvil/Tools/Striker.pm +++ b/Anvil/Tools/Striker.pm @@ -231,6 +231,7 @@ sub generate_manifest return($manifest_uuid, $anvil_name); } + =head2 get_fence_data This parses the unified metadata file from the avaialable fence_devices on this host. If the unified file (location stored in C<< path::data::fences_unified_metadata >>, default is C<< /tmp/fences_unified_metadata.xml >> is not found or fails to parse, C<< 1 >> is returned. If the file is successfully parsed. C<< 0 >> is returned. diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index 8be8440e..79ae3f2e 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -1267,6 +1267,7 @@ sub collect_ipmi_data # Write the password to a temp file. $temp_file = "/tmp/scancore.".$anvil->Get->uuid({short => 1}); $anvil->Storage->write_file({ + debug => 2, body => $ipmi_password, secure => 1, file => $temp_file, diff --git a/Anvil/Tools/Words.pm b/Anvil/Tools/Words.pm index 5763928d..adeaf3dd 100644 --- a/Anvil/Tools/Words.pm +++ b/Anvil/Tools/Words.pm @@ -22,6 +22,7 @@ my $THIS_FILE = "Words.pm"; # key # language # language_list +# load_agent_strings # parse_banged_string # read # shorten_string @@ -315,6 +316,50 @@ sub language_list return(9); } +=head2 load_agent_strings + +This loads the strings from all the ScanCore scan agents on this system. + +The method takes no parameters. + +=cut +sub load_agent_strings +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "path::directories::scan_agents" => $anvil->data->{path}{directories}{scan_agents}, + }}); + $anvil->Storage->scan_directory({ + debug => $debug, + directory => $anvil->data->{path}{directories}{scan_agents}, + recursive => 1, + }); + + # Now loop through the agents I found and call them. + foreach my $agent_name (sort {$a cmp $b} keys %{$anvil->data->{scancore}{agent}}) + { + my $agent_words = $anvil->data->{scancore}{agent}{$agent_name}.".xml"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { agent_words => $agent_words }}); + + if ((-e $agent_words) && (-r $agent_words)) + { + # Read the words file. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0251", variables => { + agent_name => $agent_name, + file => $agent_words, + }}); + $anvil->Words->read({file => $agent_words}); + } + } + + return(0); +} + + =head2 parse_banged_string This takes a string (usually from a DB record) in the format C<< [,!!var1!value1!!,!!var2!value2!!,...,!!varN!valueN!! >> and converts it into an actual string. @@ -459,6 +504,29 @@ sub parse_banged_string } else { + ### TODO: If we ever decide to support imperial measurements or other + ### forms of hyrogliphics, here's where we'll do it. + # Some variables are encoded with 'value=X:units=Y'. In those cases, + if ($value =~ /value=(.*?):units=(.*)$/) + { + my $this_value = $1; + my $this_unit = $2; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + this_value => $this_value, + this_unit => $this_unit, + }}); + + if ((uc($this_unit) eq "V") or ($this_unit =~ /Volt/i)) { $value = $this_value." #!string!unit_0033!#"; } + elsif ((uc($this_unit) eq "W") or ($this_unit =~ /Watt/i)) { $value = $this_value." #!string!unit_0034!#"; } + elsif (uc($this_unit) eq "RPM") { $value = $this_value." #!string!unit_0035!#"; } + elsif (uc($this_unit) eq "C") { $value = $this_value." #!string!unit_0036!#"; } + elsif (uc($this_unit) eq "F") { $value = $this_value." #!string!unit_0037!#"; } + elsif ($this_unit eq "%") { $value = $this_value." #!string!unit_0038!#"; } + elsif ((uc($this_unit) eq "A") or ($this_unit =~ /Amp/i)) { $value = $this_value." #!string!unit_0039!#"; } + else { $value = $this_value." ".$this_unit; } + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { value => $value }}); + } + # Record the variable/value pair $variables->{$variable} = $value; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "variables->$variable" => $variables->{$variable} }}); diff --git a/ocf/alteeve/server b/ocf/alteeve/server index 15f57963..8691c1eb 100755 --- a/ocf/alteeve/server +++ b/ocf/alteeve/server @@ -1143,7 +1143,7 @@ pmsuspended - The domain has been suspended by guest power management, e.g. ente { # Wait. $loop = 1; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0525"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0525", variables => { server_name => $server }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { loop => $loop }}); sleep 2; @@ -1152,13 +1152,16 @@ pmsuspended - The domain has been suspended by guest power management, e.g. ente elsif ($state eq "shut off") { # Exit with OCF_NOT_RUNNING (rc: 7); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0526"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0526", variables => { server_name => $server }}); $anvil->nice_exit({exit_code => 7}); } else { # In some fashion or another, the server is running. Exit with OCF_SUCCESS (rc: 0) - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0527", variables => { 'state' => $state }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0527", variables => { + 'state' => $state, + server_name => $server, + }}); $anvil->nice_exit({exit_code => 0}); } } @@ -1168,7 +1171,7 @@ pmsuspended - The domain has been suspended by guest power management, e.g. ente if (not $found) { # Exit with OCF_NOT_RUNNING (rc: 7); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0526"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0526", variables => { server_name => $server }}); $anvil->nice_exit({exit_code => 7}); } } diff --git a/scancore-agents/scan-apc-pdu/scan-apc-pdu b/scancore-agents/scan-apc-pdu/scan-apc-pdu index 8e73bc59..ae065612 100755 --- a/scancore-agents/scan-apc-pdu/scan-apc-pdu +++ b/scancore-agents/scan-apc-pdu/scan-apc-pdu @@ -933,10 +933,10 @@ WHERE old_total_wattage_draw => $old_total_wattage_draw, new_total_wattage_draw => $new_total_wattage_draw, }; - $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_0020", variables => $variables}); $anvil->Alert->register({ - alert_level => "warning", - message => "scan_apc_pdu_message_0009", + alert_level => "notice", + message => "scan_apc_pdu_message_0020", variables => $variables, set_by => $THIS_FILE, sort_position => $anvil->data->{'scan-apc-pdu'}{alert_sort}++, diff --git a/scancore-agents/scan-drbd/scan-drbd b/scancore-agents/scan-drbd/scan-drbd index e35e3c07..19cb95b7 100755 --- a/scancore-agents/scan-drbd/scan-drbd +++ b/scancore-agents/scan-drbd/scan-drbd @@ -73,7 +73,7 @@ if (($anvil->data->{scancore}{'scan-drbd'}{disable}) && (not $anvil->data->{swit } # Handle start-up tasks -my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); +my $problem = $anvil->ScanCore->agent_startup({debug => 2, agent => $THIS_FILE}); if ($problem) { $anvil->nice_exit({exit_code => 1}); diff --git a/scancore-agents/scan-hardware/scan-hardware b/scancore-agents/scan-hardware/scan-hardware index 09a6cd36..ffa4062b 100755 --- a/scancore-agents/scan-hardware/scan-hardware +++ b/scancore-agents/scan-hardware/scan-hardware @@ -959,7 +959,7 @@ sub find_changes say_swap => $say_swap, 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' => 0, level => 1, key => "scan_hardware_alert_0020", variables => $variables}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0020", variables => $variables, set_by => $THIS_FILE }); } } @@ -983,7 +983,7 @@ sub find_changes say_swap => $say_swap, swap_percent => $new_swap_percent_used, }; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_hardware_alert_0021", variables => $variables}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 1, key => "scan_hardware_alert_0021", variables => $variables}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0021", variables => $variables, set_by => $THIS_FILE }); } } @@ -1142,7 +1142,7 @@ INSERT INTO old_model => $old_scan_hardware_ram_module_model, 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' => 0, level => 1, key => "scan_hardware_alert_0023", variables => $variables}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0023", variables => $variables, set_by => $THIS_FILE}); } else @@ -1159,7 +1159,7 @@ INSERT INTO old_model => $old_scan_hardware_ram_module_model, 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' => 0, level => 1, key => "scan_hardware_alert_0024", variables => $variables}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0024", variables => $variables, set_by => $THIS_FILE}); } @@ -1191,7 +1191,7 @@ WHERE model => $new_scan_hardware_ram_module_model, 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' => 0, level => 2, key => "scan_hardware_alert_0025", variables => $variables}); $anvil->Alert->register({alert_level => "notice", message => "scan_hardware_alert_0025", variables => $variables, set_by => $THIS_FILE}); # INSERT @@ -1256,7 +1256,7 @@ INSERT INTO old_model => $old_scan_hardware_ram_module_model, 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' => 0, level => 2, key => "scan_hardware_alert_0026", variables => $variables}); $anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0026", variables => $variables, set_by => $THIS_FILE}); my $query = " diff --git a/scancore-agents/scan-ipmitool/scan-ipmitool b/scancore-agents/scan-ipmitool/scan-ipmitool index f66810ec..64dd2fdb 100755 --- a/scancore-agents/scan-ipmitool/scan-ipmitool +++ b/scancore-agents/scan-ipmitool/scan-ipmitool @@ -733,10 +733,8 @@ INSERT INTO $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); push @{$anvil->data->{'scan-ipmitool'}{queries}}, $query; - # TODO: Use the following variable/value pairs to have the sensor - # name and value translated/converted to imperial as needed. - my $sensor_name = "name=$scan_ipmitool_sensor_name:units=$new_scan_ipmitool_sensor_units"; - my $sensor_value = "value=$new_scan_ipmitool_value_sensor_value:units=$new_scan_ipmitool_sensor_units"; + my $sensor_name = "name=".$scan_ipmitool_sensor_name.":units=".$new_scan_ipmitool_sensor_units; + my $sensor_value = "value=".$new_scan_ipmitool_value_sensor_value.":units=".$new_scan_ipmitool_sensor_units; my $message_key = "scan_ipmitool_message_0019"; my $level = "notice"; my $variables = { @@ -763,8 +761,8 @@ INSERT INTO my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-ipmitool'}{alert_sort}++; 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->Alert->register({alert_level => $level, message => "scan_ipmitool_message_0019", variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); + $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, variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); } } } @@ -881,8 +879,8 @@ INSERT INTO # We need to let ScanCore translate the sensor data into a string for each # user and their prefered language and units. As such, we're going to use a # couple special variable strings for this. - my $sensor_name = "name=$scan_ipmitool_sensor_name:units=$new_scan_ipmitool_sensor_units"; - my $sensor_value = "value=$new_scan_ipmitool_value_sensor_value:units=$new_scan_ipmitool_sensor_units"; + my $sensor_name = "name=".$scan_ipmitool_sensor_name.":units=".$new_scan_ipmitool_sensor_units; + my $sensor_value = "value=".$new_scan_ipmitool_value_sensor_value.":units=".$new_scan_ipmitool_sensor_units; # If the sensor is not 'ok', set a warning level alert. my $level = "notice"; @@ -895,7 +893,7 @@ INSERT INTO my $variables = { host_name => $host_name, - sensor => $scan_ipmitool_sensor_name, + sensor_name => $scan_ipmitool_sensor_name, sensor_value => $sensor_value, sensor_status => $new_scan_ipmitool_sensor_status, high_critical => $new_scan_ipmitool_sensor_high_critical eq "" ? "--" : $new_scan_ipmitool_sensor_high_critical." ".$new_scan_ipmitool_sensor_units, @@ -905,8 +903,8 @@ INSERT INTO }; my $sort_position = $level eq "warning" ? 1 : $anvil->data->{'scan-ipmitool'}{alert_sort}++; 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->Alert->register({alert_level => $level, message => "scan_ipmitool_message_0019", variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); + $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, variables => $variables, set_by => $THIS_FILE, sort_position => $sort_position}); } } @@ -921,6 +919,10 @@ INSERT INTO } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "sys::scanning_myself" => $anvil->data->{sys}{scanning_myself} }}); + # Now commit the changes. + $anvil->Database->write({debug => 2, query => $anvil->data->{'scan-ipmitool'}{queries}, source => $THIS_FILE, line => __LINE__}); + $anvil->data->{'scan-ipmitool'}{queries} = []; + ### Now add, update and delete 'temperature' entries. process_temperature($anvil, $host_name); @@ -928,9 +930,6 @@ INSERT INTO check_sensor_health($anvil, $host_name); } - # Now commit the changes. - $anvil->Database->write({query => $anvil->data->{'scan-ipmitool'}{queries}, source => $THIS_FILE, line => __LINE__}); - return(0); } diff --git a/scancore-agents/scan-storcli/scan-storcli b/scancore-agents/scan-storcli/scan-storcli index 3b70fb9b..536d070d 100755 --- a/scancore-agents/scan-storcli/scan-storcli +++ b/scancore-agents/scan-storcli/scan-storcli @@ -661,18 +661,21 @@ AND } # Now, if any undeleted old entries remain, delete them from the database. - foreach my $serial_number (sort {$a cmp $b} keys %{$anvil->data->{old}{temperature}{$variable}}) + foreach my $variable (sort {$a cmp $b} keys %{$anvil->data->{old}{temperature}}) { - my $temperature_uuid = $anvil->data->{old}{temperature}{$variable}{$serial_number}{temperature_uuid}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { temperature_uuid => $temperature_uuid }}); - - $temperature_uuid = $anvil->Database->insert_or_update_temperature({ - cache => $anvil->data->{'scan-storcli'}{queries}, - debug => 2, - 'delete' => 1, - temperature_uuid => $temperature_uuid, - }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { temperature_uuid => $temperature_uuid }}); + foreach my $serial_number (sort {$a cmp $b} keys %{$anvil->data->{old}{temperature}{$variable}}) + { + my $temperature_uuid = $anvil->data->{old}{temperature}{$variable}{$serial_number}{temperature_uuid}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { temperature_uuid => $temperature_uuid }}); + + $temperature_uuid = $anvil->Database->insert_or_update_temperature({ + cache => $anvil->data->{'scan-storcli'}{queries}, + debug => 2, + 'delete' => 1, + temperature_uuid => $temperature_uuid, + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { temperature_uuid => $temperature_uuid }}); + } } # Commit the queries. diff --git a/share/words.xml b/share/words.xml index d58f5e38..4f98805e 100644 --- a/share/words.xml +++ b/share/words.xml @@ -241,6 +241,7 @@ The error was: The resource: [#!variable!resource!#] in the config file: [#!variable!file!#] was found, but does not appear to be a valid UUID: [#!variable!uuid!#]. The resource: [#!variable!resource!#] in the config file: [#!variable!file!#] was found, and we were asked to replace the 'scan_drbd_resource_uuid' but the new UUID: [#!variable!uuid!#] is not a valud UUID. The 'fence_ipmilan' command: [#!variable!command!#] does not appear to be valid. + The Anvil! UUID: [#!variable!anvil_uuid!#] doesn't appear to exist in the database. Current Network Interfaces and States @@ -1035,9 +1036,9 @@ The file: [#!variable!file!#] needs to be updated. The difference is: The 'libvirtd' daemon is not running. It may be starting up, will wait: [#!variable!wait_time!#] seconds... Found the server to be running using it's PID. The state of the server can't be determined, however. Please start the 'libvirtd' daemon! No PID for the server was found. It is not running on this host. - The server is shutting down. Will wait for it to finish... - The server is off. - The server is running (state is: [#!variable!state!#]). + The server: [#!variable!server_name!#] is shutting down. Will wait for it to finish... + The server: [#!variable!server_name!#] is off. + The server: [#!variable!server_name!#] is running (state is: [#!variable!state!#]). We've been asked to migrating the server: [#!variable!server!#] to: [#!variable!target_host!#]. Checking server state after: [#!variable!server!#] was migrated to this host. Updating the postfix relay password file: [#!data!path::configs::postfix_relay_password!#]. @@ -1071,7 +1072,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is: #!variable!difference!# ==== - Scan agent: [#!variable!agent_name!#] exited after: [#!variable!runtime!#] seconds with the return code: [#!variable!return_code!#]. + - Scan agent: [#!variable!agent_name!#] exited after: [#!variable!runtime!#] seconds with the return code: [#!variable!return_code!#]. I'm not on the same network as: [#!variable!host_name!#]. Unable to check the power state. The host: [#!variable!host_name!#] appears to be off, but there's no IPMI information, so unable to check the power state or power on the machine. The host: [#!variable!host_name!#] has no IPMI information. Wouldn't be able to boot it, even if it's off, so skipping it. @@ -1802,6 +1803,13 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st Down Mbps waiting for job output... + Volts + Watts + RPM + Celsius + Fahrenheit + % + Amps