From df9bc6198d6e6190de72901e7156a3e38099c246 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Tue, 29 Dec 2020 12:04:09 +0100 Subject: [PATCH] Added string exclude filter to events reports --- .../reporting_builder.item_editor.php | 28 +++- .../godmode/reporting/reporting_builder.php | 15 ++ pandora_console/include/functions_events.php | 132 +++++++++++------- .../include/functions_reporting.php | 61 +++++--- 4 files changed, 168 insertions(+), 68 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 52d94006d7..79d30146ce 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -140,6 +140,8 @@ $visual_format = 0; // Others. $filter_search = ''; +$filter_exclude = ''; + // Added for select fields. $total_time = true; @@ -556,6 +558,8 @@ switch ($action) { $include_extended_events = $item['show_extended_events']; $filter_search = $style['event_filter_search']; + $filter_exclude = $style['event_filter_exclude']; + break; case 'event_report_group': @@ -570,6 +574,7 @@ switch ($action) { $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; $filter_search = $style['event_filter_search']; + $filter_exclude = $style['event_filter_exclude']; $filter_event_severity = json_decode($style['filter_event_severity'], true); $filter_event_status = json_decode($style['filter_event_status'], true); @@ -607,6 +612,8 @@ switch ($action) { $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; $filter_search = $style['event_filter_search']; + $filter_exclude = $style['event_filter_exclude']; + $include_extended_events = $item['show_extended_events']; break; @@ -2744,10 +2751,20 @@ $class = 'databox filters'; - + + + + + + + @@ -5141,6 +5158,7 @@ function chooseType() { $("#row_resolution").hide(); $("#row_last_value").hide(); $("#row_filter_search").hide(); + $("#row_filter_exclude").hide(); $("#row_percentil").hide(); $("#log_help_tip").css("visibility", "hidden"); $("#agents_row").hide(); @@ -5191,6 +5209,8 @@ function chooseType() { $("#row_extended_events").show(); $("#row_filter_search").show(); + $("#row_filter_exclude").show(); + $("#row_event_severity").show(); $("#row_event_status").show(); @@ -5486,6 +5506,8 @@ function chooseType() { $("#row_extended_events").show(); $("#row_filter_search").show(); + $("#row_filter_exclude").show(); + $("#row_historical_db_check").hide(); break; @@ -5509,6 +5531,8 @@ function chooseType() { $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); $("#row_filter_search").show(); + $("#row_filter_exclude").show(); + $("#row_historical_db_check").hide(); break; @@ -5531,6 +5555,8 @@ function chooseType() { $('#agent_autocomplete').hide(); $('#agent_autocomplete_events').show(); $("#row_filter_search").show(); + $("#row_filter_exclude").show(); + $("#row_historical_db_check").hide(); break; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 3180fb918e..d5981e2699 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1861,6 +1861,11 @@ switch ($action) { '' ); + $event_filter_exclude = get_parameter( + 'filter_exclude', + '' + ); + // If metaconsole is activated. if (is_metaconsole() === true) { if (($values['type'] == 'custom_graph') @@ -1998,6 +2003,8 @@ switch ($action) { $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; + $style['event_filter_exclude'] = $event_filter_exclude; + if ($label != '') { $style['label'] = $label; @@ -2602,6 +2609,12 @@ switch ($action) { '' ); + $event_filter_exclude = get_parameter( + 'filter_exclude', + '' + ); + + // Added for events items. $style['show_summary_group'] = $show_summary_group; $style['filter_event_severity'] = json_encode( @@ -2619,6 +2632,8 @@ switch ($action) { $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; + $style['event_filter_exclude'] = $event_filter_exclude; + if ($label != '') { $style['label'] = $label; } else { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index cd66fc78a1..99d3dfb697 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2878,20 +2878,21 @@ function events_get_group_events_steps( * * The returned events will be in the time interval ($date - $period, $date] * - * @param integer $id_agent Agent id to get events. - * @param integer $period Period in seconds to get events. - * @param integer $date Beginning date to get events. - * @param boolean $history History. - * @param boolean $show_summary_group Show_summary_group. - * @param boolean $filter_event_severity Filter_event_severity. - * @param boolean $filter_event_type Filter_event_type. - * @param boolean $filter_event_status Filter_event_status. - * @param boolean $filter_event_filter_search Filter_event_filter_search. - * @param boolean $id_group Id_group. - * @param boolean $events_group Events_group. - * @param boolean $id_agent_module Id_agent_module. - * @param boolean $events_module Events_module. - * @param boolean $id_server Id_server. + * @param integer $id_agent Agent id to get events. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @param boolean $history History. + * @param boolean $show_summary_group Show_summary_group. + * @param boolean $filter_event_severity Filter_event_severity. + * @param boolean $filter_event_type Filter_event_type. + * @param boolean $filter_event_status Filter_event_status. + * @param boolean $filter_event_filter_search Filter_event_filter_search. + * @param boolean $id_group Id_group. + * @param boolean $events_group Events_group. + * @param boolean $id_agent_module Id_agent_module. + * @param boolean $events_module Events_module. + * @param boolean $id_server Id_server. + * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude. * * @return array An array with all the events happened. */ @@ -2909,7 +2910,8 @@ function events_get_agent( $events_group=false, $id_agent_module=false, $events_module=false, - $id_server=false + $id_server=false, + $filter_event_filter_exclude=false ) { global $config; @@ -3017,6 +3019,10 @@ function events_get_agent( $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; } + if (!empty($filter_event_filter_exclude)) { + $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")'; + } + if ($events_group) { $secondary_groups = sprintf( ' INNER JOIN tgrupo tg @@ -4996,14 +5002,15 @@ function events_clean_tags($tags) * * The returned events will be in the time interval ($date - $period, $date] * - * @param mixed $id_group Group id to get events for. - * @param integer $period Period in seconds to get events. - * @param integer $date Beginning date to get events. - * @param boolean $filter_event_severity Filter_event_severity. - * @param boolean $filter_event_type Filter_event_type. - * @param boolean $filter_event_status Filter_event_status. - * @param boolean $filter_event_filter_search Filter_event_filter_search. - * @param boolean $dbmeta Dbmeta. + * @param mixed $id_group Group id to get events for. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @param boolean $filter_event_severity Filter_event_severity. + * @param boolean $filter_event_type Filter_event_type. + * @param boolean $filter_event_status Filter_event_status. + * @param boolean $filter_event_filter_search Filter_event_filter_search. + * @param boolean $dbmeta Dbmeta. + * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude. * * @return array An array with all the events happened. */ @@ -5015,7 +5022,8 @@ function events_get_count_events_by_agent( $filter_event_type=false, $filter_event_status=false, $filter_event_filter_search=false, - $dbmeta=false + $dbmeta=false, + $filter_event_filter_exclude=false ) { global $config; @@ -5115,6 +5123,10 @@ function events_get_count_events_by_agent( $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; } + if (!empty($filter_event_filter_exclude)) { + $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")'; + } + $tagente = 'tagente'; $tevento = 'tevento'; @@ -5167,14 +5179,15 @@ function events_get_count_events_by_agent( * * The returned events will be in the time interval ($date - $period, $date] * - * @param array $filter Use target filter. - * @param integer $period Period in seconds to get events. - * @param integer $date Beginning date to get events. - * @param boolean $filter_event_severity Filter_event_severity. - * @param boolean $filter_event_type Filter_event_type. - * @param boolean $filter_event_status Filter_event_status. - * @param boolean $filter_event_filter_search Filter_event_filter_search. - * @param boolean $dbmeta Dbmeta. + * @param array $filter Use target filter. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @param boolean $filter_event_severity Filter_event_severity. + * @param boolean $filter_event_type Filter_event_type. + * @param boolean $filter_event_status Filter_event_status. + * @param boolean $filter_event_filter_search Filter_event_filter_search. + * @param boolean $dbmeta Dbmeta. + * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude. * * @return array An array with all the events happened. */ @@ -5186,7 +5199,8 @@ function events_get_count_events_validated_by_user( $filter_event_type=false, $filter_event_status=false, $filter_event_filter_search=false, - $dbmeta=false + $dbmeta=false, + $filter_event_filter_exclude=false ) { global $config; $tevento = 'tevento'; @@ -5308,6 +5322,10 @@ function events_get_count_events_validated_by_user( $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; } + if (!empty($filter_event_filter_exclude)) { + $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")'; + } + $sql = sprintf( 'SELECT te.id_usuario, @@ -5356,14 +5374,15 @@ function events_get_count_events_validated_by_user( * * The returned events will be in the time interval ($date - $period, $date] * - * @param mixed $filter Target filter. - * @param integer $period Period in seconds to get events. - * @param integer $date Beginning date to get events. - * @param boolean $filter_event_severity Filter_event_severity. - * @param boolean $filter_event_type Filter_event_type. - * @param boolean $filter_event_status Filter_event_status. - * @param boolean $filter_event_filter_search Filter_event_filter_search. - * @param boolean $dbmeta Dbmeta. + * @param mixed $filter Target filter. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @param boolean $filter_event_severity Filter_event_severity. + * @param boolean $filter_event_type Filter_event_type. + * @param boolean $filter_event_status Filter_event_status. + * @param boolean $filter_event_filter_search Filter_event_filter_search. + * @param boolean $dbmeta Dbmeta. + * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude. * * @return array An array with all the events happened. */ @@ -5375,7 +5394,8 @@ function events_get_count_events_by_criticity( $filter_event_type=false, $filter_event_status=false, $filter_event_filter_search=false, - $dbmeta=false + $dbmeta=false, + $filter_event_filter_exclude=false ) { global $config; @@ -5499,6 +5519,10 @@ function events_get_count_events_by_criticity( $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; } + if (!empty($filter_event_filter_exclude)) { + $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")'; + } + $sql = sprintf( 'SELECT te.criticity, @@ -5538,14 +5562,15 @@ function events_get_count_events_by_criticity( * * The returned events will be in the time interval ($date - $period, $date] * - * @param mixed $filter Target filter. - * @param integer $period Period in seconds to get events. - * @param integer $date Beginning date to get events. - * @param boolean $filter_event_severity Filter_event_severity. - * @param boolean $filter_event_type Filter_event_type. - * @param boolean $filter_event_status Filter_event_status. - * @param boolean $filter_event_filter_search Filter_event_filter_search. - * @param boolean $dbmeta Dbmeta. + * @param mixed $filter Target filter. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @param boolean $filter_event_severity Filter_event_severity. + * @param boolean $filter_event_type Filter_event_type. + * @param boolean $filter_event_status Filter_event_status. + * @param boolean $filter_event_filter_search Filter_event_filter_search. + * @param boolean $dbmeta Dbmeta. + * @param boolean $filter_event_filter_exclude Filter_event_filter_exclude. * * @return array An array with all the events happened. */ @@ -5557,7 +5582,8 @@ function events_get_count_events_validated( $filter_event_type=false, $filter_event_status=false, $filter_event_filter_search=false, - $dbmeta=false + $dbmeta=false, + $filter_event_filter_exclude=false ) { global $config; $tevento = 'tevento'; @@ -5710,6 +5736,10 @@ function events_get_count_events_validated( $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; } + if (!empty($filter_event_filter_exclude)) { + $sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")'; + } + $sql = sprintf( 'SELECT te.estado, diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index d5054d4ffd..3a14be44df 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1868,6 +1868,10 @@ function reporting_event_report_group( $return['subtitle'] .= ' ('.$content['style']['event_filter_search'].')'; } + if (!empty($content['style']['event_filter_exclude'])) { + $return['subtitle'] .= ' ('.__('Exclude ').$content['style']['event_filter_exclude'].')'; + } + $return['description'] = $content['description']; $return['show_extended_events'] = $content['show_extended_events']; $return['date'] = reporting_get_date_text($report, $content); @@ -1880,6 +1884,7 @@ function reporting_event_report_group( $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']; // Graphs. $event_graph_by_agent = $event_filter['event_graph_by_agent']; @@ -1919,7 +1924,11 @@ function reporting_event_report_group( $filter_event_status, $filter_event_filter_search, $content['id_group'], - true + true, + false, + false, + false, + $filter_event_filter_exclude ); if (empty($data)) { @@ -1965,7 +1974,8 @@ function reporting_event_report_group( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $return['chart']['by_agent'] = pie_graph( @@ -1990,7 +2000,8 @@ function reporting_event_report_group( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $return['chart']['by_user_validator'] = pie_graph( @@ -2044,7 +2055,8 @@ function reporting_event_report_group( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $return['chart']['validated_vs_unvalidated'] = pie_graph( @@ -2189,6 +2201,7 @@ function reporting_event_report_module( true ); $filter_event_filter_search = $event_filter['event_filter_search']; + $filter_event_filter_exclude = $event_filter['event_filter_exclude']; // Graphs. $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; @@ -2218,7 +2231,8 @@ function reporting_event_report_module( $event_graph_validated_vs_unvalidated, $ttl, $id_server, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); if (empty($data)) { @@ -3259,6 +3273,7 @@ function reporting_event_report_agent( $filter_event_type = json_decode($style['filter_event_type'], true); $filter_event_status = json_decode($style['filter_event_status'], true); $filter_event_filter_search = $style['event_filter_search']; + $filter_event_filter_exclude = $style['event_filter_exclude']; // Graph. $event_graph_by_user_validator = $style['event_graph_by_user_validator']; @@ -3276,7 +3291,8 @@ function reporting_event_report_agent( $filter_event_severity, $filter_event_type, $filter_event_status, - $filter_event_filter_search + $filter_event_filter_search, + $filter_event_filter_exclude ); reporting_set_conf_charts( @@ -3316,7 +3332,8 @@ function reporting_event_report_agent( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $return['chart']['by_user_validator'] = pie_graph( @@ -3341,7 +3358,8 @@ function reporting_event_report_agent( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $colors = get_criticity_pie_colors($data_graph); @@ -3370,7 +3388,8 @@ function reporting_event_report_agent( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $return['chart']['validated_vs_unvalidated'] = pie_graph( @@ -9406,7 +9425,8 @@ function reporting_get_module_detailed_event( $event_graph_validated_vs_unvalidated=false, $ttl=1, $id_server=false, - $metaconsole_dbtable=false + $metaconsole_dbtable=false, + $filter_event_filter_exclude=false ) { global $config; @@ -9442,7 +9462,8 @@ function reporting_get_module_detailed_event( false, $id_module, true, - $id_server + $id_server, + $filter_event_filter_exclude ); // total_events @@ -9470,7 +9491,8 @@ function reporting_get_module_detailed_event( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $event['chart']['by_user_validator'] = pie_graph( @@ -9495,7 +9517,8 @@ function reporting_get_module_detailed_event( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $colors = get_criticity_pie_colors($data_graph); @@ -9524,7 +9547,8 @@ function reporting_get_module_detailed_event( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $metaconsole_dbtable + $metaconsole_dbtable, + $filter_event_filter_exclude ); $event['chart']['validated_vs_unvalidated'] = pie_graph( @@ -9573,7 +9597,8 @@ function reporting_get_agents_detailed_event( $filter_event_severity=false, $filter_event_type=false, $filter_event_status=false, - $filter_event_filter_search=false + $filter_event_filter_search=false, + $filter_event_filter_exclude=false ) { global $config; @@ -9605,7 +9630,11 @@ function reporting_get_agents_detailed_event( $filter_event_status, $filter_event_filter_search, false, - false + false, + false, + false, + false, + $filter_event_filter_exclude ); if (empty($event)) {