From 7bd6f5e05dd6251d7c4b099e5944e61f0fe64639 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Wed, 25 Oct 2017 15:45:19 +0200 Subject: [PATCH 1/4] Added code to snmp filters form --- .../godmode/snmpconsole/snmp_filters.php | 133 ++++++++++++++++-- pandora_console/pandoradb.sql | 1 + 2 files changed, 120 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php index 085b23957d..3def7ed776 100644 --- a/pandora_console/godmode/snmpconsole/snmp_filters.php +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -28,6 +28,7 @@ $update_filter = (int) get_parameter ('update_filter', -2); $delete_filter = (int) get_parameter ('delete_filter', -1); $description = (string) get_parameter ('description', ''); $filter = (string) get_parameter ('filter', ''); +$index_post = (int) get_parameter('index_post', 0); // Create/update header if ($edit_filter > -2) { @@ -45,8 +46,37 @@ else {// Overview header // Create/update filter if ($update_filter > -2) { if ($update_filter > -1) { - $values = array('description' => $description, 'filter' => $filter); - $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $update_filter)); + $new_unified_id = (db_get_value_sql("SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $update_filter)); + $elements = get_parameter('elements', array()); + + if ($index_post == 1) { + $filter = get_parameter('filter_' . $update_filter); + $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $update_filter)); + } + else { + $elements = explode(",", $elements); + foreach ($elements as $e) { + $filter = get_parameter('filter_' . $e); + $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $e)); + } + if (count($elements) == 1) { + $new_unified_id = (db_get_value_sql("SELECT MAX(unified_filters_id) FROM tsnmp_filter")) + 1; + + $filter = get_parameter('filter_' . $elements[0]); + $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $elements[0])); + } + for ($i = 1; $i < $index_post; $i++) { + $filter = get_parameter('filter_' . $i); + $values = array( + 'description' => $description, + 'filter' => $filter, + 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_insert('tsnmp_filter', $values); + } + } if ($result === false) { ui_print_error_message (__('There was a problem updating the filter')); } @@ -55,10 +85,27 @@ if ($update_filter > -2) { } } else { - $values = array( - 'description' => $description, - 'filter' => $filter); - $result = db_process_sql_insert('tsnmp_filter', $values); + $new_unified_id = (db_get_value_sql("SELECT MAX(unified_filters_id) FROM tsnmp_filter")) + 1; + + if ($index_post == 1) { + $filter = get_parameter('filter_0'); + $values = array( + 'description' => $description, + 'filter' => $filter, + 'unified_filters_id' => 0); + $result = db_process_sql_insert('tsnmp_filter', $values); + } + else { + for ($i = 0; $i < $index_post; $i++) { + $filter = get_parameter('filter_' . $i); + $values = array( + 'description' => $description, + 'filter' => $filter, + 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_insert('tsnmp_filter', $values); + } + } + if ($result === false) { ui_print_error_message (__('There was a problem creating the filter')); } @@ -68,6 +115,16 @@ if ($update_filter > -2) { } } else if ($delete_filter > -1) { // Delete + $filters_to_upd = db_get_all_rows_sql("SELECT * FROM tsnmp_filter WHERE unified_filters_id = (SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $delete_filter . ")"); + if (count($filters_to_upd) == 2) { + foreach ($filters_to_upd as $fil) { + if ($fil['id_snmp_filter'] != $delete_filter) { + $values = array('description' => $fil['description'], 'filter' => $fil['filter'], 'unified_filters_id' => 0); + db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $fil['id_snmp_filter'])); + } + } + + } $result = db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $delete_filter)); if ($result === false) { ui_print_error_message (__('There was a problem deleting the filter')); @@ -88,19 +145,46 @@ if ($edit_filter > -1) { // Create/update form if ($edit_filter > -2) { + $index = $index_post; $table->data = array (); + $table->id = 'filter_table'; $table->width = '100%'; $table->class = 'databox filters'; $table->data[0][0] = __('Description'); $table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true); $table->data[1][0] = __('Filter'); - $table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true); - $table->data[1][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); - + if ($edit_filter > -1) { + $filters = db_get_all_rows_sql("SELECT * FROM tsnmp_filter WHERE unified_filters_id = (SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $edit_filter . ")"); + $j = 1; + foreach ($filters as $f) { + if ($j != 1) { + $table->data[$j][0] = ""; + } + $table->data[$j][1] = html_print_input_text ('filter_' . $f['id_snmp_filter'], $f['filter'], '', 60, 100, true); + if ($j == 1) { + $table->data[$j][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); + } + $j++; + } + } + else { + $table->data[1][1] = html_print_input_text ('filter_' . $index, $filter, '', 60, 100, true); + $table->data[1][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); + } + $index++; echo '
'; html_print_input_hidden ('update_filter', $edit_filter); + html_print_input_hidden ('index_post', $index); + if ($edit_filter > -1) { + $filters_to_post = array(); + foreach ($filters as $fil) { + $filters_to_post[] = $fil['id_snmp_filter']; + } + html_print_input_hidden ('elements', implode(",", $filters_to_post)); + } html_print_table ($table); echo '
'; + html_print_image('images/add.png', false, array('id' => 'add_filter', 'alt' => __('Click to add new filter'), 'title' => __('Click to add new filter'), 'style' => 'float:left;')); if ($edit_filter > -1) { html_print_submit_button (__('Update'), 'submit_button', false, 'class="sub upd"'); } @@ -112,7 +196,7 @@ if ($edit_filter > -2) { // Overview } else { - $result = db_get_all_rows_in_table ("tsnmp_filter"); + $result = db_get_all_rows_sql("SELECT * FROM tsnmp_filter ORDER BY unified_filters_id ASC"); if ($result === false) { $result = array (); require_once ($config['homedir'] . "/general/firts_task/snmp_filters.php"); @@ -130,15 +214,22 @@ else { $table->head[0] = __('Description'); $table->head[1] = __('Filter'); - $table->head[2] = __('Action'); - $table->size[2] = "50px"; - $table->align[2] = 'center'; + $table->head[2] = __('Function'); + $table->head[3] = __('Action'); + $table->size[3] = "50px"; + $table->align[3] = 'center'; foreach ($result as $row) { $data = array (); $data[0] = '' . $row['description'] . ''; $data[1] = $row['filter']; - $data[2] = '' . + if ($row['unified_filters_id'] == 0) { + $data[2] = "OR"; + } + else { + $data[2] = "AND (" . $row['unified_filters_id'] . ")"; + } + $data[3] = '' . html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . '  ' . html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; @@ -157,3 +248,17 @@ else { echo '
'; } ?> + + diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 0d749db694..7b8f09de5f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1707,6 +1707,7 @@ CREATE TABLE IF NOT EXISTS `tsnmp_filter` ( `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, `description` varchar(255) default '', `filter` varchar(255) default '', + `unified_filters_id` int(10) not null default 0, PRIMARY KEY (`id_snmp_filter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From efd8c850a06c8118c9c95590bb90f1d9d3517973 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Wed, 25 Oct 2017 16:47:58 +0200 Subject: [PATCH 2/4] Added new filter function to snmp traps --- pandora_server/lib/PandoraFMS/SNMPServer.pm | 38 ++++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index bc7b3a708a..2ea002bb1b 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -345,22 +345,34 @@ sub pandora_snmptrapd { sub matches_filter ($$$) { my ($dbh, $pa_config, $string) = @_; - # Get filters - my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter'); - foreach my $filter (@filters) { - my $regexp = safe_output($filter->{'filter'}) ; - my $eval_result; + my @filter_unique_functions = get_db_rows ($dbh, 'SELECT DISTINCT(unified_filters_id) FROM tsnmp_filter ORDER BY unified_filters_id'); - # eval protects against server down (by invalid regular expressions) - $eval_result = eval { - $string =~ m/$regexp/i ; - }; + foreach my $filter_unique_func (@filter_unique_functions) { + # Get filters + my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter WHERE unified_filters_id = ' . $filter_unique_func->{'unified_filters_id'}); - if ($eval_result) { - logger($pa_config, "Trap '$string' matches filter '$regexp'. Discarding...", 10); - return 1; - } + my $eval_acum = 1; + foreach my $filter (@filters) { + my $regexp = safe_output($filter->{'filter'}) ; + my $eval_result; + # eval protects against server down (by invalid regular expressions) + $eval_result = eval { + $string =~ m/$regexp/i ; + }; + + if ($eval_result && $eval_acum) { + $eval_acum = 1; + } + else { + $eval_acum = 0; + last; + } + } + + if ($eval_acum) { + return 1; + } } return 0; From 91a39ab01e32293eac550f7c2008cb43376f3d9d Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 26 Oct 2017 11:03:08 +0200 Subject: [PATCH 3/4] Added visual upgrades to filter view --- .../godmode/snmpconsole/snmp_filters.php | 151 ++++++++++++------ pandora_console/include/ajax/snmp.ajax.php | 9 ++ pandora_server/lib/PandoraFMS/SNMPServer.pm | 11 +- 3 files changed, 116 insertions(+), 55 deletions(-) diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php index 3def7ed776..9316b36b05 100644 --- a/pandora_console/godmode/snmpconsole/snmp_filters.php +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -45,31 +45,27 @@ else {// Overview header // Create/update filter if ($update_filter > -2) { + // UPDATE if ($update_filter > -1) { $new_unified_id = (db_get_value_sql("SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $update_filter)); $elements = get_parameter('elements', array()); - if ($index_post == 1) { - $filter = get_parameter('filter_' . $update_filter); + $elements = explode(",", $elements); + foreach ($elements as $e) { + $filter = get_parameter('filter_' . $e); $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); - $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $update_filter)); + $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $e)); } - else { - $elements = explode(",", $elements); - foreach ($elements as $e) { - $filter = get_parameter('filter_' . $e); - $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); - $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $e)); - } - if (count($elements) == 1) { - $new_unified_id = (db_get_value_sql("SELECT MAX(unified_filters_id) FROM tsnmp_filter")) + 1; + if (count($elements) == 1) { + $new_unified_id = (db_get_value_sql("SELECT MAX(unified_filters_id) FROM tsnmp_filter")) + 1; - $filter = get_parameter('filter_' . $elements[0]); - $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); - $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $elements[0])); - } - for ($i = 1; $i < $index_post; $i++) { - $filter = get_parameter('filter_' . $i); + $filter = get_parameter('filter_' . $elements[0]); + $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $elements[0])); + } + for ($i = 1; $i < $index_post; $i++) { + $filter = get_parameter('filter_' . $i); + if ($filter != "") { $values = array( 'description' => $description, 'filter' => $filter, @@ -77,6 +73,7 @@ if ($update_filter > -2) { $result = db_process_sql_insert('tsnmp_filter', $values); } } + if ($result === false) { ui_print_error_message (__('There was a problem updating the filter')); } @@ -84,6 +81,7 @@ if ($update_filter > -2) { ui_print_success_message (__('Successfully updated')); } } + // CREATE else { $new_unified_id = (db_get_value_sql("SELECT MAX(unified_filters_id) FROM tsnmp_filter")) + 1; @@ -115,17 +113,15 @@ if ($update_filter > -2) { } } else if ($delete_filter > -1) { // Delete - $filters_to_upd = db_get_all_rows_sql("SELECT * FROM tsnmp_filter WHERE unified_filters_id = (SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $delete_filter . ")"); - if (count($filters_to_upd) == 2) { - foreach ($filters_to_upd as $fil) { - if ($fil['id_snmp_filter'] != $delete_filter) { - $values = array('description' => $fil['description'], 'filter' => $fil['filter'], 'unified_filters_id' => 0); - db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $fil['id_snmp_filter'])); - } - } - + $unified_id_to_delete = (db_get_value_sql("SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $delete_filter)); + + if ($unified_id_to_delete == 0) { + $result = db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $delete_filter)); } - $result = db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $delete_filter)); + else { + $result = db_process_sql_delete('tsnmp_filter', array('unified_filters_id' => $unified_id_to_delete)); + } + if ($result === false) { ui_print_error_message (__('There was a problem deleting the filter')); } @@ -164,7 +160,11 @@ if ($edit_filter > -2) { if ($j == 1) { $table->data[$j][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); } + else { + $table->data[$j][1] .= html_print_image('images/cross.png', true, array('id' => 'delete_filter_' . $f['id_snmp_filter'], 'alt' => __('Click to add new filter'), 'title' => __('Click to add new filter'))); + } $j++; + $index++; } } else { @@ -196,13 +196,13 @@ if ($edit_filter > -2) { // Overview } else { - $result = db_get_all_rows_sql("SELECT * FROM tsnmp_filter ORDER BY unified_filters_id ASC"); - if ($result === false) { - $result = array (); - require_once ($config['homedir'] . "/general/firts_task/snmp_filters.php"); - return; + $result_unified = db_get_all_rows_sql("SELECT DISTINCT(unified_filters_id) FROM tsnmp_filter ORDER BY unified_filters_id ASC"); + + $aglomerate_result = array(); + foreach ($result_unified as $res) { + $aglomerate_result[$res['unified_filters_id']] = db_get_all_rows_sql("SELECT * FROM tsnmp_filter WHERE unified_filters_id = " . $res['unified_filters_id'] . " ORDER BY id_snmp_filter ASC"); } - + $table->data = array (); $table->head = array (); $table->size = array (); @@ -214,26 +214,46 @@ else { $table->head[0] = __('Description'); $table->head[1] = __('Filter'); - $table->head[2] = __('Function'); - $table->head[3] = __('Action'); - $table->size[3] = "50px"; - $table->align[3] = 'center'; - - foreach ($result as $row) { - $data = array (); - $data[0] = '' . $row['description'] . ''; - $data[1] = $row['filter']; - if ($row['unified_filters_id'] == 0) { - $data[2] = "OR"; + $table->head[2] = __('Action'); + $table->size[2] = "50px"; + $table->align[2] = 'center'; + + foreach ($aglomerate_result as $ind => $row) { + if ($ind == 0) { + foreach ($row as $r) { + $data = array (); + $data[0] = '' . $r['description'] . ''; + $data[1] = $r['filter']; + $data[2] = '' . + html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . + '  ' . + html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; + array_push ($table->data, $data); + } } else { - $data[2] = "AND (" . $row['unified_filters_id'] . ")"; + $ind2 = 0; + $compose_filter = array(); + $compose_id = ""; + $compose_action = ""; + foreach ($row as $i => $r) { + if ($ind2 == 0) { + $compose_id = '' . $r['description'] . ''; + $compose_action = '' . + html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . + '  ' . + html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; + $ind2++; + } + $compose_filter[] = $r['filter']; + } + $data = array (); + $data[0] = $compose_id; + $data[1] = implode(" AND ", $compose_filter); + $data[2] = $compose_action; + array_push ($table->data, $data); } - $data[3] = '' . - html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . - '  ' . - html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; - array_push ($table->data, $data); + } if (!empty ($table->data)) { @@ -254,11 +274,38 @@ else { $(document).ready (function () { $('#add_filter').click(function(e) { - $('#filter_table').append(''); + $('#filter_table').append('Click to delete the filter'); id++; $('#hidden-index_post').val(id); }); + + $('[id^=delete_filter_]').click(function(e) { + var elem_id = this.id; + var id_array = elem_id.split("delete_filter_"); + var id = id_array[1]; + + params = {}; + params['page'] = "include/ajax/snmp.ajax"; + params['delete_snmp_filter'] = 1; + params['filter_id'] = id; + + jQuery.ajax ({ + data: params, + type: "POST", + url: "ajax.php", + dataType: "html", + success: function(data){ + var elem = $('#hidden-elements').val(); + $('#hidden-elements').val(elem - 1); + $('#' + elem_id).parent().parent().remove(); + } + }); + }); }); + + function delete_this_row (id_row) { + $('#filter_table-' + id_row).remove(); + } diff --git a/pandora_console/include/ajax/snmp.ajax.php b/pandora_console/include/ajax/snmp.ajax.php index 7b3e45c704..a372d50e11 100644 --- a/pandora_console/include/ajax/snmp.ajax.php +++ b/pandora_console/include/ajax/snmp.ajax.php @@ -20,6 +20,7 @@ require_once("include/functions_snmp.php"); $save_snmp_translation = (bool)get_parameter('save_snmp_translation', 0); $delete_snmp_translation = (bool)get_parameter('delete_snmp_translation', 0); $update_snmp_translation = (bool)get_parameter('update_snmp_translation', 0); +$delete_snmp_filter = (bool)get_parameter('delete_snmp_filter', 0); /* skins image checks */ if ($save_snmp_translation) { @@ -56,4 +57,12 @@ if ($update_snmp_translation) { return; } + +if ($delete_snmp_filter) { + $filter_id = get_parameter('filter_id'); +html_debug($filter_id, true); + db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $filter_id)); + + return; +} ?> diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index 2ea002bb1b..83af3c24ac 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -344,13 +344,18 @@ sub pandora_snmptrapd { ######################################################################################## sub matches_filter ($$$) { my ($dbh, $pa_config, $string) = @_; - + use Data::Dumper; + $Data::Dumper::Sortkeys = 1; my @filter_unique_functions = get_db_rows ($dbh, 'SELECT DISTINCT(unified_filters_id) FROM tsnmp_filter ORDER BY unified_filters_id'); - + Dumper("++++++++++++++++++++++"); + Dumper(@filter_unique_functions); + Dumper("++++++++++++++++++++++"); foreach my $filter_unique_func (@filter_unique_functions) { # Get filters my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter WHERE unified_filters_id = ' . $filter_unique_func->{'unified_filters_id'}); - + Dumper("-----------------------"); + Dumper(@filters); + Dumper("-----------------------"); my $eval_acum = 1; foreach my $filter (@filters) { my $regexp = safe_output($filter->{'filter'}) ; From 3f77b3ae7d9c48c3fb00bbe001243c42e4d44eb3 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 26 Oct 2017 12:01:04 +0200 Subject: [PATCH 4/4] Added changes to snmp server to evaluate all filters in the same virtual world --- pandora_server/lib/PandoraFMS/SNMPServer.pm | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index 83af3c24ac..9328f56c68 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -196,10 +196,10 @@ sub pandora_snmptrapd { my ($pa_config, $line, $server_id, $dbh) = @_; (my $trap_ver, $line) = split(/\[\*\*\]/, $line, 2); - +print STDERR "ANTES"; # Process SNMP filter next if (matches_filter ($dbh, $pa_config, $line) == 1); - +print STDERR "DESPUES"; logger($pa_config, "Reading trap '$line'", 10); my ($date, $time, $source, $oid, $type, $type_desc, $value, $data) = ('', '', '', '', '', '', '', ''); @@ -344,18 +344,13 @@ sub pandora_snmptrapd { ######################################################################################## sub matches_filter ($$$) { my ($dbh, $pa_config, $string) = @_; - use Data::Dumper; - $Data::Dumper::Sortkeys = 1; + my @filter_unique_functions = get_db_rows ($dbh, 'SELECT DISTINCT(unified_filters_id) FROM tsnmp_filter ORDER BY unified_filters_id'); - Dumper("++++++++++++++++++++++"); - Dumper(@filter_unique_functions); - Dumper("++++++++++++++++++++++"); + foreach my $filter_unique_func (@filter_unique_functions) { # Get filters my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter WHERE unified_filters_id = ' . $filter_unique_func->{'unified_filters_id'}); - Dumper("-----------------------"); - Dumper(@filters); - Dumper("-----------------------"); + my $eval_acum = 1; foreach my $filter (@filters) { my $regexp = safe_output($filter->{'filter'}) ;