From bf4710ba93a6e7c3d224c38b33b4f21f17211391 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Mon, 15 Mar 2021 13:26:29 +0100 Subject: [PATCH] fixed error events reports --- pandora_console/include/functions_events.php | 23 ++++++++++++++++--- .../include/functions_reporting.php | 14 +++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 543fe06a13..110b153eec 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -3088,7 +3088,7 @@ function events_get_agent( } else { return events_get_events_no_grouped( $sql_where, - (is_metaconsole() && $id_server) ? true : false, + (is_metaconsole() === true && $id_server === false) ? true : false, $history ); } @@ -5263,16 +5263,22 @@ function events_get_count_events_by_agent( $tagente = 'tagente'; $tevento = 'tevento'; + $field_type = 'ta.id_agente'; + if ($dbmeta === true) { + $tagente = 'tmetaconsole_agent'; + $tevento = 'tmetaconsole_event'; + $field_type = 'ta.id_tagente'; + } $sql = sprintf( - 'SELECT + 'SELECT ta.id_agente, ta.alias as agent_name, count(*) as count FROM %s te %s INNER JOIN %s ta - ON te.id_agente = ta.id_agente + ON te.id_agente = %s INNER JOIN tgrupo tg ON (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s)) OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s)) @@ -5281,6 +5287,7 @@ function events_get_count_events_by_agent( $tevento, events_get_secondary_groups_left_join($tevento), $tagente, + $field_type, implode(',', $id_group), implode(',', $id_group), $datelimit, @@ -5338,6 +5345,9 @@ function events_get_count_events_validated_by_user( ) { global $config; $tevento = 'tevento'; + if ($dbmeta === true) { + $tevento = 'tmetaconsole_event'; + } // Group. $tgroup_join = ''; @@ -5360,6 +5370,7 @@ function events_get_count_events_validated_by_user( ); } + $sql_filter = ''; if (!empty($filter['id_agent'])) { $sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']); } @@ -5534,6 +5545,9 @@ function events_get_count_events_by_criticity( global $config; $tevento = 'tevento'; + if ($dbmeta === true) { + $tevento = 'tmetaconsole_event'; + } $sql_filter = ''; $tgroup_join = ''; @@ -5721,6 +5735,9 @@ function events_get_count_events_validated( ) { global $config; $tevento = 'tevento'; + if ($dbmeta === true) { + $tevento = 'tmetaconsole_event'; + } // Group. $sql_filter = ''; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 8e0aafe5fb..9990b7ed94 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1836,9 +1836,8 @@ function reporting_event_report_group( $content['name'] = __('Event Report Group'); } - if ($config['metaconsole']) { + 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); } @@ -1932,7 +1931,7 @@ function reporting_event_report_group( $filter_event_filter_exclude ); - if (empty($data)) { + if (empty($data) === true) { $return['failed'] = __('No events'); } else { $return['data'] = array_reverse($data); @@ -1960,10 +1959,9 @@ function reporting_event_report_group( $return['chart']['by_criticity'] = null; $return['chart']['validated_vs_unvalidated'] = null; $server_name = $content['server_name']; - if (is_metaconsole() && $server_name != '') { + $metaconsole_dbtable = false; + if (is_metaconsole() === true && empty($server_name) === true) { $metaconsole_dbtable = true; - } else { - $metaconsole_dbtable = false; } if ($event_graph_by_agent) { @@ -2073,11 +2071,11 @@ function reporting_event_report_group( ); } - if ($config['metaconsole']) { + if (is_metaconsole() === true) { metaconsole_restore_db(); } - // total_events. + // Total events. if ($return['data'] != '') { $return['total_events'] = count($return['data']); } else {