Merge branch 'ent-9762-14476-reporte-de-eventos-de-todos-los-nodos-desde-metaconsola' into 'develop'

fix report agent groups pandora_enterprise#9762

See merge request artica/pandorafms!5250
This commit is contained in:
Diego Muñoz-Reja 2022-11-07 15:55:54 +00:00
commit f637bc12b8
3 changed files with 74 additions and 34 deletions

View File

@ -147,6 +147,7 @@ $image_threshold = false;
$time_compare_overlapped = false;
// Added for events items.
$server_multiple = [0];
$show_summary_group = false;
$filter_event_severity = false;
$filter_event_type = false;
@ -639,9 +640,10 @@ switch ($action) {
$filter_search = $style['event_filter_search'];
$filter_exclude = $style['event_filter_exclude'];
$server_multiple = json_decode($style['server_multiple'], true);
$filter_event_severity = json_decode($style['filter_event_severity'], true);
$filter_event_status = json_decode($style['filter_event_status'], true);
$filter_event_type = json_decode($style['filter_event_type'], true);
$filter_event_status = json_decode($style['filter_event_status'], true);
$filter_event_type = json_decode($style['filter_event_type'], true);
$include_extended_events = $item['show_extended_events'];
@ -1225,6 +1227,37 @@ $class = 'databox filters';
}
?>
<?php
if ($meta) {
?>
<tr id="row_multiple_servers" class="datos">
<td class="bolder"><?php echo __('Server'); ?></td>
<td >
<?php
$server_ids = [];
$server_ids[0] = __('Local metaconsole');
$get_servers = metaconsole_get_servers();
foreach ($get_servers as $key => $server) {
$server_ids[$server['id']] = $server['server_name'];
}
html_print_select(
$server_ids,
'server_multiple[]',
$server_multiple,
'',
'',
0,
false,
true
);
?>
</td>
</tr>
<?php
}
?>
<tr id="row_label" class="datos">
<td class="bolder">
<?php
@ -6173,6 +6206,7 @@ function chooseType() {
$("#row_alert_templates").hide();
$("#row_alert_actions").hide();
$("#row_servers").hide();
$("#row_multiple_servers").hide();
$("#row_sort").hide();
$("#row_date").hide();
$("#row_agent_multi").hide();
@ -6244,7 +6278,7 @@ function chooseType() {
case 'event_report_group':
$("#row_description").show();
$("#row_period").show();
$("#row_servers").show();
$("#row_multiple_servers").show();
$("#row_group").show();
$("#row_event_filter").show();
$("#row_event_graphs").show();

View File

@ -2050,6 +2050,11 @@ switch ($action) {
'show_summary_group',
0
);
$server_multiple = get_parameter(
'server_multiple',
0
);
$filter_event_severity = get_parameter(
'filter_event_severity',
0
@ -2207,8 +2212,11 @@ switch ($action) {
);
switch ($values['type']) {
case 'event_report_agent':
case 'event_report_group':
$style['server_multiple'] = json_encode(
$server_multiple
);
case 'event_report_agent':
case 'event_report_module':
// Added for events items.
$style['show_summary_group'] = $show_summary_group;
@ -2938,10 +2946,16 @@ switch ($action) {
$style['dyn_height'] = get_parameter('dyn_height', 230);
switch ($values['type']) {
case 'event_report_agent':
case 'event_report_group':
$server_multiple = get_parameter(
'server_multiple',
''
);
$style['server_multiple'] = json_encode(
$server_multiple
);
case 'event_report_agent':
case 'event_report_module':
$show_summary_group = get_parameter(
'show_summary_group',
0

View File

@ -2018,26 +2018,8 @@ function reporting_event_report_group(
$content['name'] = __('Event Report Group');
}
$id_meta = 0;
$node_historical_event_enbled = '';
if (is_metaconsole() === true && empty($content['server_name']) === false) {
$id_meta = metaconsole_get_id_server($content['server_name']);
$server = metaconsole_get_connection_by_id($id_meta);
metaconsole_connect($server);
// Check if node historical event is enable.
$sql = sprintf(
'SELECT value
FROM tconfig
WHERE token LIKE "history_event_enabled"'
);
$result = db_get_row_sql($sql);
$node_historical_event_enbled = $result['value'];
}
$history = false;
if ($config['history_event_enabled'] || $node_historical_event_enbled) {
if ($config['history_event_enabled']) {
$history = true;
}
@ -2075,13 +2057,27 @@ function reporting_event_report_group(
$return['show_custom_data'] = (isset($event_filter['custom_data_events']) === true) ? (bool) $event_filter['custom_data_events'] : false;
// Filter.
$show_summary_group = $event_filter['show_summary_group'];
$filter_event_severity = json_decode($event_filter['filter_event_severity'], true);
$filter_event_type = json_decode($event_filter['filter_event_type'], true);
$filter_event_status = json_decode($event_filter['filter_event_status'], true);
$show_summary_group = $event_filter['show_summary_group'];
$filter_event_severity = json_decode($event_filter['filter_event_severity'], true);
$filter_event_type = json_decode($event_filter['filter_event_type'], true);
$filter_event_status = json_decode($event_filter['filter_event_status'], true);
$filter_event_filter_search = $event_filter['event_filter_search'];
$filter_event_filter_exclude = $event_filter['event_filter_exclude'];
$servers = false;
if (is_metaconsole() === true) {
// Only meta by default.
$servers = [0];
if (isset($event_filter['server_multiple']) === true) {
$servers = json_decode($event_filter['server_multiple'], true);
} else {
// Retrocompatibility.
if (empty($content['server_name']) === false) {
$servers = [metaconsole_get_id_server($content['server_name'])];
}
}
}
// Graphs.
$event_graph_by_agent = $event_filter['event_graph_by_agent'];
$event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
@ -2112,10 +2108,6 @@ function reporting_event_report_group(
}
}
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
$data = events_get_agent(
false,
$content['period'],
@ -2130,7 +2122,7 @@ function reporting_event_report_group(
true,
false,
false,
$id_meta,
$servers,
$filter_event_filter_exclude
);