fix error histogram and events history graph pandora_enterprise#12209
This commit is contained in:
parent
fa39a97518
commit
ee3df634d6
|
@ -15920,6 +15920,11 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($metaconsole_on && $server_name != '') {
|
||||
// Restore db connection.
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
$filter = [
|
||||
'id_agentmodule' => $content['id_agent_module'],
|
||||
'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'])),
|
||||
];
|
||||
|
||||
if ($metaconsole_on && $server_name != '') {
|
||||
$filter['id_server'] = $connection['id'];
|
||||
}
|
||||
|
||||
$previous_event = events_get_all(
|
||||
['te.event_type, te.timestamp, te.utimestamp'],
|
||||
$filter,
|
||||
|
@ -15953,6 +15962,10 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
|
|||
'time_to' => date('H:i:s', $report['datetime']),
|
||||
];
|
||||
|
||||
if ($metaconsole_on && $server_name != '') {
|
||||
$filter['id_server'] = $connection['id'];
|
||||
}
|
||||
|
||||
$events = events_get_all(
|
||||
['te.event_type, te.timestamp, te.utimestamp'],
|
||||
$filter,
|
||||
|
@ -15963,6 +15976,14 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
|
|||
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 = [];
|
||||
$previous_data = [
|
||||
'event_type' => $status,
|
||||
|
|
|
@ -120,6 +120,23 @@ final class EventsHistory extends Item
|
|||
$moduleId = static::parseIntOr($linkedModule['moduleId'], null);
|
||||
$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) {
|
||||
throw new \InvalidArgumentException('missing agent Id');
|
||||
}
|
||||
|
@ -166,6 +183,11 @@ final class EventsHistory extends Item
|
|||
|
||||
$data['html'] = $html;
|
||||
|
||||
// Restore connection.
|
||||
if ($nodeConnected === true) {
|
||||
\metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue