summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xperl-install/standalone/logdrake51
1 files changed, 27 insertions, 24 deletions
diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake
index e504a529c..6cd68d7a1 100755
--- a/perl-install/standalone/logdrake
+++ b/perl-install/standalone/logdrake
@@ -373,21 +373,22 @@ sub log_output {
sub alert_config() {
$::isWizard = 1;
+ my $conffile = "/etc/sysconfig/mail_alert";
$::Wizard_pix_up = "wiz_logdrake.png"; # FIXME
$::Wizard_title = N("Mail alert");
+ my %options = getVarsFromSh($conffile);
+ $options{LOAD} ||= 3;
+ $options{MAIL} ||= "root";
my $cron = q(#!/usr/bin/perl
# generated by logdrake
use MDK::Common;
my $r;
-
+my %options = getVarsFromSh("/etc/sysconfig/mail_alert");
);
my $initdir = "/etc/init.d";
- my ($load, $email);
- $load = 3;
-
begin:
$::Wizard_finished = 0;
$::Wizard_no_previous = 1;
@@ -409,17 +410,21 @@ my $r;
xinetd => N("Xinetd Service")
};
my @installed_d = grep { -e "$initdir/$_" } sort keys %$service;
- my %services_to_check;
+ my %services_to_check = map { $_ => 1 } split(':', $options{SERVICES});
$in->ask_from(N("service setting"),
N("You will receive an alert if one of the selected services is no longer running"),
[ map { { label => $_, val => \$services_to_check{$_}, type => "bool", text => $service->{$_} } } @installed_d
]) or goto begin;
- $cron .= "#- check services\n";
- foreach (keys %services_to_check) {
- next unless $services_to_check{$_};
- $cron .= qq(\$r .= "Service $_ ($service->{$_} is not running)\\n" unless -e "/var/lock/subsys/$_";\n);
- }
+ use Data::Dumper;
+ $cron .= q(#- check services
+my ) . Data::Dumper->Dump([ $service ], [qw(*services)]) . q(
+foreach (split(':', $options{SERVICES})) {
+ next unless $services{$_};
+ $r .= "Service $_ ($services{$_} is not running)\\n" unless -e "/var/lock/subsys/$_";
+}
+);
+ $options{SERVICES} = join ':', grep { $services_to_check{$_} } sort keys %services_to_check;
step_load:
undef $::Wizard_finished;
@@ -428,15 +433,14 @@ my $r;
N("You will receive an alert if the load is higher than this value"),
[
- { label => N("_: load here is a noun, the load of the system\nLoad"), val => \$load, type => 'range', min => 1, max => 50 },
+ { label => N("_: load here is a noun, the load of the system\nLoad"), val => \$options{LOAD}, type => 'range', min => 1, max => 50 },
]) or goto step_service;
- $cron .= sprintf(<<'EOF', $load);
+ $cron .= q(
#- load
my ($load) = split ' ', first(cat_("/proc/loadavg"));
-$r .= "Load is huge: $load\n" if $load > %s;
-
-EOF
+$r .= "Load is huge: $load\n" if $load > $options{LOAD};
+);
step_output:
# $::Wizard_no_previous = 1;
@@ -445,29 +449,28 @@ EOF
N("Please enter your email address below "),
[
{ label => "" },
- { label => "Email", val => \$email },
+ { label => "Email", val => \$options{MAIL} },
]) or goto step_load;
- if ($email !~ /[\w.-]*\@[\w.-]/) {
+ if ($options{MAIL} !~ /[\w.-]*\@[\w.-]/) {
err_dialog(N("Wrong email"), N("\"%s\" is not a valid email!"));
goto step_output;
}
$cron .= q(#- report it
-
-my $email = ) . "'$email';\n\n";
-
- $cron .= q(if ($r) {
+if ($r) {
my $F;
open $F, '|/usr/sbin/sendmail -oi -t';
- print $F q(Subject: logdrake Mail Alert
-From: root@localhost
-To: ), "$email\n";
+ print $F qq(Subject: logdrake Mail Alert
+From: root\@localhost
+To: $options{MAIL}
+);
print $F "*** " . chomp_(`date`) . " ***\n";
print $F $r;
}
# EOF);
output_with_perm "/etc/cron.hourly/logdrake_service", 0755, $cron;
+ setVarsInSh($conffile, \%options);
undef $::isWizard;
if (defined $::WizardWindow) {