From cbe518dc53855766ce440babe6d021791987789e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 15:12:46 +0100 Subject: [PATCH 1/4] Added events in DataServer processed XML Former-commit-id: e3166d9fb2bcbf1b6aa574ae1a96e796a26a70a6 --- pandora_server/lib/PandoraFMS/DataServer.pm | 49 ++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 6ff42d34ed..3db55cc8f0 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -29,6 +29,8 @@ 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; @@ -321,6 +323,7 @@ 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); @@ -329,7 +332,7 @@ sub process_xml_data ($$$$$) { # Get OS, group and description my $os = pandora_get_os ($dbh, $data->{'os_name'}); - my $group_id = $pa_config->{'autocreate_group'}; + $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'}; @@ -594,6 +597,9 @@ 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); } ########################################################################## @@ -962,5 +968,46 @@ 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__ From 5328a0e23984a35e565953c1a130d19c503e5343 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 17:42:41 +0100 Subject: [PATCH 2/4] Added tnetwork_matrix data structure Former-commit-id: aa49de6c04a3c7a612ce7041393fe521e23e281d --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 14 ++++++++++++++ pandora_console/pandoradb.sql | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) 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 5dc7cd70c4..d0d17dfb18 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,3 +1868,17 @@ 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 7f8197540b..42d7ea487c 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3377,4 +3377,18 @@ 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; \ No newline at end of file +) 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 From d970c6628a9535a7556e4f2d4493df1866ed9c7b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 21 Jan 2019 18:27:31 +0100 Subject: [PATCH 3/4] Added matrix_data XML Former-commit-id: cd26d436e6745a456df95484120d1b96439b274d --- pandora_server/lib/PandoraFMS/DataServer.pm | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 3db55cc8f0..3c925f7fb7 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -219,6 +219,10 @@ 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 ()); } @@ -1009,5 +1013,44 @@ 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 c586b68cb33c6ec573ce0cf6a252d84d5a1a08af Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 22 Jan 2019 00:01:24 +0100 Subject: [PATCH 4/4] Auto-updated build strings. Former-commit-id: 84dcfe707e9a70754b4ee72365bd549c8d1c09ef --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 5edf2e031e..46498bd8fe 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.730-190121 +Version: 7.0NG.730-190122 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 47d6c97643..47128ef243 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.730-190121" +pandora_version="7.0NG.730-190122" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 54b12f4f5b..00bb415dc9 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.730'; -use constant AGENT_BUILD => '190121'; +use constant AGENT_BUILD => '190122'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 6fb7b30b81..e4a54348bd 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.730 -%define release 190121 +%define release 190122 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 5bbd32b462..fe3f6aaff7 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.730 -%define release 190121 +%define release 190122 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 47fb301e3b..e95c7c910a 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.730" -PI_BUILD="190121" +PI_BUILD="190122" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 945e983da3..544b0425a4 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190121} +{190122} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index fee3ef8459..34845987ce 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.730(Build 190121)") +#define PANDORA_VERSION ("7.0NG.730(Build 190122)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 71d61237d1..855569fa37 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.730(Build 190121))" + VALUE "ProductVersion", "(7.0NG.730(Build 190122))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index ec72bc0293..11e2512c6c 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.730-190121 +Version: 7.0NG.730-190122 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 7aa7dbadd5..56b66d548d 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.730-190121" +pandora_version="7.0NG.730-190122" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index fd05f10323..1a0e4737e4 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190121'; +$build_version = 'PC190122'; $pandora_version = 'v7.0NG.730'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index ae0e37cbbc..d4aadca58d 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -116,7 +116,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index bc18642b58..d1020c30b2 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.730 -%define release 190121 +%define release 190122 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c89ed5b2f2..798f7c9b5f 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.730 -%define release 190121 +%define release 190122 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 98b3dc1cb8..ccc329991d 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.730" -PI_BUILD="190121" +PI_BUILD="190122" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 74dfd0b39b..fe865df9b5 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.730 PS190121"; +my $version = "7.0NG.730 PS190122"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 338075ed7b..d15b70da59 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.730 PS190121"; +my $version = "7.0NG.730 PS190122"; # save program name for logging my $progname = basename($0);