fix error histogram and events history graph pandora_enterprise#12209

This commit is contained in:
daniel 2023-12-05 10:35:02 +01:00
parent fa39a97518
commit ee3df634d6
2 changed files with 43 additions and 0 deletions

View File

@ -15920,6 +15920,11 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
return false; return false;
} }
if ($metaconsole_on && $server_name != '') {
// Restore db connection.
metaconsole_restore_db();
}
$filter = [ $filter = [
'id_agentmodule' => $content['id_agent_module'], 'id_agentmodule' => $content['id_agent_module'],
'group_rep' => EVENT_GROUP_REP_ALL, 'group_rep' => EVENT_GROUP_REP_ALL,
@ -15927,6 +15932,10 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
'time_to' => date('H:i:s', ($report['datetime'] - $content['period'])), 'time_to' => date('H:i:s', ($report['datetime'] - $content['period'])),
]; ];
if ($metaconsole_on && $server_name != '') {
$filter['id_server'] = $connection['id'];
}
$previous_event = events_get_all( $previous_event = events_get_all(
['te.event_type, te.timestamp, te.utimestamp'], ['te.event_type, te.timestamp, te.utimestamp'],
$filter, $filter,
@ -15953,6 +15962,10 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
'time_to' => date('H:i:s', $report['datetime']), 'time_to' => date('H:i:s', $report['datetime']),
]; ];
if ($metaconsole_on && $server_name != '') {
$filter['id_server'] = $connection['id'];
}
$events = events_get_all( $events = events_get_all(
['te.event_type, te.timestamp, te.utimestamp'], ['te.event_type, te.timestamp, te.utimestamp'],
$filter, $filter,
@ -15963,6 +15976,14 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
true true
); );
// Metaconsole connection.
if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
ui_print_error_message('Error connecting to '.$server_name);
}
}
$not_init_data = []; $not_init_data = [];
$previous_data = [ $previous_data = [
'event_type' => $status, 'event_type' => $status,

View File

@ -120,6 +120,23 @@ final class EventsHistory extends Item
$moduleId = static::parseIntOr($linkedModule['moduleId'], null); $moduleId = static::parseIntOr($linkedModule['moduleId'], null);
$legendColor = static::extractLegendColor($data); $legendColor = static::extractLegendColor($data);
$metaconsoleId = $linkedModule['metaconsoleId'];
// Maybe connect to node.
$nodeConnected = false;
if (\is_metaconsole() === true && $metaconsoleId !== null) {
$nodeConnected = \metaconsole_connect(
null,
$metaconsoleId
) === NOERR;
if ($nodeConnected === false) {
throw new \InvalidArgumentException(
'error connecting to the node'
);
}
}
if ($agentId === null) { if ($agentId === null) {
throw new \InvalidArgumentException('missing agent Id'); throw new \InvalidArgumentException('missing agent Id');
} }
@ -166,6 +183,11 @@ final class EventsHistory extends Item
$data['html'] = $html; $data['html'] = $html;
// Restore connection.
if ($nodeConnected === true) {
\metaconsole_restore_db();
}
return $data; return $data;
} }