Reduced the frequency of monitoring to 1/min and reduced log size

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 10 months ago
parent 247cf0a238
commit c79b76e2ee
  1. 1
      share/words.xml
  2. 39
      tools/anvil-manage-daemons

@ -3367,6 +3367,7 @@ proceeding.
<key name="message_0418">[ Note ] - Updated the ssh daemon config file: [#!variable!file!#] to enable ssh access for the root user.</key> <key name="message_0418">[ Note ] - Updated the ssh daemon config file: [#!variable!file!#] to enable ssh access for the root user.</key>
<key name="message_0419">Anvil! Intelligent Availability Daemon Status (Enabled, Started, Failed);</key> <key name="message_0419">Anvil! Intelligent Availability Daemon Status (Enabled, Started, Failed);</key>
<key name="message_0420">- #!variable!daemon!# #!variable!enabled!# (#!variable!enable_string!#), #!variable!started!# (#!variable!start_string!#), #!variable!failed!# (#!variable!fail_string!#).</key> <key name="message_0420">- #!variable!daemon!# #!variable!enabled!# (#!variable!enable_string!#), #!variable!started!# (#!variable!start_string!#), #!variable!failed!# (#!variable!fail_string!#).</key>
<key name="message_0421">Daemons [enabled/started/failed]; #!variable!string!#.</key>
<!-- Translate names (protocols, etc) --> <!-- Translate names (protocols, etc) -->
<key name="name_0001">Normal Password</key> <!-- none in mail-server --> <key name="name_0001">Normal Password</key> <!-- none in mail-server -->

@ -35,8 +35,8 @@ $anvil->Get->switches({list => [
"status", "status",
"stop", "stop",
], man => $THIS_FILE}); ], man => $THIS_FILE});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => $anvil->data->{switches}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# Common daemons # Common daemons
$anvil->data->{daemons}{core}{'anvil-daemon'} = "anvil-daemon.service"; $anvil->data->{daemons}{core}{'anvil-daemon'} = "anvil-daemon.service";
@ -53,17 +53,17 @@ $anvil->data->{daemons}{node}{'anvil-safe-start'} = "anvil-safe-start.service";
$anvil->data->{daemons}{dr}{'anvil-safe-start'} = "anvil-safe-start.service"; $anvil->data->{daemons}{dr}{'anvil-safe-start'} = "anvil-safe-start.service";
my $host_type = $anvil->Get->host_type(); my $host_type = $anvil->Get->host_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { host_type => $host_type }});
my $daemon_list = []; my $daemon_list = [];
foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemons}{core}}) foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemons}{core}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { daemon => $daemon }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { daemon => $daemon }});
push @{$daemon_list}, $daemon; push @{$daemon_list}, $daemon;
} }
foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemons}{$host_type}}) foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemons}{$host_type}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { daemon => $daemon }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { daemon => $daemon }});
push @{$daemon_list}, $daemon; push @{$daemon_list}, $daemon;
} }
@ -119,6 +119,7 @@ sub report_status
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => $print, level => 1, secure => 0, key => "message_0419"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => $print, level => 1, secure => 0, key => "message_0419"});
} }
my $longest_daemon = $anvil->data->{longest_daemon}; my $longest_daemon = $anvil->data->{longest_daemon};
my $string = "";
foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}}) foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}})
{ {
my $say_enabled = "unknown"; my $say_enabled = "unknown";
@ -162,8 +163,11 @@ sub report_status
$say_daemon .= "."; $say_daemon .= ".";
} }
$string .= $daemon." [".$say_enabled."/".$say_started."/".$say_failed."], ";
### NOTE: Set this to '3' because it was filling the logs when '--debug' is used.
# Report. # Report.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => $print, level => 1, secure => 0, key => "message_0420", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => $print, level => 3, secure => 0, key => "message_0420", variables => {
daemon => $say_daemon, daemon => $say_daemon,
enabled => $say_enabled, enabled => $say_enabled,
enable_string => $anvil->data->{daemon}{$daemon}{enabled}{string}, enable_string => $anvil->data->{daemon}{$daemon}{enabled}{string},
@ -174,6 +178,9 @@ sub report_status
}}); }});
} }
$string =~ s/, $//gs;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => $print, level => 1, secure => 0, key => "message_0421", variables => { string => $string }});
return(0); return(0);
} }
@ -184,22 +191,22 @@ sub check_daemon
$anvil->data->{longest_daemon} = 0; $anvil->data->{longest_daemon} = 0;
foreach my $daemon (sort {$a cmp $b} @{$daemon_list}) foreach my $daemon (sort {$a cmp $b} @{$daemon_list})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { daemon => $daemon }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { daemon => $daemon }});
if (length($daemon) > $anvil->data->{longest_daemon}) if (length($daemon) > $anvil->data->{longest_daemon})
{ {
$anvil->data->{longest_daemon} = length($daemon); $anvil->data->{longest_daemon} = length($daemon);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { longest_daemon => $anvil->data->{longest_daemon} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { longest_daemon => $anvil->data->{longest_daemon} }});
} }
# What's the status of this daemon? # What's the status of this daemon?
foreach my $test ("active", "enabled", "failed") foreach my $test ("active", "enabled", "failed")
{ {
my $shell_call = $anvil->data->{path}{exe}{systemctl}." is-".$test." ".$daemon; my $shell_call = $anvil->data->{path}{exe}{systemctl}." is-".$test." ".$daemon;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $shell_call}); my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
}}); }});
@ -207,7 +214,7 @@ sub check_daemon
# There should only be one line of output. # There should only be one line of output.
$anvil->data->{daemon}{$daemon}{$test}{string} = $output; $anvil->data->{daemon}{$daemon}{$test}{string} = $output;
$anvil->data->{daemon}{$daemon}{$test}{return_code} = $return_code; $anvil->data->{daemon}{$daemon}{$test}{return_code} = $return_code;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"daemon::${daemon}::${test}::string" => $anvil->data->{daemon}{$daemon}{$test}{string}, "daemon::${daemon}::${test}::string" => $anvil->data->{daemon}{$daemon}{$test}{string},
"daemon::${daemon}::${test}::return_code" => $anvil->data->{daemon}{$daemon}{$test}{return_code}, "daemon::${daemon}::${test}::return_code" => $anvil->data->{daemon}{$daemon}{$test}{return_code},
}}); }});
@ -216,12 +223,12 @@ sub check_daemon
foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}}) foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { daemon => $daemon }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { daemon => $daemon }});
foreach my $test (sort {$a cmp $b} keys %{$anvil->data->{daemon}{$daemon}}) foreach my $test (sort {$a cmp $b} keys %{$anvil->data->{daemon}{$daemon}})
{ {
my $string = $anvil->data->{daemon}{$daemon}{$test}{string}; my $string = $anvil->data->{daemon}{$daemon}{$test}{string};
my $return_code = $anvil->data->{daemon}{$daemon}{$test}{return_code}; my $return_code = $anvil->data->{daemon}{$daemon}{$test}{return_code};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"s1:test" => $test, "s1:test" => $test,
"s2:string" => $string, "s2:string" => $string,
"s3:return_code" => $return_code, "s3:return_code" => $return_code,
@ -339,7 +346,7 @@ sub monitor_daemons
# Return code of '1' is OK, '0' is failed. # Return code of '1' is OK, '0' is failed.
my $string = $anvil->data->{daemon}{$daemon}{failed}{string}; my $string = $anvil->data->{daemon}{$daemon}{failed}{string};
my $return_code = $anvil->data->{daemon}{$daemon}{failed}{return_code}; my $return_code = $anvil->data->{daemon}{$daemon}{failed}{return_code};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"s1:daemon" => $daemon, "s1:daemon" => $daemon,
"s2:string" => $string, "s2:string" => $string,
"s3:return_code" => $return_code, "s3:return_code" => $return_code,
@ -368,7 +375,7 @@ sub monitor_daemons
if (time > $next_md5sum_check) if (time > $next_md5sum_check)
{ {
$next_md5sum_check = time + 30; $next_md5sum_check = time + 30;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { next_md5sum_check => $next_md5sum_check }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { next_md5sum_check => $next_md5sum_check }});
if ($anvil->Storage->check_md5sums) if ($anvil->Storage->check_md5sums)
{ {
# NOTE: We exit with '0' to prevent systemctl from showing a scary red message. # NOTE: We exit with '0' to prevent systemctl from showing a scary red message.
@ -376,7 +383,7 @@ sub monitor_daemons
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
} }
} }
sleep 10; sleep 60;
} }
return(0); return(0);

Loading…
Cancel
Save