Added log-only option to anvil-manage-daemons and enabled

anvil-monitor-daemons.service to only monitor daemons.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 10 months ago
parent 1455066cd1
commit e0c4ed6de5
  1. 1
      anvil.spec.in
  2. 3
      man/anvil-manage-daemons.8
  3. 2
      share/words.xml
  4. 39
      tools/anvil-manage-daemons
  5. 2
      units/anvil-monitor-daemons.service

@ -249,6 +249,7 @@ setenforce 0
### TODO: check it if was disabled (if it existed before) and, if so, leave it disabled. ### TODO: check it if was disabled (if it existed before) and, if so, leave it disabled.
systemctl enable --now chronyd.service systemctl enable --now chronyd.service
systemctl enable --now anvil-daemon.service systemctl enable --now anvil-daemon.service
systemctl enable --now anvil-monitor-daemons.service
systemctl enable --now anvil-monitor-network.service systemctl enable --now anvil-monitor-network.service
systemctl enable --now anvil-monitor-performance.service systemctl enable --now anvil-monitor-performance.service
systemctl enable --now scancore.service systemctl enable --now scancore.service

@ -27,6 +27,9 @@ All Anvil! daemons that are not enabled will be enabled.
\fB\-\-disable\fR \fB\-\-disable\fR
All Anvil! daemons that are not disabled will be disabled. All Anvil! daemons that are not disabled will be disabled.
.TP .TP
\fB\-\-log\-only\fR
if this is passed, it monitors the status of the daemons, but does not try to recover failed ones.
.TP
\fB\-\-monitor\fR \fB\-\-monitor\fR
This is set to the job UUID when the request to boot is coming from a database job. When set, the referenced job will be updated and marked as complete / failed when the run completes. This is set to the job UUID when the request to boot is coming from a database job. When set, the referenced job will be updated and marked as complete / failed when the run completes.
.TP .TP

@ -3361,6 +3361,8 @@ proceeding.
<key name="message_0416">[ Note ] - The network has reconnected to the database, configuring will complete shortly.</key> <key name="message_0416">[ Note ] - The network has reconnected to the database, configuring will complete shortly.</key>
<key name="message_0417">[ Note ] - The old 'ifcfg' style config file: [#!variable!file!#] will be backed up and then removed!</key> <key name="message_0417">[ Note ] - The old 'ifcfg' style config file: [#!variable!file!#] will be backed up and then removed!</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_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_0420">- #!variable!daemon!# #!variable!enabled!# (#!variable!enable_string!#), #!variable!started!# (#!variable!start_string!#), #!variable!failed!# (#!variable!fail_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 -->

@ -28,6 +28,7 @@ my $anvil = Anvil::Tools->new();
$anvil->Get->switches({list => [ $anvil->Get->switches({list => [
"enable", "enable",
"disable", "disable",
"log-only",
"monitor", "monitor",
"now", "now",
"start", "start",
@ -66,14 +67,14 @@ foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemons}{$host_type}}
push @{$daemon_list}, $daemon; push @{$daemon_list}, $daemon;
} }
if ($anvil->data->{switches}{monitor}) if (($anvil->data->{switches}{monitor}) or ($anvil->data->{switches}{'log-only'}))
{ {
# Run as a daemon # Run as a daemon
monitor_daemons($anvil); monitor_daemons($anvil);
} }
elsif ($anvil->data->{switches}{status}) elsif ($anvil->data->{switches}{status})
{ {
report_status($anvil); report_status($anvil, "stdout");
} }
else else
{ {
@ -103,14 +104,20 @@ $anvil->nice_exit({exit_code => 0});
sub report_status sub report_status
{ {
my ($anvil) = @_; my ($anvil, $target) = @_;
# Return Code meanings: # Return Code meanings:
# - Enabled = 0, Disabled = 1 # - Enabled = 0, Disabled = 1
# - Started = 0, Stopped = 3 # - Started = 0, Stopped = 3
# - Failed = 0, OK = 1, # - Failed = 0, OK = 1,
print "Anvil! Intelligent Availability Daemon Status (Enabled, Started, Failed);\n";
check_daemon($anvil); check_daemon($anvil);
my $print = $target eq "stdout" ? 1 : 0;
# Only print the header if we're printing to STDOUT
if ($print)
{
$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};
foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}}) foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}})
{ {
@ -154,7 +161,17 @@ sub report_status
{ {
$say_daemon .= "."; $say_daemon .= ".";
} }
print " - ".$say_daemon." ".$say_enabled." (".$anvil->data->{daemon}{$daemon}{enabled}{string}."), ".$say_started." (".$anvil->data->{daemon}{$daemon}{active}{string}."), ".$say_failed." (".$anvil->data->{daemon}{$daemon}{failed}{string}.")\n";
# Report.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => $print, level => 1, secure => 0, key => "message_0420", variables => {
daemon => $say_daemon,
enabled => $say_enabled,
enable_string => $anvil->data->{daemon}{$daemon}{enabled}{string},
started => $say_started,
start_string => $anvil->data->{daemon}{$daemon}{active}{string},
failed => $say_failed,
fail_string => $anvil->data->{daemon}{$daemon}{failed}{string},
}});
} }
return(0); return(0);
@ -294,7 +311,7 @@ sub process_daemons
print "Done.\n\n"; print "Done.\n\n";
sleep 1; sleep 1;
report_status($anvil); report_status($anvil, "stdout");
return(0); return(0);
} }
@ -315,7 +332,8 @@ sub monitor_daemons
} }
check_daemon($anvil); check_daemon($anvil);
if ($anvil->data->{switches}{monitor})
{
foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}}) foreach my $daemon (sort {$a cmp $b} keys %{$anvil->data->{daemon}})
{ {
# Return code of '1' is OK, '0' is failed. # Return code of '1' is OK, '0' is failed.
@ -341,6 +359,11 @@ sub monitor_daemons
}}); }});
} }
} }
}
else
{
report_status($anvil, "log");
}
if (time > $next_md5sum_check) if (time > $next_md5sum_check)
{ {
@ -353,7 +376,7 @@ sub monitor_daemons
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
} }
} }
sleep 5; sleep 10;
} }
return(0); return(0);

@ -4,7 +4,7 @@ Wants=network.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/sbin/anvil-manage-daemons --monitor ExecStart=/usr/sbin/anvil-manage-daemons --log-only
ExecStop=/bin/kill -WINCH ${MAINPID} ExecStop=/bin/kill -WINCH ${MAINPID}
Restart=always Restart=always
RestartSec=60 RestartSec=60

Loading…
Cancel
Save