* Updated scan-storcli to check if a MegaRAID controlled exists and neither storcli64 or perccli64 exist. If a controller is found but no RPM is installed, it checks to see if the host is Dell and then decides to try and install perccli or storcli.

* Reworked scan-ipimitool so that on nodes and dr hosts, it only scans itself. On strikers, it scans all hosts found in active Anvil! systems with a host_ipmi entry. `
* For all agents, reduced log verbosity to not push too much noise into anvil.log while scancore is running in the background.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 50d529e07c
commit 8d0f873912
  1. 1
      Anvil/Tools.pm
  2. 2
      Anvil/Tools/Database.pm
  3. 6
      Anvil/Tools/Get.pm
  4. 14
      scancore-agents/scan-apc-pdu/scan-apc-pdu
  5. 8
      scancore-agents/scan-apc-ups/scan-apc-ups
  6. 8
      scancore-agents/scan-cluster/scan-cluster
  7. 6
      scancore-agents/scan-drbd/scan-drbd
  8. 12
      scancore-agents/scan-hardware/scan-hardware
  9. 145
      scancore-agents/scan-ipmitool/scan-ipmitool
  10. 6
      scancore-agents/scan-lvm/scan-lvm
  11. 8
      scancore-agents/scan-server/scan-server
  12. 117
      scancore-agents/scan-storcli/scan-storcli
  13. 3
      scancore-agents/scan-storcli/scan-storcli.xml
  14. 2
      share/anvil.sql
  15. 4
      tools/scancore

@ -1145,6 +1145,7 @@ sub _set_paths
journalctl => "/usr/bin/journalctl",
logger => "/usr/bin/logger",
ls => "/usr/bin/ls",
lspci => "/usr/sbin/lspci",
lsblk => "/usr/bin/lsblk",
lvchange => "/usr/sbin/lvchange",
lvcreate => "/usr/sbin/lvcreate",

@ -1252,7 +1252,7 @@ sub connect
average_time => $average_time,
}});
my $ping_time = tv_interval ($start_time, [gettimeofday]);
#my $ping_time = tv_interval ($start_time, [gettimeofday]);
#print "[".$ping_time."] - Pinged: [$host:$port:$name:$user]\n";
if (not $pinged)

@ -1479,7 +1479,11 @@ sub free_memory
=head2 host_type
This method tries to determine the host type and returns a value suitable for use is the C<< hosts >> table.
This method tries to determine the host type and returns a value suitable for use is the C<< hosts >> table. Returned values are;
striker - Striker dashboards
node - Anvil! nodes (active protection of VMs)
dr - DR Hosts (passive DR host targets)
my $type = $anvil->Get->host_type();

@ -75,9 +75,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@ -159,7 +157,7 @@ $anvil->data->{snmp} = {
};
$anvil->Storage->read_config();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->Get->switches;
@ -883,7 +881,7 @@ WHERE
if ($new_uptime > $old_uptime)
{
# 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 => 2, key => "scan_apc_pdu_message_0018", variables => $variables});
$anvil->Alert->register({
alert_level => "info",
message => "scan_apc_pdu_message_0018",
@ -933,9 +931,9 @@ 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_0020", variables => $variables});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_pdu_message_0020", variables => $variables});
$anvil->Alert->register({
alert_level => "notice",
alert_level => "info",
message => "scan_apc_pdu_message_0020",
variables => $variables,
set_by => $THIS_FILE,
@ -1035,7 +1033,7 @@ WHERE
old_phase_current_amperage => $old_scan_apc_pdu_phase_current_amperage,
new_phase_current_amperage => $new_scan_apc_pdu_phase_current_amperage,
};
$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 => 2, key => "scan_apc_pdu_message_0023", variables => $variables});
$anvil->Alert->register({
alert_level => "info",
message => "scan_apc_pdu_message_0023",

@ -40,9 +40,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@ -185,7 +183,7 @@ $anvil->data->{snmp} = {
};
$anvil->Storage->read_config();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->Get->switches;
@ -736,7 +734,7 @@ INSERT INTO
new_value => "#!string!scan_apc_ups_last_transfer_".sprintf("%04d", $say_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 => 2, key => "scan_apc_ups_warning_0015", variables => $variables});
$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)

@ -34,9 +34,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@ -69,7 +67,7 @@ if ($problem)
$anvil->nice_exit({exit_code => 1});
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_log_0001", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
if ($anvil->data->{switches}{purge})
{
# This can be called when doing bulk-database purges.
@ -85,7 +83,7 @@ my $host_type = $anvil->Get->host_type;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { host_type => $host_type }});
if ($host_type ne "node")
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_log_0002", variables => { host_type => $host_type }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_cluster_log_0002", variables => { host_type => $host_type }});
$anvil->nice_exit({exit_code => 0});
}

@ -36,9 +36,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
$anvil->data->{'scan-drbd'}{alert_sort} = 2;
$anvil->data->{'scan-drbd'}{queries} = [];
@ -75,7 +73,7 @@ if ($problem)
{
$anvil->nice_exit({exit_code => 1});
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_drbd_log_0001", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
if ($anvil->data->{switches}{purge})
{

@ -31,9 +31,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@ -54,7 +52,7 @@ $anvil->data->{scancore}{'scan-hardware'}{swap}{high_threshold} = 75;
$anvil->data->{switches}{force} = 0;
$anvil->Storage->read_config();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->Get->switches;
@ -913,15 +911,15 @@ sub find_changes
my $say_new_scan_hardware_memory_free = $anvil->Convert->bytes_to_human_readable({'bytes' => $new_scan_hardware_memory_free})." (".$anvil->Convert->add_commas({number => $new_scan_hardware_memory_free})." #!string!scan_hardware_unit_0001!#)";
my $say_old_scan_hardware_memory_free = $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_memory_free})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_memory_free})." #!string!scan_hardware_unit_0001!#)";
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "info", message => "scan_hardware_alert_0018,!!new!".$say_new_scan_hardware_memory_free."!!,!!old!".$say_old_scan_hardware_memory_free."!!"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0018", variables => { new => $say_new_scan_hardware_memory_free, old => $say_old_scan_hardware_memory_free}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_hardware_alert_0018", variables => { new => $say_new_scan_hardware_memory_free, old => $say_old_scan_hardware_memory_free}});
}
if ($new_scan_hardware_swap_free ne $old_scan_hardware_swap_free)
{
$update = 1;
$update = 1;
my $say_new_scan_hardware_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!#)";
my $say_old_scan_hardware_swap_free = $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_hardware_swap_free})." (".$anvil->Convert->add_commas({number => $old_scan_hardware_swap_free})." #!string!scan_hardware_unit_0001!#)";
$anvil->Alert->register({set_by => $THIS_FILE, alert_level => "info", message => "scan_hardware_alert_0019,!!new!".$say_new_scan_hardware_swap_free."!!,!!old!".$say_old_scan_hardware_swap_free."!!"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_hardware_alert_0019", variables => { new => $say_new_scan_hardware_swap_free, old => $say_old_scan_hardware_swap_free}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_hardware_alert_0019", variables => { new => $say_new_scan_hardware_swap_free, old => $say_old_scan_hardware_swap_free}});
my $new_swap_bytes_used = $new_scan_hardware_swap_total - $new_scan_hardware_swap_free;
my $old_swap_bytes_used = $old_scan_hardware_swap_total - $old_scan_hardware_swap_free;

@ -192,7 +192,7 @@ $anvil->data->{'scan-ipmitool'} = {
};
$anvil->Storage->read_config();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1 , key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1 , key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->data->{switches}{force} = 0;
@ -2014,10 +2014,10 @@ sub find_ipmi_targets
# If I am a node, I will only scan myself.
my $host_type = $anvil->Get->host_type();
my $hostname = $anvil->Get->host_name();
my $host_name = $anvil->Get->host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host_type => $host_type,
hostname => $hostname,
host_name => $host_name,
}});
# Do I have local IPMI access?
@ -2044,71 +2044,124 @@ sub find_ipmi_targets
}
}
# Find all known hosts (except ourself) with a host_ipmi value set.
# Which hosts we scan depends on if we're a Striker dashboard or not. If we are, we'll try to scan
# all machines in all Anvil! systems. Otherwise, we only scan ourselves.
if ($host_type ne "striker")
{
# We're not a dashboard, so we don't scan others.
return($ipmi_targets);
}
# Loop through Anvil! systems.
my $query = "
SELECT
host_name,
host_uuid,
host_ipmi
anvil_name,
anvil_node1_host_uuid,
anvil_node2_host_uuid,
anvil_dr1_host_uuid
FROM
hosts
anvils
WHERE
host_ipmi != ''
AND
host_uuid != ".$anvil->Database->quote($anvil->Get->host_uuid)."
anvil_description != 'DELETED'
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
$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__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
# We've got an entry in the 'scan_hardware' table, so now we'll look for data in the node and
# services tables.
my $host_name = $row->[0];
my $host_uuid = $row->[1];
my $host_ipmi = $row->[2];
# For each host_uuid, get the IPMI info.
my $anvil_name = $row->[0];
my $anvil_node1_host_uuid = $row->[1];
my $anvil_node2_host_uuid = $row->[2];
my $anvil_dr1_host_uuid = defined $row->[3] ? $row->[3] : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host_name => $host_name,
host_uuid => $host_uuid,
host_ipmi => $anvil->Log->is_secure($host_ipmi),
's1:anvil_name' => $anvil_name,
's2:anvil_node1_host_uuid' => $anvil_node1_host_uuid,
's3:anvil_node2_host_uuid' => $anvil_node2_host_uuid,
's4:anvil_dr1_host_uuid' => $anvil_dr1_host_uuid,
}});
# Get the ipaddress and see if I can ping the target. If I can't, there is no sense in
# recording this entry.
my $access = 0;
my $target = "";
if (($host_ipmi =~ /-a (.*?) /) or ($host_ipmi =~ /-ip (.*?) /))
my $query = "
SELECT
host_name,
host_uuid,
host_ipmi
FROM
hosts
WHERE
host_ipmi != ''
AND
(
host_uuid = ".$anvil->Database->quote($anvil_node1_host_uuid)."
OR
host_uuid = ".$anvil->Database->quote($anvil_node2_host_uuid);
if ($anvil_dr1_host_uuid)
{
$target = $1;
$query .= "
OR
host_uuid = ".$anvil->Database->quote($anvil_dr1_host_uuid);
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { target => $target }});
if ($target)
$query .= "
)
;";
$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__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
($access, my $average_time) = $anvil->Network->ping({ping => $target});
# We've got an entry in the 'scan_hardware' table, so now we'll look for data in the node and
# services tables.
my $host_name = $row->[0];
my $host_uuid = $row->[1];
my $host_ipmi = $row->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
access => $access,
average_time => $average_time,
host_name => $host_name,
host_uuid => $host_uuid,
host_ipmi => $anvil->Log->is_secure($host_ipmi),
}});
# Get the ipaddress and see if I can ping the target. If I can't, there is no sense in
# recording this entry.
my $access = 0;
my $target = "";
if (($host_ipmi =~ /-a (.*?) /) or ($host_ipmi =~ /-ip (.*?) /))
{
$target = $1;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { target => $target }});
if ($target)
{
($access, my $average_time) = $anvil->Network->ping({ping => $target});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
access => $access,
average_time => $average_time,
}});
}
next if not $access;
$ipmi_targets++;
# Convert to an 'ipmitool' call.
my ($ipmitool_command, $ipmi_password) = $anvil->Convert->fence_ipmilan_to_ipmitool({fence_ipmilan_command => $host_ipmi});
$anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{host_ipmi} = $host_ipmi;
$anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmitool_command} = $ipmitool_command;
$anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmi_password} = $ipmi_password;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"scan-ipmitool::host_name::${host_name}::host_ipmi" => $anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{host_ipmi},
"scan-ipmitool::host_name::${host_name}::ipmitool_command" => $anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmitool_command},
"scan-ipmitool::host_name::${host_name}::ipmi_password" => $anvil->Log->is_secure($anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmi_password}),
}});
}
next if not $access;
$ipmi_targets++;
# Convert to an 'ipmitool' call.
my ($ipmitool_command, $ipmi_password) = $anvil->Convert->fence_ipmilan_to_ipmitool({fence_ipmilan_command => $host_ipmi});
$anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{host_ipmi} = $host_ipmi;
$anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmitool_command} = $ipmitool_command;
$anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmi_password} = $ipmi_password;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"scan-ipmitool::host_name::${host_name}::host_ipmi" => $anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{host_ipmi},
"scan-ipmitool::host_name::${host_name}::ipmitool_command" => $anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmitool_command},
"scan-ipmitool::host_name::${host_name}::ipmi_password" => $anvil->Log->is_secure($anvil->data->{'scan-ipmitool'}{host_name}{$host_name}{ipmi_password}),
}});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ipmi_targets => $ipmi_targets }});

@ -36,9 +36,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@ -54,7 +52,7 @@ $anvil->data->{scancore}{'scan-lvm'}{disable} = 0;
$anvil->data->{switches}{force} = 0;
$anvil->Storage->read_config();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->Get->switches;

@ -35,9 +35,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@ -71,7 +69,7 @@ if ($problem)
$anvil->nice_exit({exit_code => 1});
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_log_0001", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_server_log_0001", variables => { program => $THIS_FILE }});
# There are no tables for this agent, so '--purge' is useless here.
@ -80,7 +78,7 @@ my $host_type = $anvil->Get->host_type;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { host_type => $host_type }});
if ($host_type eq "striker")
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_server_log_0002", variables => { host_type => $host_type }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_server_log_0002", variables => { host_type => $host_type }});
$anvil->nice_exit({exit_code => 0});
}

@ -75,9 +75,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
my $anvil = Anvil::Tools->new();
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@ -207,7 +205,7 @@ $anvil->data->{'scan-storcli'} = {
};
$anvil->Storage->read_config();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1 , key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->data->{switches}{force} = 0;
@ -240,7 +238,7 @@ if ($anvil->data->{switches}{purge})
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "scan_storcli_message_0001"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "scan_storcli_message_0001"});
# This does two things; It checks to see if storcli64 is installed (exits '1' if not, exits '2' if not
# executable) and then checks to see if any controllers are found in the system (exits '3' if not).
@ -2724,7 +2722,7 @@ INSERT INTO
low_critical_temperature => $low_critical,
low_warning_temperature => $low_warning,
};
my $log_level = $alert_level eq "notice" ? 2 : 1;
my $log_level = $alert_level eq "notice" ? 3 : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => $message_key, variables => $variables});
$anvil->Alert->register({
alert_level => $alert_level,
@ -3284,7 +3282,7 @@ WHERE
low_warning_temperature => $low_warning,
jump => $jump,
};
my $log_level = $alert_level eq "notice" ? 2 : 1;
my $log_level = $alert_level eq "notice" ? 3 : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => $message_key, variables => $variables});
$anvil->Alert->register({
alert_level => $alert_level,
@ -10040,12 +10038,37 @@ sub find_lsi_controllers
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "path::exe::storcli64" => $anvil->data->{path}{exe}{storcli64} }});
}
# First, do we have storcli64 installed?
# Do we have storcli64 installed?
if (not -e $anvil->data->{path}{exe}{storcli64})
{
# Nope, exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "scan_storcli_error_0001", variables => { path => $anvil->data->{path}{exe}{storcli64} }});
$anvil->nice_exit({exit_code => 1});
# Nope, Call lspci to see if there's a MegaRAID controller. If there is, the user may need to
# install the RPM.
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{lspci}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
my $megaraid_installed = 0;
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /MegaRAID/i)
{
# This host appears to have a RAID card, but it's not installed. Lets try to
# install it for them.
$megaraid_installed = install_storcli($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { megaraid_installed => $megaraid_installed }});
}
}
# exit.
if (not $megaraid_installed)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "scan_storcli_error_0001", variables => { path => $anvil->data->{path}{exe}{storcli64} }});
$anvil->nice_exit({exit_code => 1});
}
}
# Make sure it is executable
@ -10083,7 +10106,7 @@ sub find_lsi_controllers
}
else
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "scan_storcli_error_0003", variables => {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 2, level => 0, key => "scan_storcli_error_0003", variables => {
path => $anvil->data->{path}{exe}{storcli64},
}});
$anvil->nice_exit({exit_code => 3});
@ -10091,3 +10114,73 @@ sub find_lsi_controllers
return(0);
}
sub install_storcli
{
my ($anvil) = @_;
# Tell the user what we're doing.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, key => "scan_storcli_note_0071"});
# Is this a Dell?
my $is_dell = 0;
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{dmidecode}." --string system-manufacturer"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /Dell/i)
{
$is_dell = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { is_dell => $is_dell }});
}
}
my $rpm_name = $is_dell ? "perccli" : "storcli";
my $shell_call = $anvil->data->{path}{exe}{dnf}." -y install ".$rpm_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
# Check now to see if the program is installed. If it is, register an alert announcing we installed it.
my $program = $is_dell ? $anvil->data->{path}{exe}{perccli64} : $anvil->data->{path}{exe}{storcli64};
if (-e $program)
{
# Installed successfully!
my $variables = {
rpm => $rpm_name,
};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_storcli_note_0072", variables => $variables});
$anvil->Alert->register({
alert_level => "notice",
message => "scan_storcli_note_0072",
show_header => 1,
variables => $variables,
sort_position => 0,
set_by => $THIS_FILE,
});
# Before we return, if we installed for Dell, switch out the 'storcli' program path.
if ($is_dell)
{
$anvil->data->{path}{exe}{storcli64} = $anvil->data->{path}{exe}{perccli64};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "path::exe::storcli64" => $anvil->data->{path}{exe}{storcli64} }});
}
return(1);
}
else
{
# Didn't work.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, key => "scan_storcli_note_0073"});
}
return(0);
}

@ -334,6 +334,9 @@ The temperature of the Battery Backup Unit (BBU): [#!variable!serial_number!#] h
- Controller: [#!variable!serial_number!#]: '#!variable!name!#' has changed: [#!variable!old_value!#] -> [#!variable!new_value!#]
NOTE: This is expected and is no reason for concern.
</key>
<key name="scan_storcli_note_0071">The host appears to have a MegaRAID controller, but the tool to communicate with it is not installed. We'll try to install it now.</key>
<key name="scan_storcli_note_0072">An LSI-based (MegaRAID) controller was found, but the management tool was not installed. The RPM: [#!variable!rpm!#] has now been installed to allow monitoring storage.</key>
<key name="scan_storcli_note_0073">The install didn't work, we'll try again in the next scan.</key>
<!-- Warnings -->

@ -337,7 +337,7 @@ CREATE TRIGGER trigger_sessions
CREATE TABLE anvils (
anvil_uuid uuid not null primary key,
anvil_name text not null,
anvil_description text not null, -- This is a short, one-line (usually) description of this particular Anvil!. It is displayed in the Anvil! selection list.
anvil_description text not null, -- This is a short, one-line (usually) description of this particular Anvil!. It is displayed in the Anvil! selection list. This is set to 'DELETED' when an Anvil! is removed.
anvil_password text not null, -- This is the 'hacluster' user password. It is also used to access nodes that don't have a specific password set.
anvil_node1_host_uuid uuid, -- This is the host_uuid of the machine that is used as node 1.
anvil_node2_host_uuid uuid, -- This is the host_uuid of the machine that is used as node 2.

@ -16,7 +16,9 @@
# - Record how long a server's migration took in the past, and use that to determine which node to evacuate
# during load shed. Also, track how long it takes for servers to stop to determine when to initiate a total
# shutdown.
# -
# - Add a '--silence-alerts --anvil <name>' and '--restore-alerts --anvil <name>' to temporarily
# disable/re-enable alerts. This is to allow for quiet maintenance without stopping scancore itself.
#
use strict;
use warnings;

Loading…
Cancel
Save