diff --git a/Anvil/Tools/Email.pm b/Anvil/Tools/Email.pm
index 035e3942..ec9a7157 100644
--- a/Anvil/Tools/Email.pm
+++ b/Anvil/Tools/Email.pm
@@ -623,10 +623,9 @@ Reply-To: ".$reply_to."
my $file_time = $anvil->Get->date_and_time({file_name => 1});
my $short_uuid = $anvil->Get->uuid({short => 1});
my $file_name = $anvil->data->{path}{directories}{alert_emails}."/alert_email.".$file_time.".".$short_uuid;
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0541", variables => { file => $file_name }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0541", variables => { file => $file_name }});
my $problem = $anvil->Storage->write_file({
- debug => 3,
file => $file_name,
body => $email_body,
});
@@ -640,7 +639,7 @@ Reply-To: ".$reply_to."
}
else
{
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0542", variables => { to => $to }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0542", variables => { to => $to }});
my $shell_call = $anvil->data->{path}{exe}{mailx}." -t < ".$file_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
diff --git a/Anvil/Tools/ScanCore.pm b/Anvil/Tools/ScanCore.pm
index 663b48f2..07a24272 100644
--- a/Anvil/Tools/ScanCore.pm
+++ b/Anvil/Tools/ScanCore.pm
@@ -259,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 => 1, key => "log_0252", variables => {
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0252", variables => {
agent_name => $agent_name,
timeout => $timeout,
}});
@@ -269,9 +269,14 @@ 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 => 1, key => "log_0557", variables => {
+
+ # If an agent takes a while to run, log it with higher verbosity
+ my $runtime = (time - $start_time);
+ my $log_level = $runtime > 10 ? 1 : $debug;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output, runtime => $runtime }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => $log_level, key => "log_0557", variables => {
agent_name => $agent_name,
- runtime => (time - $start_time),
+ runtime => $runtime,
return_code => $return_code,
}});
diff --git a/scancore-agents/scan-apc-ups/scan-apc-ups b/scancore-agents/scan-apc-ups/scan-apc-ups
index f15648ac..7f17abfa 100755
--- a/scancore-agents/scan-apc-ups/scan-apc-ups
+++ b/scancore-agents/scan-apc-ups/scan-apc-ups
@@ -698,6 +698,8 @@ INSERT INTO
# some being more critical than others.
if ($scan_apc_ups_last_transfer_reason ne $old_scan_apc_ups_last_transfer_reason)
{
+ $ups_changed = 1;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ups_changed => $ups_changed }});
### NOTE: This used to be 'warning' level, but it caused way too many
### false alarms. If a serious issue arises, the input voltage
@@ -729,13 +731,27 @@ INSERT INTO
$say_old_scan_apc_ups_last_transfer_reason = 99;
}
+ # The level of the alert will depends on the now/old state
+ my $log_level = 3;
+ my $alert_level = "info";
+ if (($scan_apc_ups_last_transfer_reason eq "2") or ($old_scan_apc_ups_last_transfer_reason eq "2") or
+ ($scan_apc_ups_last_transfer_reason eq "3") or ($old_scan_apc_ups_last_transfer_reason eq "3") or
+ ($scan_apc_ups_last_transfer_reason eq "4") or ($old_scan_apc_ups_last_transfer_reason eq "3") or
+ ($scan_apc_ups_last_transfer_reason eq "6") or ($old_scan_apc_ups_last_transfer_reason eq "6") or
+ ($scan_apc_ups_last_transfer_reason eq "8") or ($old_scan_apc_ups_last_transfer_reason eq "8") or
+ ($scan_apc_ups_last_transfer_reason eq "10") or ($old_scan_apc_ups_last_transfer_reason eq "10"))
+ {
+ $log_level = 2;
+ $alert_level = "notice";
+ }
+
my $variables = {
ups_name => $scan_apc_ups_name,
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 => 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}++});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, key => "scan_apc_ups_warning_0015", variables => $variables});
+ $anvil->Alert->register({alert_level => $alert_level, 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)
{
diff --git a/scancore-agents/scan-ipmitool/scan-ipmitool b/scancore-agents/scan-ipmitool/scan-ipmitool
index 438803e1..adf1ac37 100755
--- a/scancore-agents/scan-ipmitool/scan-ipmitool
+++ b/scancore-agents/scan-ipmitool/scan-ipmitool
@@ -124,7 +124,7 @@ $anvil->data->{'scan-ipmitool'} = {
high_critical => 55,
low_warning => 5,
low_critical => 0,
- jump => 5,
+ jump => 10,
### TODO: Some sensors define their hysteresis which we can read using:
### ipmitool ... sensor get "Ambient"
buffer => 2,
diff --git a/share/words.xml b/share/words.xml
index 0835efa6..9d05966c 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -949,7 +949,7 @@ The body of the file: [#!variable!file!#] does not match the new body. The file
[ Warning ] - The local system is not yet configured. Scancore will check once a minute and start running once configured.
[ Cleared ] - The local system is now configured, proceeding.
ScanCore is entering the main loop now.
- ----=] ScanCore loop finished. Sleeping for: [#!variable!run_interval!#] seconds. ]=--------------------------------------
+ ----=] ScanCore loop finished after: [#!variable!runtime!#]. Sleeping for: [#!variable!run_interval!#] seconds. ]=--------------------------------------
The md5sum of: [#!variable!file!#] has changed since the daemon started.
* [#!variable!old_sum!#] -> [#!variable!new_sum!#]
diff --git a/tools/scancore b/tools/scancore
index 5b8307a2..e5b92515 100755
--- a/tools/scancore
+++ b/tools/scancore
@@ -97,10 +97,11 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level
while(1)
{
# Do the various pre-run tasks.
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { 'sys::log::level' => $anvil->data->{sys}{'log'}{level} }});
+ my $start_time = time;
prepare_for_run($anvil);
# Do we have at least one database?
+ my $agent_runtime = 0;
if ($anvil->data->{sys}{database}{connections})
{
# Run the normal tasks
@@ -147,7 +148,10 @@ while(1)
{
$run_interval = $anvil->data->{scancore}{timing}{run_interval};
}
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0249", variables => { run_interval => $run_interval }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0249", variables => {
+ run_interval => $run_interval,
+ runtime => (time - $start_time),
+ }});
sleep($run_interval);
# In case something has changed, exit.
@@ -211,7 +215,7 @@ sub prepare_for_run
$anvil->Get->switches();
$anvil->Words->read();
$anvil->Database->connect();
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0132"});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0132"});
# See if the mail server needs to be updated.
$anvil->Email->check_config;
@@ -303,9 +307,8 @@ sub startup_tasks
my ($anvil) = @_;
# Make sure our stop reason is cleared.
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0572"});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0572"});
my $variable_uuid = $anvil->Database->insert_or_update_variables({
- debug => 2,
variable_name => 'system::stop_reason',
variable_value => '',
variable_default => '',