* Fixed a bug in scan-apc-ups where changes in the transfer reason were not being recorded.

* Cleaned up a log of logging to reduce the amount of log entries when running at log level 1.
* Bumped the scan-ipmitool default 'jump' range to 10c.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent b2dab95459
commit 6009590352
  1. 5
      Anvil/Tools/Email.pm
  2. 11
      Anvil/Tools/ScanCore.pm
  3. 20
      scancore-agents/scan-apc-ups/scan-apc-ups
  4. 2
      scancore-agents/scan-ipmitool/scan-ipmitool
  5. 2
      share/words.xml
  6. 13
      tools/scancore

@ -623,10 +623,9 @@ Reply-To: ".$reply_to."
my $file_time = $anvil->Get->date_and_time({file_name => 1}); my $file_time = $anvil->Get->date_and_time({file_name => 1});
my $short_uuid = $anvil->Get->uuid({short => 1}); my $short_uuid = $anvil->Get->uuid({short => 1});
my $file_name = $anvil->data->{path}{directories}{alert_emails}."/alert_email.".$file_time.".".$short_uuid; 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({ my $problem = $anvil->Storage->write_file({
debug => 3,
file => $file_name, file => $file_name,
body => $email_body, body => $email_body,
}); });
@ -640,7 +639,7 @@ Reply-To: ".$reply_to."
} }
else 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; 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 }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});

@ -259,7 +259,7 @@ sub call_scan_agents
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
# Tell the user this agent is about to run... # 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, agent_name => $agent_name,
timeout => $timeout, 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->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, agent_name => $agent_name,
runtime => (time - $start_time), runtime => $runtime,
return_code => $return_code, return_code => $return_code,
}}); }});

@ -698,6 +698,8 @@ INSERT INTO
# some being more critical than others. # some being more critical than others.
if ($scan_apc_ups_last_transfer_reason ne $old_scan_apc_ups_last_transfer_reason) 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 ### NOTE: This used to be 'warning' level, but it caused way too many
### false alarms. If a serious issue arises, the input voltage ### 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; $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 = { my $variables = {
ups_name => $scan_apc_ups_name, ups_name => $scan_apc_ups_name,
new_value => "#!string!scan_apc_ups_last_transfer_".sprintf("%04d", $say_scan_apc_ups_last_transfer_reason)."!#", 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)."!#", 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->Log->entry({source => $THIS_FILE, line => __LINE__, level => $log_level, 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->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) if ($scan_apc_ups_manufactured_date ne $old_scan_apc_ups_manufactured_date)
{ {

@ -124,7 +124,7 @@ $anvil->data->{'scan-ipmitool'} = {
high_critical => 55, high_critical => 55,
low_warning => 5, low_warning => 5,
low_critical => 0, low_critical => 0,
jump => 5, jump => 10,
### TODO: Some sensors define their hysteresis which we can read using: ### TODO: Some sensors define their hysteresis which we can read using:
### ipmitool ... sensor get "Ambient" ### ipmitool ... sensor get "Ambient"
buffer => 2, buffer => 2,

@ -949,7 +949,7 @@ The body of the file: [#!variable!file!#] does not match the new body. The file
<key name="log_0246">[ Warning ] - The local system is not yet configured. Scancore will check once a minute and start running once configured.</key> <key name="log_0246">[ Warning ] - The local system is not yet configured. Scancore will check once a minute and start running once configured.</key>
<key name="log_0247">[ Cleared ] - The local system is now configured, proceeding.</key> <key name="log_0247">[ Cleared ] - The local system is now configured, proceeding.</key>
<key name="log_0248">ScanCore is entering the main loop now.</key> <key name="log_0248">ScanCore is entering the main loop now.</key>
<key name="log_0249">----=] ScanCore loop finished. Sleeping for: [#!variable!run_interval!#] seconds. ]=--------------------------------------</key> <!-- This is meant to be easily seen in the logs, hence the dashes. --> <key name="log_0249">----=] ScanCore loop finished after: [#!variable!runtime!#]. Sleeping for: [#!variable!run_interval!#] seconds. ]=--------------------------------------</key> <!-- This is meant to be easily seen in the logs, hence the dashes. -->
<key name="log_0250"> <key name="log_0250">
The md5sum of: [#!variable!file!#] has changed since the daemon started. The md5sum of: [#!variable!file!#] has changed since the daemon started.
* [#!variable!old_sum!#] -> [#!variable!new_sum!#] * [#!variable!old_sum!#] -> [#!variable!new_sum!#]

@ -97,10 +97,11 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level
while(1) while(1)
{ {
# Do the various pre-run tasks. # 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); prepare_for_run($anvil);
# Do we have at least one database? # Do we have at least one database?
my $agent_runtime = 0;
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
{ {
# Run the normal tasks # Run the normal tasks
@ -147,7 +148,10 @@ while(1)
{ {
$run_interval = $anvil->data->{scancore}{timing}{run_interval}; $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); sleep($run_interval);
# In case something has changed, exit. # In case something has changed, exit.
@ -211,7 +215,7 @@ sub prepare_for_run
$anvil->Get->switches(); $anvil->Get->switches();
$anvil->Words->read(); $anvil->Words->read();
$anvil->Database->connect(); $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. # See if the mail server needs to be updated.
$anvil->Email->check_config; $anvil->Email->check_config;
@ -303,9 +307,8 @@ sub startup_tasks
my ($anvil) = @_; my ($anvil) = @_;
# Make sure our stop reason is cleared. # 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({ my $variable_uuid = $anvil->Database->insert_or_update_variables({
debug => 2,
variable_name => 'system::stop_reason', variable_name => 'system::stop_reason',
variable_value => '', variable_value => '',
variable_default => '', variable_default => '',

Loading…
Cancel
Save