mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Added sync status notifications
This commit is contained in:
parent
976e881cb9
commit
4f2bca1df4
@ -254,7 +254,8 @@ class ConsoleSupervisor
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (is_metaconsole() === true) {
|
if (is_metaconsole() === true) {
|
||||||
$this->checkSyncQueue();
|
$this->checkSyncQueueLength();
|
||||||
|
$this->checkSyncQueueStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -514,7 +515,8 @@ class ConsoleSupervisor
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (is_metaconsole() === true) {
|
if (is_metaconsole() === true) {
|
||||||
$this->checkSyncQueue();
|
$this->checkSyncQueueLength();
|
||||||
|
$this->checkSyncQueueStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2714,14 +2716,14 @@ class ConsoleSupervisor
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function checkSyncQueue()
|
public function checkSyncQueueLength()
|
||||||
{
|
{
|
||||||
if (is_metaconsole() !== true) {
|
if (is_metaconsole() !== true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync = new PandoraFMS\Enterprise\Metaconsole\Synchronizer();
|
$sync = new PandoraFMS\Enterprise\Metaconsole\Synchronizer();
|
||||||
$counts = $sync->counts();
|
$counts = $sync->getQueues(true);
|
||||||
|
|
||||||
if (count($counts) === 0) {
|
if (count($counts) === 0) {
|
||||||
// Clean all.
|
// Clean all.
|
||||||
@ -2760,4 +2762,58 @@ class ConsoleSupervisor
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies the status of synchronization queue and warns if something is
|
||||||
|
* not working as expected.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function checkSyncQueueStatus()
|
||||||
|
{
|
||||||
|
if (is_metaconsole() !== true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sync = new PandoraFMS\Enterprise\Metaconsole\Synchronizer();
|
||||||
|
$queues = $sync->getQueues();
|
||||||
|
if (count($queues) === 0) {
|
||||||
|
// Clean all.
|
||||||
|
$this->cleanNotifications('NOTIF.SYNCQUEUE.STATUS.%');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($queues as $node_id => $queue) {
|
||||||
|
if (count($queue) === 0) {
|
||||||
|
$this->cleanNotifications('NOTIF.SYNCQUEUE.STATUS.'.$node_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = $queue[0];
|
||||||
|
|
||||||
|
if (empty($item->error()) === false) {
|
||||||
|
try {
|
||||||
|
$node = new PandoraFMS\Enterprise\Metaconsole\Node($node_id);
|
||||||
|
$url = '__url__/index.php?sec=advanced&sec2=advanced/metasetup&tab=consoles';
|
||||||
|
|
||||||
|
$this->notify(
|
||||||
|
[
|
||||||
|
'type' => 'NOTIF.SYNCQUEUE.STATUS.'.$node_id,
|
||||||
|
'title' => __('Node %s sync queue failed, ', $node->server_name()),
|
||||||
|
'message' => __(
|
||||||
|
'Node %s cannot process synchronization queue due %s, please check the queue status.',
|
||||||
|
$node->server_name(),
|
||||||
|
$item->error()
|
||||||
|
),
|
||||||
|
'url' => $url,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Clean, exception in node finding.
|
||||||
|
$this->cleanNotifications('NOTIF.SYNCQUEUE.STATUS.'.$node_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user