* Added support for setting per-agent log-level and log secure values in amvil.conf.

* Moved the check for an agent being disabled into ScanCore->agent_startup()

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 3674a47179
commit 8abb5b46e0
  1. 24
      Anvil/Tools/ScanCore.pm
  2. 2
      Anvil/Tools/Server.pm
  3. 11
      anvil.conf
  4. 7
      scancore-agents/scan-apc-pdu/scan-apc-pdu
  5. 7
      scancore-agents/scan-apc-ups/scan-apc-ups
  6. 7
      scancore-agents/scan-cluster/scan-cluster
  7. 7
      scancore-agents/scan-drbd/scan-drbd
  8. 7
      scancore-agents/scan-filesystems/scan-filesystems
  9. 7
      scancore-agents/scan-hardware/scan-hardware
  10. 7
      scancore-agents/scan-hpacucli/scan-hpacucli
  11. 7
      scancore-agents/scan-ipmitool/scan-ipmitool
  12. 7
      scancore-agents/scan-lvm/scan-lvm
  13. 21
      scancore-agents/scan-network/scan-network
  14. 7
      scancore-agents/scan-server/scan-server
  15. 9
      tools/scancore

@ -178,6 +178,30 @@ sub agent_startup
tables => $tables, tables => $tables,
}}); }});
# Adjust the log level, if required.
if ((exists $anvil->data->{scancore}{$agent}{log_level}) && ($anvil->data->{scancore}{$agent}{log_level} =~ /^\d+$/))
{
$anvil->Log->level({set => $anvil->data->{scancore}{$agent}{log_level}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"scancore::${agent}::log_level" => $anvil->data->{scan_agent}{$agent}{log_level},
}});
}
if ((exists $anvil->data->{scancore}{$agent}{log_secure}) && ($anvil->data->{scancore}{$agent}{log_secure} =~ /^\d+$/))
{
$anvil->Log->secure({set => $anvil->data->{scancore}{$agent}{log_secure}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"scancore::${agent}::log_level" => $anvil->data->{scan_agent}{$agent}{log_secure},
}});
}
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{$agent}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0646", variables => { program => $THIS_FILE }});
$anvil->nice_exit({exit_code => 0});
}
# Setting this will prepend messages coming grom the agent with the agent's name # Setting this will prepend messages coming grom the agent with the agent's name
$anvil->data->{'log'}{scan_agent} = $agent; $anvil->data->{'log'}{scan_agent} = $agent;

@ -1032,7 +1032,7 @@ WHERE
{ {
$live_migrate = "--live"; $live_migrate = "--live";
} }
my $target_ip = $anvil->Convert->host_name_to_ip({debug => $debug, host_name => $target}); my $target_ip = $anvil->Convert->host_name_to_ip({debug => $debug, host_name => $target});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
target_ip => $target_ip, target_ip => $target_ip,
live_migrate => $live_migrate, live_migrate => $live_migrate,

@ -193,3 +193,14 @@ sys::manage::firewall = 1
# This is the "short list" of servers shown when provisioning a new server. To see the full list of options, # This is the "short list" of servers shown when provisioning a new server. To see the full list of options,
# run '/usr/bin/osinfo-query os' on any machine in the Anvil!. # run '/usr/bin/osinfo-query os' on any machine in the Anvil!.
#sys::servers::os_short_list = debian10,fedora32,freebsd12.1,gentoo,macosx10.7,msdos6.22,openbsd6.7,opensuse15.2,rhel5.11,rhel6.10,rhel7.9,rhel8.3,sles12sp5,solaris11,ubuntu20.04,win10,win2k16,win2k19 #sys::servers::os_short_list = debian10,fedora32,freebsd12.1,gentoo,macosx10.7,msdos6.22,openbsd6.7,opensuse15.2,rhel5.11,rhel6.10,rhel7.9,rhel8.3,sles12sp5,solaris11,ubuntu20.04,win10,win2k16,win2k19
### Scan agent options
# All scan agent configurations have the format 'scancore::<agent_name>::<variable>'.
# An agent can be disabled on a given machine by setting the 'disable' variable.
#scancore::scan-network::disable = 1
# Logging can be set on a per-agent basis with:
#scancore::scan-network::log_level = 2
#scancore::scan-network::log_secure = 1

@ -170,13 +170,6 @@ if (($host_type ne "striker") && (not $anvil->data->{switches}{force}))
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-apc-pdu'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -197,13 +197,6 @@ if (($host_type ne "striker") && (not $anvil->data->{switches}{force}))
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-apc-ups'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -56,13 +56,6 @@ $anvil->Storage->read_config();
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-cluster'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -59,13 +59,6 @@ $anvil->Storage->read_config();
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-drbd'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }});

@ -58,13 +58,6 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-filesystems'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -59,13 +59,6 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print'
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-hardware'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -165,13 +165,6 @@ $anvil->data->{switches}{force} = 0;
$anvil->data->{switches}{purge} = 0; $anvil->data->{switches}{purge} = 0;
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-hpacucli'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -205,13 +205,6 @@ $anvil->data->{switches}{force} = 0;
$anvil->data->{switches}{purge} = 0; $anvil->data->{switches}{purge} = 0;
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-ipmitool'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -57,13 +57,6 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-lvm'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -51,14 +51,6 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print'
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-hardware'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0646", variables => { program => $THIS_FILE }});
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)
@ -90,7 +82,7 @@ find_changes($anvil);
# Finally, process health weights. # Finally, process health weights.
process_health($anvil); process_health($anvil);
# Shut down. # Shut down.
$anvil->ScanCore->agent_shutdown({agent => $THIS_FILE}); $anvil->ScanCore->agent_shutdown({agent => $THIS_FILE});
@ -211,8 +203,12 @@ sub collect_data
$speed =~ s/\n$//; $speed =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
interface => $interface, interface => $interface,
speed => $speed,
mac_address => $mac_address, mac_address => $mac_address,
link_state => $link_state,
mtu => $mtu,
duplex => $duplex,
operational => $operational,
speed => $speed,
}}); }});
# These are variables that will be needed if this is a bond interface. # These are variables that will be needed if this is a bond interface.
@ -474,6 +470,11 @@ sub collect_data
"cache::new_file" => $anvil->data->{cache}{new_file}, "cache::new_file" => $anvil->data->{cache}{new_file},
}}); }});
} }
if (($interface =~ /^vnet/) && ($operational ne "up"))
{
#die;
}
} }
} }
closedir(DIRECTORY); closedir(DIRECTORY);

@ -58,13 +58,6 @@ $anvil->Storage->read_config();
# Read switches # Read switches
$anvil->Get->switches; $anvil->Get->switches;
# If we're disabled and '--force' wasn't used, exit.
if (($anvil->data->{scancore}{'scan-server'}{disable}) && (not $anvil->data->{switches}{force}))
{
# Exit.
$anvil->nice_exit({exit_code => 0});
}
# Handle start-up tasks # Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE}); my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
if ($problem) if ($problem)

@ -128,7 +128,7 @@ while(1)
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
{ {
# Run the normal tasks # Run the normal tasks
$anvil->ScanCore->call_scan_agents({debug => 2}); $anvil->ScanCore->call_scan_agents();
# Do post-scan analysis. # Do post-scan analysis.
$anvil->ScanCore->post_scan_analysis({debug => 2}); $anvil->ScanCore->post_scan_analysis({debug => 2});
@ -224,6 +224,7 @@ sub exit_if_sums_changed
sub prepare_for_run sub prepare_for_run
{ {
my ($anvil) = @_; my ($anvil) = @_;
# Reload defaults, re-read the config and then connect to the database(s) # Reload defaults, re-read the config and then connect to the database(s)
$anvil->_set_paths(); $anvil->_set_paths();
$anvil->_set_defaults(); $anvil->_set_defaults();
@ -332,7 +333,7 @@ sub startup_tasks
foreach my $scan_agent (sort {$a cmp $b} keys %{$anvil->data->{scancore}{agent}}) foreach my $scan_agent (sort {$a cmp $b} keys %{$anvil->data->{scancore}{agent}})
{ {
my $schema_file = $anvil->data->{path}{directories}{scan_agents}."/".$scan_agent."/".$scan_agent.".sql"; my $schema_file = $anvil->data->{path}{directories}{scan_agents}."/".$scan_agent."/".$scan_agent.".sql";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
scan_agent => $scan_agent, scan_agent => $scan_agent,
schema_file => $schema_file, schema_file => $schema_file,
}}); }});
@ -342,7 +343,7 @@ sub startup_tasks
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { tables => $tables }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { tables => $tables }});
my $table_count = @{$tables}; my $table_count = @{$tables};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { table_count => $table_count }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { table_count => $table_count }});
# It's possible that some agents don't have a database (or use core database tables only) # It's possible that some agents don't have a database (or use core database tables only)
if (@{$tables} > 0) if (@{$tables} > 0)
@ -386,7 +387,7 @@ sub startup_tasks
if ($host_type eq "node") if ($host_type eq "node")
{ {
my $uptime = $anvil->Get->uptime; my $uptime = $anvil->Get->uptime;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uptime => $uptime }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uptime => $uptime }});
if ($uptime < 600) if ($uptime < 600)
{ {
# Run it as a background task # Run it as a background task

Loading…
Cancel
Save