add message Database error HA

This commit is contained in:
marcos 2020-05-26 11:00:22 +02:00
parent 1095781725
commit 45f105b662

View File

@ -2454,7 +2454,14 @@ class ConsoleSupervisor
public function checkHaStatus() public function checkHaStatus()
{ {
global $config; global $config;
enterprise_include_once('include/class/DatabaseHA.class.php');
$cluster = new DatabaseHA();
$nodes = $cluster->getNodes();
foreach ($nodes as $node) {
$message = '<pre>The roles played by node '.$node['host'].' are out of sync:
Role in the cluster: Master
Role in the database: Slave Desynchronized operation in the node';
$dbh = @get_dbconnection( $dbh = @get_dbconnection(
[ [
'dbhost' => $node['host'], 'dbhost' => $node['host'],
@ -2464,35 +2471,34 @@ class ConsoleSupervisor
'dbpass' => $config['pandora_db_repl_pass'], 'dbpass' => $config['pandora_db_repl_pass'],
] ]
); );
ob_start();
$message = '<pre>A node in the database cluster is not performing its role correctly:
<br>Role in the cluster: Master
<br>Role in the database: Slave';
$db = db_process_sql( $db = db_process_sql(
'SELECT @@global.read_only',
'info',
$dbh
);
$cluster = db_process_sql(
'SHOW SLAVE STATUS ', 'SHOW SLAVE STATUS ',
'info', 'info',
$dbh $dbh
); );
ob_clean();
if ($cluster == 0 && $db == false) { ob_start();
$cluster = db_process_sql(
'SELECT @@global.read_only',
'info',
$dbh
);
ob_clean();
if ($cluster == $db) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.HAMASTER.MESSAGE', 'type' => 'NOTIF.HAMASTER.MESSAGE',
'title' => __('Database HA has problem '), 'title' => __('Desynchronized operation on the node '.$node['host']),
'message' => __($message), 'message' => __($message),
'url' => ui_get_full_url('index.php'), 'url' => ui_get_full_url('index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster'),
] ]
); );
} else { } else {
$this->cleanNotifications('NOTIF.HAMASTER.MESSAGE'); $this->cleanNotifications('NOTIF.HAMASTER.MESSAGE');
} }
}
} }