mirror of
https://github.com/webmin/webmin.git
synced 2025-08-16 14:51:18 +00:00
Fix email report when mysql is down
This commit is contained in:
@ -16,15 +16,9 @@ else {
|
||||
$cmode = 0;
|
||||
}
|
||||
|
||||
if ($cmode) {
|
||||
# Run and check before-backup command (for all DBs)
|
||||
$bok = &execute_before(undef, STDOUT, 0, $config{'backup_'}, undef);
|
||||
if (!$bok) {
|
||||
$failure = "Before-backup command failed!\n";
|
||||
$ex = 1;
|
||||
goto EMAIL;
|
||||
}
|
||||
}
|
||||
$ex = 0;
|
||||
$email = $config{'backup_email_'.($all ? '' : $dbs[0])};
|
||||
$notify = $config{'backup_notify_'.($all ? '' : $dbs[0])};
|
||||
|
||||
# Check if MySQL is running
|
||||
($r, $out) = &is_mysql_running();
|
||||
@ -35,9 +29,16 @@ if (!$r) {
|
||||
goto EMAIL;
|
||||
}
|
||||
|
||||
$ex = 0;
|
||||
$email = $config{'backup_email_'.($all ? '' : $dbs[0])};
|
||||
$notify = $config{'backup_notify_'.($all ? '' : $dbs[0])};
|
||||
if ($cmode) {
|
||||
# Run and check before-backup command (for all DBs)
|
||||
$bok = &execute_before(undef, STDOUT, 0, $config{'backup_'}, undef);
|
||||
if (!$bok) {
|
||||
$failure = "Before-backup command failed!\n";
|
||||
$ex = 1;
|
||||
goto EMAIL;
|
||||
}
|
||||
}
|
||||
|
||||
foreach $db (@dbs) {
|
||||
$sf = $all ? "" : $db;
|
||||
if ($all) {
|
||||
|
@ -119,7 +119,7 @@ sub is_mysql_running
|
||||
if ($driver_handle && !$config{'nodbi'}) {
|
||||
local $main::error_must_die = 1;
|
||||
local ($data, $rv);
|
||||
eval { $data = &execute_sql_safe(undef, "select version()") };
|
||||
eval { $data = &execute_sql_safe(undef, "select version()"); };
|
||||
local $err = $@;
|
||||
$err =~ s/\s+at\s+\S+\s+line.*$//;
|
||||
if ($@ =~ /denied|password/i) {
|
||||
@ -137,7 +137,8 @@ if ($driver_handle && !$config{'nodbi'}) {
|
||||
}
|
||||
|
||||
# Fall back to mysqladmin command
|
||||
local $out = `"$config{'mysqladmin'}" $authstr status 2>&1`;
|
||||
local $out = &backquote_command(
|
||||
"\"$config{'mysqladmin'}\" $authstr status 2>&1");
|
||||
local $rv = $out =~ /uptime/i ? 1 :
|
||||
$out =~ /denied|password/i ? -1 : 0;
|
||||
$out =~ s/^.*\Q$config{'mysqladmin'}\E\s*:\s*//;
|
||||
|
Reference in New Issue
Block a user