mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
add message Database error HA
This commit is contained in:
parent
1095781725
commit
45f105b662
@ -2454,45 +2454,51 @@ 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();
|
||||||
|
|
||||||
$dbh = @get_dbconnection(
|
foreach ($nodes as $node) {
|
||||||
[
|
$message = '<pre>The roles played by node '.$node['host'].' are out of sync:
|
||||||
'dbhost' => $node['host'],
|
Role in the cluster: Master
|
||||||
'dbport' => $node['db_port'],
|
Role in the database: Slave Desynchronized operation in the node';
|
||||||
'dbname' => '',
|
$dbh = @get_dbconnection(
|
||||||
'dbuser' => $config['pandora_db_repl_user'],
|
|
||||||
'dbpass' => $config['pandora_db_repl_pass'],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$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(
|
|
||||||
'SELECT @@global.read_only',
|
|
||||||
'info',
|
|
||||||
$dbh
|
|
||||||
);
|
|
||||||
|
|
||||||
$cluster = db_process_sql(
|
|
||||||
'SHOW SLAVE STATUS ',
|
|
||||||
'info',
|
|
||||||
$dbh
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($cluster == 0 && $db == false) {
|
|
||||||
$this->notify(
|
|
||||||
[
|
[
|
||||||
'type' => 'NOTIF.HAMASTER.MESSAGE',
|
'dbhost' => $node['host'],
|
||||||
'title' => __('Database HA has problem '),
|
'dbport' => $node['db_port'],
|
||||||
'message' => __($message),
|
'dbname' => '',
|
||||||
'url' => ui_get_full_url('index.php'),
|
'dbuser' => $config['pandora_db_repl_user'],
|
||||||
|
'dbpass' => $config['pandora_db_repl_pass'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {
|
ob_start();
|
||||||
$this->cleanNotifications('NOTIF.HAMASTER.MESSAGE');
|
$db = db_process_sql(
|
||||||
}
|
'SHOW SLAVE STATUS ',
|
||||||
|
'info',
|
||||||
|
$dbh
|
||||||
|
);
|
||||||
|
ob_clean();
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$cluster = db_process_sql(
|
||||||
|
'SELECT @@global.read_only',
|
||||||
|
'info',
|
||||||
|
$dbh
|
||||||
|
);
|
||||||
|
ob_clean();
|
||||||
|
if ($cluster == $db) {
|
||||||
|
$this->notify(
|
||||||
|
[
|
||||||
|
'type' => 'NOTIF.HAMASTER.MESSAGE',
|
||||||
|
'title' => __('Desynchronized operation on the node '.$node['host']),
|
||||||
|
'message' => __($message),
|
||||||
|
'url' => ui_get_full_url('index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->cleanNotifications('NOTIF.HAMASTER.MESSAGE');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user