add notify on console supervisor

This commit is contained in:
marcos 2020-05-27 13:07:59 +02:00
parent c8bcd3d4fc
commit 73218db337
1 changed files with 10 additions and 5 deletions

View File

@ -2455,13 +2455,15 @@ class ConsoleSupervisor
{ {
global $config; global $config;
enterprise_include_once('include/class/DatabaseHA.class.php'); enterprise_include_once('include/class/DatabaseHA.class.php');
$cluster = new DatabaseHA(); $cluster = new DatabaseHA();
$nodes = $cluster->getNodes(); $nodes = $cluster->getNodes();
foreach ($nodes as $node) { foreach ($nodes as $node) {
$message = '<pre>The roles played by node '.$node['host'].' are out of sync: $message = '<pre>The roles played by node '.$node['host'].' are out of sync:
Role in the cluster: Master Role in the cluster: Master
Role in the database: Slave Desynchronized operation in the node'; Role in the database: Slave Desynchronized operation in the node';
$dbh = @get_dbconnection( $dbh = @get_dbconnection(
[ [
'dbhost' => $node['host'], 'dbhost' => $node['host'],
@ -2473,7 +2475,7 @@ class ConsoleSupervisor
); );
ob_start(); ob_start();
$db = db_process_sql( $db = db_process_sql(
'SHOW SLAVE STATUS ', 'SHOW MASTER STATUS ',
'info', 'info',
$dbh $dbh
); );
@ -2481,12 +2483,14 @@ class ConsoleSupervisor
ob_start(); ob_start();
$cluster = db_process_sql( $cluster = db_process_sql(
'SELECT @@global.read_only', 'SELECT COUNT(1) as maste FROM information_schema.processlist
WHERE command = "binlog dump"',
'info', 'info',
$dbh $dbh
); );
ob_clean(); ob_clean();
if ($cluster != $db) { if ($cluster[0]['maste'] !== '0' && $db !== false) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.HAMASTER.MESSAGE', 'type' => 'NOTIF.HAMASTER.MESSAGE',
@ -2499,6 +2503,7 @@ class ConsoleSupervisor
$this->cleanNotifications('NOTIF.HAMASTER.MESSAGE'); $this->cleanNotifications('NOTIF.HAMASTER.MESSAGE');
} }
} }
} }