From 64b8223f12202748206d8c8d07741a5ea78577c8 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 18:43:09 +0100 Subject: [PATCH 1/3] Revert "Added matrix_data XML" This reverts commit d970c6628a9535a7556e4f2d4493df1866ed9c7b [formerly cd26d436e6745a456df95484120d1b96439b274d]. Former-commit-id: 7f5d3d628605a2458622174edcd56916a3a63cd9 --- pandora_server/lib/PandoraFMS/DataServer.pm | 43 --------------------- 1 file changed, 43 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 3c925f7fb7..3db55cc8f0 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -219,10 +219,6 @@ sub data_consumer ($$) { process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ()); } elsif (defined($xml_data->{'connection_source'})) { enterprise_hook('process_xml_connections', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]); - } elsif (defined($xml_data->{'network_matrix'})){ - process_xml_matrix_network( - $self->getConfig(), $xml_data, $self->getDBH() - ); } else { process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ()); } @@ -1013,44 +1009,5 @@ sub process_events_dataserver { return; } - -########################################################################## -# Process events in the XML. -########################################################################## -sub process_xml_matrix_network { - my ($pa_config, $data, $dbh) = @_; - - my $utimestamp = $data->{'network_matrix'}->[0]->{'utimestamp'}; - my $content = $data->{'network_matrix'}->[0]->{'content'}; - return unless defined($utimestamp) && defined($content); - - # Try to decode the base64 inside - my $matrix_info; - eval { - $matrix_info = decode_json(decode_base64($content)); - }; - - if ($@) { - logger($pa_config, "Error processing base64 matrix data '$content'.", 5); - return; - } - foreach my $source (keys %$matrix_info) { - foreach my $destination (keys %{$matrix_info->{$source}}) { - my $matrix_single_data = $matrix_info->{$source}->{$destination}; - $matrix_single_data->{'source'} = $source; - $matrix_single_data->{'destination'} = $destination; - $matrix_single_data->{'utimestamp'} = $utimestamp; - eval { - db_process_insert($dbh, 'id', 'tnetwork_matrix', $matrix_single_data); - }; - if ($@) { - logger($pa_config, "Error inserted matrix data. Source: $source, destination: $destination, utimestamp: $utimestamp.", 5); - } - } - } - - return; -} - 1; __END__ From 923c8ee0b83ea8be0738a2097ebf29d3899ec0e2 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 18:43:35 +0100 Subject: [PATCH 2/3] Revert "Added tnetwork_matrix data structure" This reverts commit 5328a0e23984a35e565953c1a130d19c503e5343 [formerly aa49de6c04a3c7a612ce7041393fe521e23e281d]. Former-commit-id: 2c762f04c289c46670aab7ed7844ff3880e8d39a --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 14 -------------- pandora_console/pandoradb.sql | 16 +--------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index d0d17dfb18..5dc7cd70c4 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1868,17 +1868,3 @@ CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- ----------------------------------------------------- --- Table `tnetwork_matrix` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( - `id` int(10) unsigned NOT NULL auto_increment, - `source` varchar(60) default '', - `destination` varchar(60) default '', - `utimestamp` bigint(20) default 0, - `bytes` int(18) unsigned default 0, - `pkts` int(18) unsigned default 0, - PRIMARY KEY (`id`), - UNIQUE (`source`, `destination`, `utimestamp`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 42d7ea487c..7f8197540b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3377,18 +3377,4 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( `recursion` int(1) unsigned default '0', `group_search` int(10) unsigned default '0', PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; - --- ----------------------------------------------------- --- Table `tnetwork_matrix` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( - `id` int(10) unsigned NOT NULL auto_increment, - `source` varchar(60) default '', - `destination` varchar(60) default '', - `utimestamp` bigint(20) default 0, - `bytes` int(18) unsigned default 0, - `pkts` int(18) unsigned default 0, - PRIMARY KEY (`id`), - UNIQUE (`source`, `destination`, `utimestamp`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; \ No newline at end of file +) ENGINE = InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file From e540d96eb2ba37443cadcdb3fd72f309831b6e74 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 18:43:47 +0100 Subject: [PATCH 3/3] Revert "Added events in DataServer processed XML" This reverts commit cbe518dc53855766ce440babe6d021791987789e [formerly e3166d9fb2bcbf1b6aa574ae1a96e796a26a70a6]. Former-commit-id: 759a3da8b31fef88d2d7b22daeae09062f3bd80c --- pandora_server/lib/PandoraFMS/DataServer.pm | 49 +-------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 3db55cc8f0..6ff42d34ed 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -29,8 +29,6 @@ use XML::Parser::Expat; use XML::Simple; use POSIX qw(setsid strftime); use IO::Uncompress::Unzip; -use JSON qw(decode_json); -use MIME::Base64; # For Reverse Geocoding use LWP::Simple; @@ -323,7 +321,6 @@ sub process_xml_data ($$$$$) { # Get agent id my $agent_id = get_agent_id ($dbh, $agent_name); - my $group_id = 0; if ($agent_id < 1) { if ($pa_config->{'autocreate'} == 0) { logger($pa_config, "ERROR: There is no agent defined with name $agent_name", 3); @@ -332,7 +329,7 @@ sub process_xml_data ($$$$$) { # Get OS, group and description my $os = pandora_get_os ($dbh, $data->{'os_name'}); - $group_id = $pa_config->{'autocreate_group'}; + my $group_id = $pa_config->{'autocreate_group'}; if (! defined (get_group_name ($dbh, $group_id))) { if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') { $group_id = $data->{'group_id'}; @@ -597,9 +594,6 @@ sub process_xml_data ($$$$$) { # Process snmptrapd modules enterprise_hook('process_snmptrap_data', [$pa_config, $data, $server_id, $dbh]); - - # Process events - process_events_dataserver($pa_config, $data, $agent_id, $group_id, $dbh); } ########################################################################## @@ -968,46 +962,5 @@ sub unlink_modules { db_do($dbh, "UPDATE tagente_modulo SET parent_module_id = 0 WHERE id_agente_modulo = ?", $child_id); } -########################################################################## -# Process events in the XML. -########################################################################## -sub process_events_dataserver { - my ($pa_config, $data, $agent_id, $group_id, $dbh) = @_; - - return unless defined($data->{'events'}); - - foreach my $event (@{$data->{'events'}}) { - next unless defined($event->{'event'}) && defined($event->{'event'}->[0]); - my $event_info_encoded = $event->{'event'}->[0]; - - # Try to decode the base64 inside - my $event_info; - eval { - $event_info = decode_json(decode_base64($event_info_encoded)); - }; - - if ($@) { - logger($pa_config, "Error processing base64 event data '$event_info_encoded'.", 5); - next; - } - next unless defined($event_info->{'data'}); - - pandora_event( - $pa_config, - $event_info->{'data'}, - $group_id, - $agent_id, - defined($event_info->{'severity'}) ? $event_info->{'severity'} : 0, - 0, - 0, - 'system', - 0, - $dbh - ); - } - - return; -} - 1; __END__