diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f20ad62eb2..2f09b2ee66 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1523,7 +1523,7 @@ function events_get_all( if (is_metaconsole() === true) { $result_meta = []; - $metaconsole_connections = metaconsole_get_names(); + $metaconsole_connections = metaconsole_get_names(['disabled' => 0]); if (isset($metaconsole_connections) === true && is_array($metaconsole_connections) === true ) { @@ -1539,19 +1539,35 @@ function events_get_all( $result_meta = Promise\wait( parallelMap( $metaconsole_connections, - function ($node) use ($sql) { - if ($node !== 0) { - $node = new Node((int) $node); - $node->connect(); - } + function ($node_int) use ($sql) { + try { + if (is_metaconsole() === true + && (int) $node_int > 0 + ) { + $node = new Node($node_int); + $node->connect(); + } - $res = db_get_all_rows_sql($sql); - if ($res === false) { - $res = []; - } + $res = db_get_all_rows_sql($sql); + if ($res === false) { + $res = []; + } + } catch (\Exception $e) { + // Unexistent agent. + if (is_metaconsole() === true + && $node_int > 0 + ) { + $node->disconnect(); + } - if ($node !== 0) { - $node->disconnect(); + error_log('[events_get_all]'.$e->getMessage()); + return __('Could not connect: %s', $e->getMessage()); + } finally { + if (is_metaconsole() === true + && $node_int > 0 + ) { + $node->disconnect(); + } } return $res; @@ -1575,17 +1591,24 @@ function events_get_all( ], ], 'data' => [], + 'error' => [], ]; + if (empty($result_meta) === false) { foreach ($result_meta as $node => $value) { - $buffers['data'][$node] = count($value); - if (empty($value) === false) { - foreach ($value as $k => $v) { - $value[$k]['server_id'] = $metaconsole_connections[$node]; - $value[$k]['server_name'] = $node; - } + if (is_array($value) === false) { + $buffers['error'][$node] = $value; + $buffers['data'][$node] = 0; + } else { + $buffers['data'][$node] = count($value); + if (empty($value) === false) { + foreach ($value as $k => $v) { + $value[$k]['server_id'] = $metaconsole_connections[$node]; + $value[$k]['server_name'] = $node; + } - $data = array_merge($data, $value); + $data = array_merge($data, $value); + } } } } diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index b4e2b66787..c132fa0873 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1028,6 +1028,12 @@ function process_buffers(buffers) { class_total += " danger"; str_total = buffers.settings.translate.tevn; } + + if (buffers.error[element[0]] !== undefined) { + class_total += " danger"; + str_total = buffers.error[element[0]]; + } + html += '<span class="' + class_total + '">'; html += element[1]; if (str_total != "") { diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 45b405b6e1..5be4945a6a 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -902,6 +902,7 @@ if (is_ajax() === true) { $hashdata = ''; if ($tmp->meta === true) { if (isset($tmp->data_server) === true + && $tmp->data_server !== false && isset($tmp->server_url_hash) === true ) { $server_url = $tmp->data_server['server_url'];