From 6e8e5d0dd62f0cff3cdf08619a7249f797793973 Mon Sep 17 00:00:00 2001 From: samucarc Date: Wed, 16 Jan 2019 19:44:29 +0100 Subject: [PATCH] Fixed Event reports pie graphs in metaconsole Former-commit-id: 6fe0eb4035200dc4e22736098b810f31194e1a45 --- pandora_console/include/functions_events.php | 40 ++++++++++++------ .../include/functions_reporting.php | 42 +++++++++++++------ 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 591f3ae89d..5294061294 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2710,7 +2710,7 @@ function events_clean_tags ($tags) { */ function events_get_count_events_by_agent ($id_group, $period, $date, $filter_event_severity = false, $filter_event_type = false, - $filter_event_status = false, $filter_event_filter_search = false) { + $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) { global $config; @@ -2802,16 +2802,22 @@ function events_get_count_events_by_agent ($id_group, $period, $date, ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } + $tagente = 'tagente'; + $tevento = 'tevento'; + if($dbmeta){ + $tagente = 'tmetaconsole_agent'; + $tevento = 'tmetaconsole_event'; + } $sql = sprintf ('SELECT id_agente, (SELECT t2.alias - FROM tagente t2 + FROM %s t2 WHERE t2.id_agente = t3.id_agente) AS agent_name, COUNT(*) AS count - FROM tevento t3 + FROM %s t3 WHERE utimestamp > %d AND utimestamp <= %d AND id_grupo IN (%s) %s GROUP BY id_agente', - $datelimit, $date, implode (",", $id_group), $sql_where); + $tagente, $tevento, $datelimit, $date, implode (",", $id_group), $sql_where); $rows = db_get_all_rows_sql ($sql); @@ -2843,7 +2849,7 @@ function events_get_count_events_by_agent ($id_group, $period, $date, */ function events_get_count_events_validated_by_user ($filter, $period, $date, $filter_event_severity = false, $filter_event_type = false, - $filter_event_status = false, $filter_event_filter_search = false) { + $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) { global $config; //group $sql_filter = ' AND 1=1 '; @@ -2949,16 +2955,20 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } + $tevento = 'tevento'; + if($dbmeta) + $tevento = 'tmetaconsole_event'; + $sql = sprintf ('SELECT id_usuario, (SELECT t2.fullname FROM tusuario t2 WHERE t2.id_user = t3.id_usuario) AS user_name, COUNT(*) AS count - FROM tevento t3 + FROM %s t3 WHERE utimestamp > %d AND utimestamp <= %d %s %s GROUP BY id_usuario', - $datelimit, $date, $sql_filter, $sql_where); + $tevento, $datelimit, $date, $sql_filter, $sql_where); $rows = db_get_all_rows_sql ($sql); if ($rows == false) @@ -2988,7 +2998,7 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, */ function events_get_count_events_by_criticity ($filter, $period, $date, $filter_event_severity = false, $filter_event_type = false, - $filter_event_status = false, $filter_event_filter_search = false) { + $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) { global $config; @@ -3094,13 +3104,16 @@ function events_get_count_events_by_criticity ($filter, $period, $date, ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } + $tevento = 'tevento'; + if ($dbmeta) + $tevento = 'tmetaconsole_event'; $sql = sprintf ('SELECT criticity, COUNT(*) AS count - FROM tevento + FROM %s WHERE utimestamp > %d AND utimestamp <= %d %s %s GROUP BY criticity', - $datelimit, $date, $sql_filter, $sql_where); + $tevento, $datelimit, $date, $sql_filter, $sql_where); $rows = db_get_all_rows_sql ($sql); @@ -3128,7 +3141,7 @@ function events_get_count_events_by_criticity ($filter, $period, $date, */ function events_get_count_events_validated ($filter, $period = null, $date = null, $filter_event_severity = false, $filter_event_type = false, - $filter_event_status = false, $filter_event_filter_search = false) { + $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) { global $config; @@ -3252,7 +3265,10 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; } - $sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s %s GROUP BY estado", $sql_filter, $sql_where); + $tevento = 'tevento'; + if ($dbmeta) + $tevento = 'tmetaconsole_event'; + $sql = sprintf ("SELECT estado, COUNT(*) AS count FROM %s WHERE %s %s GROUP BY estado", $tevento, $sql_filter, $sql_where); $rows = db_get_all_rows_sql ($sql); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3209a61492..9232022886 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1532,12 +1532,17 @@ function reporting_event_report_group($report, $content, $return['chart']['by_user_validator'] = null; $return['chart']['by_criticity'] = null; $return['chart']['validated_vs_unvalidated'] = null; - + $server_name = $content['server_name']; + if (is_metaconsole() && $server_name != '') + $metaconsole_dbtable = true; + else + $metaconsole_dbtable = false; + if ($event_graph_by_agent) { $data_graph = events_get_count_events_by_agent( $content['id_group'], $content['period'], $report["datetime"], $filter_event_severity, $filter_event_type, - $filter_event_status, $filter_event_filter_search); + $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $return['chart']['by_agent']= pie_graph( $data_graph, @@ -1556,7 +1561,7 @@ function reporting_event_report_group($report, $content, $data_graph = events_get_count_events_validated_by_user( array('id_group' => $content['id_group']), $content['period'], $report["datetime"],$filter_event_severity, $filter_event_type, - $filter_event_status, $filter_event_filter_search); + $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $return['chart']['by_user_validator'] = pie_graph( $data_graph, @@ -1575,7 +1580,7 @@ function reporting_event_report_group($report, $content, $data_graph = events_get_count_events_by_criticity( array('id_group' => $content['id_group']), $content['period'], $report["datetime"],$filter_event_severity, $filter_event_type, - $filter_event_status, $filter_event_filter_search); + $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $colors = get_criticity_pie_colors($data_graph); @@ -1598,7 +1603,7 @@ function reporting_event_report_group($report, $content, $data_graph = events_get_count_events_validated( array('id_group' => $content['id_group']), $content['period'], $report["datetime"],$filter_event_severity, $filter_event_type, - $filter_event_status, $filter_event_filter_search); + $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $return['chart']['validated_vs_unvalidated'] = pie_graph( $data_graph, @@ -1679,13 +1684,19 @@ function reporting_event_report_module($report, $content, $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; + + $server_name = $content['server_name']; + if (is_metaconsole() && $server_name != '') + $metaconsole_dbtable = true; + else + $metaconsole_dbtable = false; //data events $data = reporting_get_module_detailed_event ( $content['id_agent_module'], $content['period'], $report["datetime"], $show_summary_group, $filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search, $force_width_chart, $event_graph_by_user_validator, $event_graph_by_criticity, - $event_graph_validated_vs_unvalidated, $ttl, $id_server); + $event_graph_validated_vs_unvalidated, $ttl, $id_server, $metaconsole_dbtable); if (empty($data)) { $return['failed'] = __('No events'); @@ -2449,11 +2460,16 @@ function reporting_event_report_agent($report, $content, $return["chart"]["by_criticity"] = null; $return["chart"]["validated_vs_unvalidated"] = null; + $server_name = $content['server_name']; + if (is_metaconsole() && $server_name != '') + $metaconsole_dbtable = true; + else + $metaconsole_dbtable = false; if ($event_graph_by_user_validator) { $data_graph = events_get_count_events_validated_by_user( array('id_agent' => $content['id_agent']), $content['period'], $report["datetime"],$filter_event_severity, $filter_event_type, - $filter_event_status, $filter_event_filter_search); + $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $return["chart"]["by_user_validator"] = pie_graph( $data_graph, @@ -2472,7 +2488,7 @@ function reporting_event_report_agent($report, $content, $data_graph = events_get_count_events_by_criticity( array('id_agent' => $content['id_agent']), $content['period'], $report["datetime"],$filter_event_severity, $filter_event_type, - $filter_event_status, $filter_event_filter_search); + $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $colors = get_criticity_pie_colors($data_graph); @@ -2495,7 +2511,7 @@ function reporting_event_report_agent($report, $content, $data_graph = events_get_count_events_validated( array('id_agent' => $content['id_agent']), $content['period'], $report["datetime"],$filter_event_severity, $filter_event_type, - $filter_event_status, $filter_event_filter_search); + $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $return["chart"]["validated_vs_unvalidated"] = pie_graph( $data_graph, @@ -6681,7 +6697,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $filter_event_type = false, $filter_event_status = false, $filter_event_filter_search = false, $force_width_chart = false, $event_graph_by_user_validator = false, $event_graph_by_criticity = false, - $event_graph_validated_vs_unvalidated = false, $ttl = 1, $id_server = false) { + $event_graph_validated_vs_unvalidated = false, $ttl = 1, $id_server = false, $metaconsole_dbtable = false) { global $config; @@ -6726,7 +6742,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, if ($event_graph_by_user_validator) { $data_graph = events_get_count_events_validated_by_user( array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, - $filter_event_type, $filter_event_status, $filter_event_filter_search); + $filter_event_type, $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $event['chart']['by_user_validator'] = pie_graph( $data_graph, @@ -6744,7 +6760,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, if ($event_graph_by_criticity) { $data_graph = events_get_count_events_by_criticity( array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, - $filter_event_type, $filter_event_status, $filter_event_filter_search); + $filter_event_type, $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $colors = get_criticity_pie_colors($data_graph); @@ -6766,7 +6782,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, if ($event_graph_validated_vs_unvalidated) { $data_graph = events_get_count_events_validated( array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, - $filter_event_type, $filter_event_status, $filter_event_filter_search); + $filter_event_type, $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable); $event['chart']['validated_vs_unvalidated'] = pie_graph( $data_graph,