From 936dc728dd8495c4603693dc834260e6c8bd2b8f Mon Sep 17 00:00:00 2001 From: "ismael.moreno" Date: Tue, 19 Nov 2019 17:24:40 +0100 Subject: [PATCH 01/45] Added regexp --- pandora_agents/unix/plugins/pandora_df_used | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora_agents/unix/plugins/pandora_df_used b/pandora_agents/unix/plugins/pandora_df_used index dcddd7f65d..a5a7842a90 100755 --- a/pandora_agents/unix/plugins/pandora_df_used +++ b/pandora_agents/unix/plugins/pandora_df_used @@ -49,7 +49,7 @@ else # Store all "ext" fstypes in @lines array my @lines = split /\n/, `df -khTP | tail -n +2 | awk '{print \$1";"\$2";"\$(NF-1)";"\$NF}' | grep -i "adfs\\|affs\\|autofs\\|btrfs\\|cifs\\|coda\\|coherent\\|efs\\|ext\\|hfs\\|hfsplus\\|hpfs\\|jfs\\|minix\\|msdos\\|ncpfs\\|nfs\\|nfs4\\|ntfs\\|proc\\|qnx4\\|reiserfs\\|smbfs\\|sysv\\|ubifs\\|udf\\|ufs\\|umsdos\\|usbfs\\|vfat\\|xenix\\|xfs\\|xiafs"`; - + chomp (@lines); # To skip indicated filesystems @@ -57,12 +57,16 @@ else { if (substr($fs,0,1) eq '-') { - $excluded_filesystems{substr($fs,1,)} = '-1%'; + my $mount_name=substr($fs,1,); + my @mount_all= split /\n/, `df -khTP | tail -n +2 | awk '{print \$7}'| grep -i "$mount_name"`; + foreach (@mount_all){ + $excluded_filesystems{$_} = '-1%'; + } } else { my @linesmanual = split /\n/, `df -khTP | tail -n +2 | awk '{print \$1";"\$2";"\$(NF-1)";"\$NF}' | grep -i $fs`; - + chomp (@linesmanual); $filesystems{$fs} = '-1%'; From be47ed178bef9f67849721509797495a3a751402 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 5 Feb 2020 12:49:52 +0100 Subject: [PATCH 02/45] Added force apply in policies --- pandora_console/extras/mr/36.sql | 5 +++++ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 ++ pandora_console/pandoradb.sql | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 pandora_console/extras/mr/36.sql diff --git a/pandora_console/extras/mr/36.sql b/pandora_console/extras/mr/36.sql new file mode 100644 index 0000000000..d3de281be5 --- /dev/null +++ b/pandora_console/extras/mr/36.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE `tpolicies` ADD COLUMN `force_apply` tinyint(1) default 0; + +COMMIT; \ No newline at end of file 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 20451647a1..4adf6abfdf 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 @@ -160,6 +160,8 @@ CREATE TABLE IF NOT EXISTS `tpolicies` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `tpolicies` ADD COLUMN `force_apply` tinyint(1) default 0; + -- ----------------------------------------------------- -- Table `tpolicy_alerts` -- ----------------------------------------------------- diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 741a0dc1d8..23d0661036 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2375,8 +2375,9 @@ CREATE TABLE IF NOT EXISTS `tpolicies` ( `id` int(10) unsigned NOT NULL auto_increment, `name` text NOT NULL default '', `description` varchar(255) NOT NULL default '', - `id_group` int(10) unsigned default '0', - `status` int(10) unsigned NOT NULL default 0, + `id_group` int(10) unsigned default '0', + `status` int(10) unsigned NOT NULL default 0, + `force_apply` tinyint(1) default 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 1e4217d1c6829791aadb19b6c737afa66997b740 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 13 Feb 2020 09:22:57 +0100 Subject: [PATCH 03/45] Changed Inserts in tpolicy --- pandora_console/pandoradb_data.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 1cdba8578f..254b4351db 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1200,15 +1200,15 @@ INSERT INTO `tskin` VALUES (2,'Legacy', 'legacy', 'Skin of the vi -- INSERT INTO `tcollection` VALUES (1,'Apache Enterprise Plugin','apache_plugin',0,'Apache Enterprise Plugin to monitor Apache web server using a Perl script.',0); -INSERT INTO `tpolicies` VALUES (1,'Basic Web Checks','Basic checks to monitoring webs',13,0); -INSERT INTO `tpolicies` VALUES (2,'Basic Windows Local Monitoring','Basic checks to monitoring Windows Systems',2,0); -INSERT INTO `tpolicies` VALUES (3,'Basic Centos/RedHat Local Monitoring','Basic local checks to monitoring Centos/RedHat systems',2,0); -INSERT INTO `tpolicies` VALUES (4,'Basic SuSe Local Monitoring','Basic local checks to monitoring SuSe systems',2,0); -INSERT INTO `tpolicies` VALUES (5,'Basic Debian/Ubuntu Local Monitoring','Basic local checks to monitoring Debian/Ubuntu systems',2,0); -INSERT INTO `tpolicies` VALUES (6,'Basic AIX Local Monitoring','Basic local checks to monitoring AIX systems',2,0); -INSERT INTO `tpolicies` VALUES (7,'Basic HP-UX Local Monitoring','Basic local checks to monitoring HP/UX systems',2,0); -INSERT INTO `tpolicies` VALUES (8,'Basic Solaris Local Monitoring','Basic local checks to monitoring Solaris systems',2,0); -INSERT INTO `tpolicies` VALUES (9,'Basic Remote Checks','Basic Remote Checks (ping, latency, ports..)',2,0); +INSERT INTO `tpolicies` VALUES (1,'Basic Web Checks','Basic checks to monitoring webs',13,0,0); +INSERT INTO `tpolicies` VALUES (2,'Basic Windows Local Monitoring','Basic checks to monitoring Windows Systems',2,0,0); +INSERT INTO `tpolicies` VALUES (3,'Basic Centos/RedHat Local Monitoring','Basic local checks to monitoring Centos/RedHat systems',2,0,0); +INSERT INTO `tpolicies` VALUES (4,'Basic SuSe Local Monitoring','Basic local checks to monitoring SuSe systems',2,0,0); +INSERT INTO `tpolicies` VALUES (5,'Basic Debian/Ubuntu Local Monitoring','Basic local checks to monitoring Debian/Ubuntu systems',2,0,0); +INSERT INTO `tpolicies` VALUES (6,'Basic AIX Local Monitoring','Basic local checks to monitoring AIX systems',2,0,0); +INSERT INTO `tpolicies` VALUES (7,'Basic HP-UX Local Monitoring','Basic local checks to monitoring HP/UX systems',2,0,0); +INSERT INTO `tpolicies` VALUES (8,'Basic Solaris Local Monitoring','Basic local checks to monitoring Solaris systems',2,0,0); +INSERT INTO `tpolicies` VALUES (9,'Basic Remote Checks','Basic Remote Checks (ping, latency, ports..)',2,0,0); INSERT INTO `tpolicy_alerts` VALUES (1,1,2,1,'',0,0,0); INSERT INTO `tpolicy_alerts` VALUES (2,1,1,1,'',0,0,0); From 21ae9a192508056c9bfd13641cfd642af9fb4b08 Mon Sep 17 00:00:00 2001 From: "ismael.moreno" Date: Thu, 13 Feb 2020 12:35:28 +0100 Subject: [PATCH 04/45] Fixed description --- .../Advanced Log Parser/pandora_logparser.pl | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/pandora_plugins/Advanced Log Parser/pandora_logparser.pl b/pandora_plugins/Advanced Log Parser/pandora_logparser.pl index 403660d1af..e22878e88a 100644 --- a/pandora_plugins/Advanced Log Parser/pandora_logparser.pl +++ b/pandora_plugins/Advanced Log Parser/pandora_logparser.pl @@ -258,7 +258,7 @@ sub parse_config { $plugin_setup{"log"}->[$log_items]->{"type"} = $1; } - if ($parametro =~ m/^log\_create_module_for_each_log/i) { + if ($parametro =~ m/^log\_create\_module\_for\_each\_log/i) { $plugin_setup{"log"}->[$log_items]->{"module_for_each_log"} = 1; } else { if (!defined($plugin_setup{"log"}->[$log_items]->{"module_for_each_log"})){ @@ -444,7 +444,7 @@ sub create_idx ($$) { # Parse log file starting from position $Idx_pos. ############################################################################### -sub parse_log ($$$$$$$) { +sub parse_log ($$$$$$$$) { my $Idx_file = $_[0]; my $Log_file = $_[1]; my $Idx_pos = $_[2]; @@ -452,6 +452,7 @@ sub parse_log ($$$$$$$) { my $Module_name = $_[4]; my $type = $_[5]; my $regexp_collection = $_[6]; # hash of rules + my $Description = $_[7]; my $line; my $count = 0; @@ -470,7 +471,7 @@ sub parse_log ($$$$$$$) { $buffer .= "\n"; $buffer .= "\n"; - $buffer .= "\n"; + $buffer .= "\n"; if ($type eq "return_ocurrences"){ $buffer .= "generic_data\n"; @@ -482,7 +483,6 @@ sub parse_log ($$$$$$$) { while ($line = ) { while (my ($key, $value) = each (%{$regexp_collection})) { # For each regexp block - $rule = $value->{"rule"}; #print "[DEBUG] Action: ".$value->{"action"} ."\n"; @@ -491,7 +491,6 @@ sub parse_log ($$$$$$$) { #print "[DEBUG] Rule: ".$value->{"rule"} ."\n"; if ($line =~ m/$rule/i) { - # Remove the trailing '\n' chop($line); @@ -594,7 +593,7 @@ sub print_module ($$$$$){ ############################################################################### #manage_logfile($log_filename, $module_name, $readall, $type, $regexp); -sub manage_logfile ($$$$$){ +sub manage_logfile ($$$$$$){ my $Idx_pos; my $Idx_ino; @@ -606,6 +605,7 @@ sub manage_logfile ($$$$$){ my $readall = $_[2]; my $type = $_[3]; my $regexp = $_[4]; + my $description = $_[5]; my $index_file_converted = $log_filename; # Avoid / \ | and : characters @@ -613,9 +613,17 @@ sub manage_logfile ($$$$$){ $index_file_converted =~ s/\\/_/g; $index_file_converted =~ s/\|/_/g; $index_file_converted =~ s/\:/_/g; + $module_name =~ s/\//_/g; + $module_name =~ s/\\/_/g; + $module_name =~ s/\|/_/g; + $module_name =~ s/\:/_/g; # Create index file if it does not exist - $Idx_file = $plugin_setup{"index_dir"} . "/". $module_name . "_" . $index_file_converted . ".idx"; + if($^O =~ /win/i){ + $Idx_file = $plugin_setup{"index_dir"} . "\\". $module_name . "_" . $index_file_converted . "\.idx"; + }else{ + $Idx_file = $plugin_setup{"index_dir"} . "/". $module_name . "_" . $index_file_converted . "\.idx"; + } # if force read all is enabled, if (! -e $Idx_file) { @@ -629,11 +637,11 @@ sub manage_logfile ($$$$$){ } } else { # Load index file - ($Idx_pos, $Idx_ino) = load_idx ($Idx_file, $log_filename); + ($Idx_pos, $Idx_ino) = load_idx ($Idx_file, $log_filename); } # Parse log file - parse_log($Idx_file, $log_filename, $Idx_pos, $Idx_ino, $module_name, $type, $regexp); + parse_log($Idx_file, $log_filename, $Idx_pos, $Idx_ino, $module_name, $type, $regexp, $description); } @@ -672,6 +680,7 @@ my $module_type; my $readall; my $type; my $regexp; +my $description; # Parse external configuration file @@ -700,23 +709,25 @@ while (my ($key, $value) = each (@{$plugin_setup{"log"}})) { $readall = $value->{"readall"}; $type = $value->{"type"}; $regexp = $value->{"regexp"}; + $description = $value->{"description"}; # Check if filename exists if (defined($value->{"log_location_file"})){ $log_filename = $value->{"log_location_file"}; - manage_logfile ($log_filename, $module_name, $readall, $type, $regexp); + manage_logfile ($log_filename, $module_name, $readall, $type, $regexp, $description); } elsif (defined($value->{"log_location_exec"})){ $log_filename = `$value->{"log_location_exec"}`; - manage_logfile ($log_filename, $module_name, $readall, $type, $regexp); + manage_logfile ($log_filename, $module_name, $readall, $type, $regexp, $description); } # Multiple files if (defined($value->{"log_location_multiple"})){ $log_filename_multiple = $value->{"log_location_multiple"}; $log_create_module_for_each_log = $value->{"module_for_each_log"}; - my @buffer = `find $log_filename_multiple`; + #my @buffer = `dir "$log_filename_multiple" /b /a-d`; + my @buffer = `ls -d "$log_filename_multiple"`; foreach (@buffer) { # This should solve problems with carriage return in Unix, Linux and Windooze chomp($_); @@ -729,7 +740,7 @@ while (my ($key, $value) = each (@{$plugin_setup{"log"}})) { $module_name_multiple =~ s/\//_/g; $module_name_multiple = $module_name . "_" . $module_name_multiple; } - manage_logfile ($log_filename, $module_name_multiple, $readall, $type, $regexp); + manage_logfile ($log_filename, $module_name_multiple, $readall, $type, $regexp, $description); } } From 4bdea42c63e59031a38551e9ee27532ff25b279b Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 24 Feb 2020 13:16:22 +0100 Subject: [PATCH 05/45] fix bad parameter in function call --- pandora_console/godmode/users/user_list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 8f0be7654a..be3b02d669 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -302,7 +302,6 @@ if (defined('METACONSOLE')) { __('Users control filter'), __('Toggle filter(s)'), '', - '', !$search ); } From 0e89fd1413983dd261a60253358f4c9dbd2a64d6 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 25 Feb 2020 12:10:26 +0100 Subject: [PATCH 06/45] Fixed deleting logs --- pandora_server/util/pandora_db.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 45fa2d48e7..ca8631c361 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -686,6 +686,7 @@ sub pandora_load_config_pdb ($) { $conf->{'_days_purge_old_information'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'Days_purge_old_information'"); $conf->{'_elasticsearch_ip'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'elasticsearch_ip'"); $conf->{'_elasticsearch_port'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'elasticsearch_port'"); + $conf->{'_server_unique_identifier'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'server_unique_identifier'"); $BIG_OPERATION_STEP = $conf->{'_big_operation_step_datos_purge'} if ( $conf->{'_big_operation_step_datos_purge'} ); From 816123f6ef9c5f2501dd2b5e746d1c6c6996697f Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 25 Feb 2020 17:45:07 +0100 Subject: [PATCH 07/45] Changed logic of inverted interval management --- pandora_agents/unix/pandora_agent | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 1257dc9153..1912598406 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -2621,7 +2621,7 @@ sub cron_next_execution { $nex_time = cron_next_execution_date ($cron, $nex_time, 0); } - return $nex_time - time(); + return $nex_time - $cur_time; } ############################################################################### @@ -2652,7 +2652,7 @@ sub cron_check_interval { if ($down < $up) { return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); } else { - return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); + return 0 if ($elem_curr_time < $down && $elem_curr_time > $up); } return 1; @@ -2676,15 +2676,11 @@ sub cron_next_execution_date { } } - # Get current time - if (! defined ($cur_time)) { - $cur_time = time(); - } # Check if current time + interval is on cron too my $nex_time = $cur_time + $interval; my ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year) = (localtime ($nex_time))[1, 2, 3, 4, 5]; - + my @cron_array = ($min, $hour, $mday, $mon); my @curr_time_array = ($cur_min, $cur_hour, $cur_mday, $cur_mon); return ($nex_time) if cron_is_in_cron(\@cron_array, \@curr_time_array) == 1; @@ -2821,7 +2817,7 @@ sub cron_is_in_cron { # * should returns floor data. # 5 should returns 5. # 10-55 should returns 10. -# 55-10 should retunrs floor data. +# 55-10 should returns elem_down. ################################################################################ sub cron_get_next_time_element { # Default floor data is 0 @@ -2829,7 +2825,7 @@ sub cron_get_next_time_element { $floor_data = 0 unless defined($floor_data); my ($elem_down, $elem_up) = cron_get_interval ($curr_element); - return ($elem_down eq '*' || (defined($elem_up) && $elem_down > $elem_up)) + return ($elem_down eq '*') ? $floor_data : $elem_down; } From b5c5d631c653c0d7757b2d02b31942d7c1954e2e Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 25 Feb 2020 17:50:27 +0100 Subject: [PATCH 08/45] Changed cron functions to allow inverse intervals --- pandora_server/lib/PandoraFMS/Tools.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 2178b2787d..137b5dfb3b 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -1480,7 +1480,7 @@ sub cron_next_execution { $nex_time = cron_next_execution_date ($cron, $nex_time, 0); } - return $nex_time - time(); + return $nex_time - $cur_time; } ############################################################################### # Get the number of seconds left to the next execution of the given cron entry. @@ -1510,7 +1510,7 @@ sub cron_check_interval { if ($down < $up) { return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); } else { - return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); + return 0 if ($elem_curr_time < $down && $elem_curr_time > $up); } return 1; @@ -1675,7 +1675,7 @@ sub cron_is_in_cron { # * should returns floor data. # 5 should returns 5. # 10-55 should returns 10. -# 55-10 should retunrs floor data. +# 55-10 should retunrs elem_down. ################################################################################ sub cron_get_next_time_element { # Default floor data is 0 @@ -1683,7 +1683,7 @@ sub cron_get_next_time_element { $floor_data = 0 unless defined($floor_data); my ($elem_down, $elem_up) = cron_get_interval ($curr_element); - return ($elem_down eq '*' || (defined($elem_up) && $elem_down > $elem_up)) + return ($elem_down eq '*') ? $floor_data : $elem_down; } From 3b9e100f9f27b8b7606e7c1af385b0b51377a446 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 26 Feb 2020 01:00:08 +0100 Subject: [PATCH 09/45] Auto-updated build strings. --- 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.rhel7.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 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 38cb0cb3c0..a6c0f1ecd1 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.743-200225 +Version: 7.0NG.743-200226 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 4518d87ae3..4c621278c0 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.743-200225" +pandora_version="7.0NG.743-200226" 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 e3b162d5cd..98d3a9c315 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.743'; -use constant AGENT_BUILD => '200225'; +use constant AGENT_BUILD => '200226'; # 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 f8c966305d..10d5649817 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.743 -%define release 200225 +%define release 200226 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 61c92de788..db51f701d4 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.743 -%define release 200225 +%define release 200226 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 524cce25e1..002489bcb5 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.743" -PI_BUILD="200225" +PI_BUILD="200226" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 1bcaf8670f..71ab0834a4 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200225} +{200226} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 0e4790a940..f040a056c6 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.743(Build 200225)") +#define PANDORA_VERSION ("7.0NG.743(Build 200226)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7ccdf5c135..0566d55675 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.743(Build 200225))" + VALUE "ProductVersion", "(7.0NG.743(Build 200226))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 156c19fb80..e4d01504de 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.743-200225 +Version: 7.0NG.743-200226 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 ff82fed9f2..345aa9c6de 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.743-200225" +pandora_version="7.0NG.743-200226" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 7b72bcfa1e..b89c70b805 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200225'; +$build_version = 'PC200226'; $pandora_version = 'v7.0NG.743'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index b200f072e3..69b1197687 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 85453c03ba..a087989e35 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.743 -%define release 200225 +%define release 200226 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index f07ee0d43a..978fcebb9b 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.743 -%define release 200225 +%define release 200226 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 45fc796f15..7d2a53d374 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.743" -PI_BUILD="200225" +PI_BUILD="200226" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index ca8631c361..5fdab63ed0 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.743 PS200225"; +my $version = "7.0NG.743 PS200226"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index ae2afe17e5..b4bcdd5689 100755 --- 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.743 PS200225"; +my $version = "7.0NG.743 PS200226"; # save program name for logging my $progname = basename($0); From a0ea52983b74a486641713bd1dd9f0e3f1be22b7 Mon Sep 17 00:00:00 2001 From: vgilc Date: Wed, 26 Feb 2020 14:27:19 +0100 Subject: [PATCH 10/45] Revert "Merge branch 'ent-4239-entities-en-exportacion-de-informes-nodo-meta' into 'develop'" This reverts merge request !2519 --- pandora_console/include/functions.php | 2 + .../include/functions_reporting.php | 3812 ++++++++++------- .../include/functions_reporting_xml.php | 8 + 3 files changed, 2173 insertions(+), 1649 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 693e72d744..85274c4f91 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3081,6 +3081,8 @@ function array2XML($data, $root=null, $xml=null) $node = $xml->addChild($key); array2XML($value, $root, $node); } else { + $value = htmlentities($value); + if (!is_numeric($value) && !is_bool($value)) { if (!empty($value)) { $xml->addChild($key, $value); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 26adab6d06..ad8bc7765a 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1,20 +1,30 @@ $content['id_agent_module'], + ] + ); + + $items_label['module_name'] = $modules[$content['id_agent_module']]['nombre']; + $items_label['module_description'] = $modules[$content['id_agent_module']]['descripcion']; + + if (is_array($content['id_agent']) + && count($content['id_agent']) != 1 + ) { + $content['style']['name_label'] = str_replace( + '_agent_', + count($content['id_agent']).__(' agents'), + $content['style']['name_label'] + ); } - $content['name'] = reporting_label_macro($items_label, $content['style']['name_label']); + if (is_array($content['id_agent_module']) + && count($content['id_agent_module']) != 1 + ) { + $content['style']['name_label'] = str_replace( + '_module_', + count($content['id_agent_module']).__(' modules'), + $content['style']['name_label'] + ); + } if ($metaconsole_on) { // Restore db connection. metaconsole_restore_db(); } + + $content['name'] = reporting_label_macro( + $items_label, + $content['style']['name_label'] + ); } switch (reporting_get_type($content)) { @@ -326,26 +410,32 @@ function reporting_make_reporting_data( break; case 'general': - $report['contents'][] = reporting_general( - $report, - $content + $report['contents'][] = io_safe_output( + reporting_general( + $report, + $content + ) ); break; case 'availability': - $report['contents'][] = reporting_availability( - $report, - $content, - $date, - $time + $report['contents'][] = io_safe_output( + reporting_availability( + $report, + $content, + $date, + $time + ) ); break; case 'availability_graph': - $report['contents'][] = reporting_availability_graph( - $report, - $content, - $pdf + $report['contents'][] = io_safe_output( + reporting_availability_graph( + $report, + $content, + $pdf + ) ); break; @@ -438,46 +528,12 @@ function reporting_make_reporting_data( ); break; - case 'MTTR': - $report['contents'][] = reporting_value( - $report, - $content, - 'MTTR', - $pdf - ); - break; - - case 'MTBF': - $report['contents'][] = reporting_value( - $report, - $content, - 'MTBF', - $pdf - ); - break; - - case 'TTO': - $report['contents'][] = reporting_value( - $report, - $content, - 'TTO', - $pdf - ); - break; - - case 'TTRT': - $report['contents'][] = reporting_value( - $report, - $content, - 'TTRT', - $pdf - ); - break; - case 'agent_configuration': - $report['contents'][] = reporting_agent_configuration( - $report, - $content + $report['contents'][] = io_safe_output( + reporting_agent_configuration( + $report, + $content + ) ); break; @@ -673,12 +729,14 @@ function reporting_make_reporting_data( case 'agent_detailed_event': case 'event_report_agent': - $report_control = reporting_event_report_agent( - $report, - $content, - $type, - $force_width_chart, - $force_height_chart + $report_control = io_safe_output( + reporting_event_report_agent( + $report, + $content, + $type, + $force_width_chart, + $force_height_chart + ) ); if ($report_control['total_events'] == 0 && $content['hide_no_data'] == 1) { continue; @@ -715,7 +773,7 @@ function reporting_make_reporting_data( continue; } - $report['contents'][] = $report_control; + $report['contents'][] = $report_control; break; case 'top_n': @@ -813,8 +871,10 @@ function reporting_SLA( $content['name'] = __('S.L.A.'); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); // Get chart. @@ -840,6 +900,10 @@ function reporting_SLA( $edge_interval = 10; if (empty($content['subitems'])) { + if (is_metaconsole()) { + metaconsole_restore_db(); + } + $slas = db_get_all_rows_field_filter( 'treport_content_sla_combined', 'id_report_content', @@ -1313,7 +1377,9 @@ function reporting_event_top_n( $content['name'] = __('Top N'); } - $return['title'] = io_safe_output($content['name']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $top_n = $content['top_n']; switch ($top_n) { @@ -1333,8 +1399,8 @@ function reporting_event_top_n( } $return['subtitle'] = __('Top %d', $content['top_n_value']).' - '.$type_top_n; - $return['description'] = io_safe_output($content['description']); - $return['date'] = io_safe_output(reporting_get_date_text($report, $content)); + $return['description'] = $content['description']; + $return['date'] = reporting_get_date_text($report, $content); $order_uptodown = $content['order_uptodown']; @@ -1344,11 +1410,15 @@ function reporting_event_top_n( $return['top_n'] = $content['top_n_value']; if (empty($content['subitems'])) { + if (is_metaconsole()) { + metaconsole_restore_db(); + } + // Get all the related data. $sql = sprintf( 'SELECT id_agent_module, server_name - FROM treport_content_item - WHERE id_report_content = %d', + FROM treport_content_item + WHERE id_report_content = %d', $content['id_rc'] ); @@ -1512,7 +1582,10 @@ function reporting_event_top_n( $data['module'] = $module_name[$i]; $data['value'] = $dt; - $data['formated_value'] = format_for_graph($dt, 2).' '.$units[$i]; + + $divisor = get_data_multiplier($units[$i]); + + $data['formated_value'] = format_for_graph($dt, 2, '.', ',', $divisor, $units[$i]); $data_return[] = $data; } @@ -1565,12 +1638,15 @@ function reporting_event_top_n( $data_pie_graph[$item_name] = $data_top[$i]; $data_hbar[$item_name]['g'] = $data_top[$i]; + + $divisor = get_data_multiplier($units[$i]); + if ($show_graph == 0 || $show_graph == 1) { $data = []; $data['agent'] = $an; $data['module'] = $module_name[$i]; $data['value'] = $data_top[$i]; - $data['formated_value'] = format_for_graph($data_top[$i], 2).' '.$units[$i]; + $data['formated_value'] = format_for_graph($data_top[$i], 2, '.', ',', $divisor, $units[$i]); $data_return[] = $data; } @@ -1646,14 +1722,15 @@ function reporting_event_top_n( $i++; } + $unit = $data_top_values['units'][0]; $avg = ($avg / $i); $return['resume']['min']['value'] = $min; - $return['resume']['min']['formated_value'] = format_for_graph($min, 2); + $return['resume']['min']['formated_value'] = format_for_graph($min, 2, '.', ',', $divisor, $unit); $return['resume']['avg']['value'] = $avg; - $return['resume']['avg']['formated_value'] = format_for_graph($avg, 2); + $return['resume']['avg']['formated_value'] = format_for_graph($avg, 2, '.', ',', $divisor, $unit); $return['resume']['max']['value'] = $max; - $return['resume']['max']['formated_value'] = format_for_graph($max, 2); + $return['resume']['max']['formated_value'] = format_for_graph($max, 2, '.', ',', $divisor, $unit); } $return['data'] = $data_return; @@ -1691,13 +1768,15 @@ function reporting_event_report_group( $history = true; } - $return['title'] = io_safe_output($content['name']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = groups_get_name($content['id_group'], true); if (!empty($content['style']['event_filter_search'])) { $return['subtitle'] .= ' ('.$content['style']['event_filter_search'].')'; } - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['show_extended_events'] = $content['show_extended_events']; $return['date'] = reporting_get_date_text($report, $content); @@ -1716,6 +1795,27 @@ function reporting_event_report_group( $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; + if (isset($content['recursion']) && $content['recursion'] == 1 && $content['id_group'] != 0) { + $propagate = db_get_value( + 'propagate', + 'tgrupo', + 'id_grupo', + $content['id_group'] + ); + + if ($propagate) { + $children = groups_get_children($content['id_group']); + $_groups = [ $content['id_group'] ]; + if (!empty($children)) { + foreach ($children as $child) { + $_groups[] = (int) $child['id_grupo']; + } + } + + $content['id_group'] = $_groups; + } + } + $data = events_get_agent( false, $content['period'], @@ -1883,6 +1983,18 @@ function reporting_event_report_group( } +/** + * Events for module reports. + * + * @param array $report Report info. + * @param array $content Content info. + * @param string $type Type retun report. + * @param integer $force_width_chart Width chart. + * @param integer $force_height_chart Height chart. + * @param integer $pdf If pdf report. + * + * @return array + */ function reporting_event_report_module( $report, $content, @@ -1911,34 +2023,75 @@ function reporting_event_report_module( metaconsole_connect(null, $id_server); } - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = agents_get_alias($content['id_agent']).' - '.io_safe_output(modules_get_agentmodule_name($content['id_agent_module'])); + $id_agent = agents_get_module_id( + $content['id_agent_module'] + ); + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + $items_label = [ + 'type' => $content['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $agent_alias.' - '.io_safe_output($module_name); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } if (is_metaconsole()) { metaconsole_restore_db(); } - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['show_extended_events'] = $content['show_extended_events']; $return['date'] = reporting_get_date_text($report, $content); $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; // Filter. - $show_summary_group = $event_filter['show_summary_group']; - $filter_event_severity = json_decode($event_filter['filter_event_severity'], true); - $filter_event_type = json_decode($event_filter['filter_event_type'], true); - $filter_event_status = json_decode($event_filter['filter_event_status'], true); + $show_summary_group = $event_filter['show_summary_group']; + $filter_event_severity = json_decode( + $event_filter['filter_event_severity'], + true + ); + $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']; // Graphs. - $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; - $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; + $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; + $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']; @@ -2005,9 +2158,11 @@ function reporting_inventory_changes($report, $content, $type) metaconsole_connect($server); } - $return['title'] = io_safe_output($content['name']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = agents_get_alias($content['id_agent']); - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $es = json_decode($content['external_source'], true); @@ -2072,8 +2227,10 @@ function reporting_inventory($report, $content, $type) metaconsole_connect($server); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $es = json_decode($content['external_source'], true); @@ -2142,6 +2299,8 @@ function reporting_agent_module($report, $content) } $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $group_name = groups_get_name($content['id_group'], true); if ($content['id_module_group'] == 0) { $module_group_name = __('All'); @@ -2155,7 +2314,7 @@ function reporting_agent_module($report, $content) } $return['subtitle'] = $group_name.' - '.$module_group_name; - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; @@ -2176,7 +2335,7 @@ function reporting_agent_module($report, $content) foreach ($agents as $agent) { $row = []; $row['agent_status'][$agent] = agents_get_status($agent); - $row['agent_name'] = agents_get_alias($agent); + $row['agent_name'] = io_safe_output(agents_get_alias($agent)); $agent_modules = agents_get_modules($agent); $row['modules'] = []; @@ -2230,6 +2389,8 @@ function reporting_exception( } $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $exception_condition = $content['exception_condition']; switch ($exception_condition) { case REPORT_EXCEPTION_CONDITION_EVERYTHING: @@ -2300,7 +2461,7 @@ function reporting_exception( break; } - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['data'] = []; @@ -2311,11 +2472,14 @@ function reporting_exception( // Get all the related data. $sql = sprintf( ' - SELECT id_agent_module, server_name, operation - FROM treport_content_item - WHERE id_report_content = %d', + SELECT id_agent_module, server_name, operation + FROM treport_content_item + WHERE id_report_content = %d', $content['id_rc'] ); + if (is_metaconsole()) { + metaconsole_restore_db(); + } $exceptions = db_process_sql($sql); } else { @@ -2701,16 +2865,17 @@ function reporting_group_report($report, $content) $content['name'] = __('Group Report'); } - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content['server_name']); - - $server = metaconsole_get_connection_by_id($id_meta); - metaconsole_connect($server); + if (is_metaconsole()) { + $server = metaconsole_get_connection_names(); + $connection = metaconsole_get_connection($server); } - $return['title'] = io_safe_output($content['name']); + $return['server_name'] = $server[0]; + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = groups_get_name($content['id_group'], true); - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['data'] = []; @@ -2776,9 +2941,45 @@ function reporting_event_report_agent( $history = true; } - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = agents_get_alias($content['id_agent']); - $return['description'] = io_safe_output($content['description']); + $id_server = false; + if (is_metaconsole()) { + $id_server = metaconsole_get_id_server($content['server_name']); + metaconsole_connect(null, $id_server); + } + + $id_agent = $content['id_agent']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + ]; + + if ($config['metaconsole']) { + metaconsole_restore_db(); + } + + $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + if ($label != '') { + $label = reporting_label_macro( + $items_label, + $label + ); + } + + $return['label'] = $label; + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = io_safe_output($agent_alias); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['show_summary_group'] = $content['style']['show_summary_group']; @@ -2840,13 +3041,6 @@ function reporting_event_report_agent( $metaconsole_dbtable = false; } - $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - if ($label != '') { - $label = reporting_label_macro($content, $label); - } - - $return['label'] = $label; - if ($event_graph_by_user_validator) { $data_graph = events_get_count_events_validated_by_user( ['id_agent' => $content['id_agent']], @@ -2926,10 +3120,6 @@ function reporting_event_report_agent( ); } - if ($config['metaconsole']) { - metaconsole_restore_db(); - } - // Total events. if ($return['data'] != '') { $return['total_events'] = count($return['data']); @@ -2941,32 +3131,74 @@ function reporting_event_report_agent( } +/** + * Show historical data. + * + * @param array $report Data report. + * @param array $content Content report. + * + * @return array + */ function reporting_historical_data($report, $content) { global $config; $return['type'] = 'historical_data'; $period = $content['period']; - $date_limit = (time() - $period); + $date_limit = ($report['datetime'] - $period); if (empty($content['name'])) { $content['name'] = __('Historical data'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) + if (is_metaconsole()) { + $id_meta = metaconsole_get_id_server($content['server_name']); + + $server = metaconsole_get_connection_by_id($id_meta); + $connection = metaconsole_connect($server); + } + + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = io_safe_output(agents_get_alias($id_agent)); + $module_name = io_safe_output( + modules_get_agentmodule_name( + $id_agent_module + ) + ); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module ); - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = io_safe_output($content['description']); + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $agent_alias.' - '.$module_name; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $return['keys'] = [ @@ -2991,7 +3223,7 @@ function reporting_historical_data($report, $content) FROM tagente_datos_string WHERE id_agente_modulo ='.$content['id_agent_module'].' AND utimestamp >'.$date_limit.' - AND utimestamp <='.time(), + AND utimestamp <='.$report['datetime'], true ); break; @@ -3002,7 +3234,7 @@ function reporting_historical_data($report, $content) FROM tagente_datos WHERE id_agente_modulo ='.$content['id_agent_module'].' AND utimestamp >'.$date_limit.' - AND utimestamp <='.time(), + AND utimestamp <='.$report['datetime'], true ); break; @@ -3018,10 +3250,22 @@ function reporting_historical_data($report, $content) $return['data'] = $data; + if (is_metaconsole() && $connection > 0) { + metaconsole_restore_db(); + } + return reporting_check_structure_content($return); } +/** + * Show data serialized. + * + * @param array $report Data report. + * @param array $content Content report. + * + * @return array + */ function reporting_database_serialized($report, $content) { global $config; @@ -3032,17 +3276,47 @@ function reporting_database_serialized($report, $content) $content['name'] = __('Database Serialized'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + if (is_metaconsole()) { + $id_meta = metaconsole_get_id_server($content['server_name']); + $server = metaconsole_get_connection_by_id($id_meta); + metaconsole_connect($server); + } + + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = io_safe_output($content['description']); - $return['date'] = io_safe_output(reporting_get_date_text($report, $content)); + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $agent_alias.' - '.$module_name; + $return['description'] = $content['description']; + $return['date'] = reporting_get_date_text($report, $content); $keys = []; if (isset($content['header_definition']) && ($content['header_definition'] != '')) { @@ -3050,51 +3324,40 @@ function reporting_database_serialized($report, $content) } $return['keys'] = $keys; - - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_name($content['id_agent_module']) - ); - - $return['agent_name'] = $agent_name; + $return['agent_name_db'] = agents_get_name($id_agent); + $return['agent_name'] = $agent_alias; $return['module_name'] = $module_name; - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content['server_name']); - - $server = metaconsole_get_connection_by_id($id_meta); - metaconsole_connect($server); - } - $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $datelimit = ($report['datetime'] - $content['period']); $search_in_history_db = db_search_in_history_db($datelimit); - // This query gets information from the default and the historic database + // This query gets information from the default and the historic database. $result = db_get_all_rows_sql( 'SELECT * - FROM tagente_datos - WHERE id_agente_modulo = '.$content['id_agent_module'].' - AND utimestamp > '.$datelimit.' - AND utimestamp <= '.$report['datetime'], + FROM tagente_datos + WHERE id_agente_modulo = '.$content['id_agent_module'].' + AND utimestamp > '.$datelimit.' + AND utimestamp <= '.$report['datetime'], $search_in_history_db ); - // Adds string data if there is no numeric data - if ((count($result) < 0) or (!$result)) { - // This query gets information from the default and the historic database + // Adds string data if there is no numeric data. + if ((count($result) < 0) || (!$result)) { + // This query gets information from the default and the historic database. $result = db_get_all_rows_sql( 'SELECT * - FROM tagente_datos_string - WHERE id_agente_modulo = '.$content['id_agent_module'].' - AND utimestamp > '.$datelimit.' - AND utimestamp <= '.$report['datetime'], + FROM tagente_datos_string + WHERE id_agente_modulo = '.$content['id_agent_module'].' + AND utimestamp > '.$datelimit.' + AND utimestamp <= '.$report['datetime'], $search_in_history_db ); } @@ -3108,13 +3371,16 @@ function reporting_database_serialized($report, $content) $date = date($config['date_format'], $row['utimestamp']); $serialized_data = $row['datos']; - // Cut line by line + // Cut line by line. if (empty($content['line_separator']) || empty($serialized_data) ) { $rowsUnserialize = [$row['datos']]; } else { - $rowsUnserialize = explode($content['line_separator'], $serialized_data); + $rowsUnserialize = explode( + $content['line_separator'], + $serialized_data + ); } foreach ($rowsUnserialize as $rowUnser) { @@ -3130,7 +3396,10 @@ function reporting_database_serialized($report, $content) $row['data'][][$keys[0]] = $rowUnser; } } else { - $columnsUnserialize = explode($content['column_separator'], $rowUnser); + $columnsUnserialize = explode( + $content['column_separator'], + $rowUnser + ); $i = 0; $temp_row = []; @@ -3180,10 +3449,12 @@ function reporting_group_configuration($report, $content) $group_name = groups_get_name($content['id_group'], true); - $return['title'] = io_safe_output($content['name']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = $group_name; - $return['description'] = io_safe_output($content['description']); - $return['date'] = io_safe_output(reporting_get_date_text($report, $content)); + $return['description'] = $content['description']; + $return['date'] = reporting_get_date_text($report, $content); $return['id_group'] = $content['id_group']; if ($content['id_group'] == 0) { @@ -3199,9 +3470,9 @@ function reporting_group_configuration($report, $content) } } else { $sql = ' - SELECT * - FROM tagente - WHERE id_grupo='.$content['id_group']; + SELECT * + FROM tagente + WHERE id_grupo='.$content['id_group']; } $agents_list = db_get_all_rows_sql($sql); @@ -3253,10 +3524,12 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic', $group_name = groups_get_name($content['id_group']); - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = io_safe_output($group_name); - $return['description'] = io_safe_output($content['description']); - $return['date'] = io_safe_output(reporting_get_date_text($report, $content)); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $group_name; + $return['description'] = $content['description']; + $return['date'] = reporting_get_date_text($report, $content); include_once $config['homedir'].'/include/functions_custom_graphs.php'; @@ -3268,7 +3541,8 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic', $return['failed'] = null; $return['data'] = []; - if ($config['metaconsole']) { + if (is_metaconsole()) { + metaconsole_restore_db(); $server_names = metaconsole_get_connection_names(); if (isset($server_names) && is_array($server_names)) { foreach ($server_names as $key => $value) { @@ -3285,7 +3559,8 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic', $content, $report, $fullscale, - $pdf + $pdf, + $id_meta ); metaconsole_restore_db(); } @@ -3338,15 +3613,17 @@ function agents_get_network_interfaces_array( $width = null; $params = [ - 'period' => $content['period'], - 'width' => $width, - 'unit_name' => array_fill(0, count($interface['traffic']), __('bytes/s')), - 'date' => $report['datetime'], - 'only_image' => $pdf, - 'homeurl' => $config['homeurl'], - 'fullscale' => $fullscale, - 'server_id' => $id_meta, - 'height' => $config['graph_image_height'], + 'period' => $content['period'], + 'width' => $width, + 'unit_name' => array_fill(0, count($interface['traffic']), __('bytes/s')), + 'date' => $report['datetime'], + 'only_image' => $pdf, + 'homeurl' => $config['homeurl'], + 'fullscale' => $fullscale, + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'], + 'landscape' => $content['landscape'], + 'return_img_base_64' => true, ]; $params_combined = [ @@ -3358,11 +3635,21 @@ function agents_get_network_interfaces_array( case 'dinamic': case 'static': if (!empty($interface['traffic'])) { - $row_interface['chart'] = graphic_combined_module( - array_values($interface['traffic']), - $params, - $params_combined - ); + if ($pdf === false) { + $row_interface['chart'] = graphic_combined_module( + array_values($interface['traffic']), + $params, + $params_combined + ); + } else { + $row_interface['chart'] = ''; + } } break; @@ -3392,7 +3679,7 @@ function agents_get_network_interfaces_array( /** * reporting alert get fired */ -function reporting_alert_get_fired($id_agent_module, $id_alert_template_module, $period, $datetime) +function reporting_alert_get_fired($id_agent_module, $id_alert_template_module, $period, $datetime, $return_empty=true) { $fired = []; $firedTimes = get_module_alert_fired( @@ -3422,7 +3709,11 @@ function reporting_alert_get_fired($id_agent_module, $id_alert_template_module, if ($fireTime['utimestamp'] > $datelimit && $fireTime['utimestamp'] <= $datetime) { $fired[] = $fireTime['timestamp']; } else { - $fired[] = $empty; + if ($return_empty === true) { + $fired[] = $empty; + } else { + continue; + } } } @@ -3452,33 +3743,35 @@ function reporting_alert_report_group($report, $content) $group_name = groups_get_name($content['id_group'], true); - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = io_safe_output($group_name); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $group_name; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); if ($content['id_group'] == 0) { $agent_modules = db_get_all_rows_sql( ' - SELECT distinct(id_agent_module) - FROM talert_template_modules - WHERE disabled = 0 - AND id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo)' + SELECT distinct(id_agent_module) + FROM talert_template_modules + WHERE disabled = 0 + AND id_agent_module IN ( + SELECT id_agente_modulo + FROM tagente_modulo)' ); } else { $agent_modules = db_get_all_rows_sql( ' - SELECT distinct(id_agent_module) - FROM talert_template_modules - WHERE disabled = 0 - AND id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_agente IN ( - SELECT id_agente - FROM tagente WHERE id_grupo = '.$content['id_group'].'))' + SELECT distinct(id_agent_module) + FROM talert_template_modules + WHERE disabled = 0 + AND id_agent_module IN ( + SELECT id_agente_modulo + FROM tagente_modulo + WHERE id_agente IN ( + SELECT id_agente + FROM tagente WHERE id_grupo = '.$content['id_group'].'))' ); } @@ -3532,10 +3825,15 @@ function reporting_alert_report_group($report, $content) foreach ($actions['custom'] as $action) { $data_action[$naction]['name'] = $action['name']; $fired = $action['fired']; - if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)) { - $data_action[$naction]['fired'] = '----------------------------'; - } else { - $data_action[$naction]['fired'] = $fired; + + if ($fired == 0) { + $data_action[$naction]['fired'] = __('Not triggered'); + } else if ($fired > 0) { + if ($fired > $datelimit && $fired < $datetime) { + $data_action[$naction]['fired'] = $fired; + } else { + continue 2; + } } $naction++; @@ -3544,10 +3842,15 @@ function reporting_alert_report_group($report, $content) foreach ($actions['default'] as $action) { $data_action[$naction]['name'] = $action['name']; $fired = $action['fired']; - if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)) { - $data_action[$naction]['fired'] = '----------------------------'; - } else { - $data_action[$naction]['fired'] = $fired; + + if ($fired == 0) { + $data_action[$naction]['fired'] = __('Not triggered'); + } else if ($fired > 0) { + if ($fired > $datelimit && $fired < $datetime) { + $data_action[$naction]['fired'] = $fired; + } else { + continue 2; + } } $naction++; @@ -3556,10 +3859,15 @@ function reporting_alert_report_group($report, $content) foreach ($actions['unavailable'] as $action) { $data_action[$naction]['name'] = $action['name']; $fired = $action['fired']; - if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)) { - $data_action[$naction]['fired'] = '----------------------------'; - } else { - $data_action[$naction]['fired'] = $fired; + + if ($fired == 0) { + $data_action[$naction]['fired'] = __('Not triggered'); + } else if ($fired > 0) { + if ($fired > $datelimit && $fired < $datetime) { + $data_action[$naction]['fired'] = $fired; + } else { + continue 2; + } } $naction++; @@ -3573,7 +3881,8 @@ function reporting_alert_report_group($report, $content) $agent_module['id_agent_module'], $actions['id'], (int) $content['period'], - (int) $report['datetime'] + (int) $report['datetime'], + false ); $module_actions['actions'] = $data_action; @@ -3596,6 +3905,14 @@ function reporting_alert_report_group($report, $content) } +/** + * Report alert agent. + * + * @param array $report Info report. + * @param array $content Content report. + * + * @return array + */ function reporting_alert_report_agent($report, $content) { global $config; @@ -3613,16 +3930,35 @@ function reporting_alert_report_agent($report, $content) metaconsole_connect($server); } - $agent_name = agents_get_alias($content['id_agent']); + $id_agent = $content['id_agent']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = io_safe_output($agent_name); - $return['description'] = io_safe_output($content['description']); + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + ]; + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $agent_alias; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $module_list = agents_get_modules($content['id_agent']); @@ -3630,10 +3966,10 @@ function reporting_alert_report_agent($report, $content) $data = []; foreach ($module_list as $id => $module_name) { $data_row = []; - $data_row['agent'] = $agent_name; + $data_row['agent'] = $agent_alias; $data_row['module'] = $module_name; - // Alerts over $id_agent_module + // Alerts over $id_agent_module. $alerts = alerts_get_effective_alert_actions($id); if ($alerts === false) { @@ -3727,6 +4063,14 @@ function reporting_alert_report_agent($report, $content) } +/** + * Alert report module. + * + * @param array $report Info report. + * @param array $content Content report. + * + * @return array + */ function reporting_alert_report_module($report, $content) { global $config; @@ -3744,36 +4088,58 @@ function reporting_alert_report_module($report, $content) metaconsole_connect($server); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module ); - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = io_safe_output($content['description']); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $agent_alias.' - '.$module_name; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } $data_row = []; - $data_row['agent'] = io_safe_output( - agents_get_alias( - agents_get_agent_id_by_module_id($content['id_agent_module']) - ) - ); + $data_row['agent'] = io_safe_output($agent_alias); $data_row['module'] = db_get_value_filter( 'nombre', 'tagente_modulo', ['id_agente_modulo' => $content['id_agent_module']] ); - // Alerts over $id_agent_module + // Alerts over $id_agent_module. $alerts = alerts_get_effective_alert_actions($content['id_agent_module']); $ntemplates = 0; @@ -3902,7 +4268,7 @@ function reporting_sql_graph( } } - // Get chart + // Get chart. reporting_set_conf_charts($width, $height, $only_image, $type, $content, $ttl); if (!empty($force_width_chart)) { @@ -3913,10 +4279,25 @@ function reporting_sql_graph( $height = $force_height_chart; } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text(); + $module_source = db_get_all_rows_sql( + 'SELECT id_agent_module + FROM tgraph_source + WHERE id_graph = '.$content['id_gs'] + ); + + if (isset($module_source) && is_array($module_source)) { + $modules = []; + foreach ($module_source as $key => $value) { + $modules[$key] = $value['id_agent_module']; + } + } + switch ($type) { case 'dinamic': case 'static': @@ -3933,6 +4314,9 @@ function reporting_sql_graph( break; case 'data': + $data = []; + $data = db_get_all_rows_sql($content['external_source']); + $return['chart'] = $data; break; } @@ -3940,6 +4324,14 @@ function reporting_sql_graph( } +/** + * Monitor report module. + * + * @param array $report Info report. + * @param array $content Content report. + * + * @return array + */ function reporting_monitor_report($report, $content) { global $config; @@ -3950,48 +4342,70 @@ function reporting_monitor_report($report, $content) $content['name'] = __('Monitor Report'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) - ); - - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = io_safe_output($content['description']); - $return['date'] = reporting_get_date_text($report, $content); - - if ($config['metaconsole']) { + if (is_metaconsole()) { $id_meta = metaconsole_get_id_server($content['server_name']); $server = metaconsole_get_connection_by_id($id_meta); metaconsole_connect($server); } + $id_agent = agents_get_module_id( + $content['id_agent_module'] + ); + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $agent_alias.' - '.$module_name; + $return['description'] = $content['description']; + $return['date'] = reporting_get_date_text($report, $content); + $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($return['label'] != '') { - $return['label'] = reporting_label_macro($content, $return['label']); + $return['label'] = reporting_label_macro( + $items_label, + $return['label'] + ); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) - ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_name($content['id_agent_module']) - ); - - $return['agent_name'] = $agent_name; + $return['agent_name_db'] = agents_get_name($id_agent); + $return['agent_name'] = $agent_alias; $return['module_name'] = $module_name; - // All values (except id module and report time) by default + // All values (except id module and report time) by default. $report = reporting_advanced_sla( $content['id_agent_module'], ($report['datetime'] - $content['period']), $report['datetime'] ); - if ($report['time_total'] === $report['time_unknown'] || empty($content['id_agent_module'])) { + if ($report['time_total'] === $report['time_unknown'] + || empty($content['id_agent_module']) + ) { $return['data']['unknown'] = 1; } else { $return['data']['ok']['value'] = $report['SLA']; @@ -4072,8 +4486,10 @@ function reporting_netflow( } } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); // Get chart. @@ -4097,8 +4513,8 @@ function reporting_netflow( // Get item filters. $filter = db_get_row_sql( "SELECT * - FROM tnetflow_filter - WHERE id_sg = '".(int) $content['text']."'", + FROM tnetflow_filter + WHERE id_sg = '".(int) $content['text']."'", false, true ); @@ -4106,6 +4522,7 @@ function reporting_netflow( switch ($type) { case 'dinamic': case 'static': + case 'data': $return['chart'] = netflow_draw_item( ($report['datetime'] - $content['period']), $report['datetime'], @@ -4150,13 +4567,17 @@ function reporting_prediction_date($report, $content) $agent_name = io_safe_output( modules_get_agentmodule_agent_alias($content['id_agent_module']) ); + $agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module'])); - $return['title'] = io_safe_output($content['name']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + $return['agent_name_db'] = $agent_name_db; $return['agent_name'] = $agent_name; $return['module_name'] = $module_name; @@ -4201,12 +4622,14 @@ function reporting_projection_graph( $module_name = io_safe_output(modules_get_agentmodule_name($content['id_agent_module'])); $agent_name = io_safe_output(modules_get_agentmodule_agent_alias($content['id_agent_module'])); + $agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module'])); - $return['title'] = io_safe_output($content['name']); + $return['title'] = $content['name']; $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + $return['agent_name_db'] = $agent_name_db; $return['agent_name'] = $agent_name; $return['module_name'] = $module_name; @@ -4216,27 +4639,38 @@ function reporting_projection_graph( case 'dinamic': case 'static': $params = [ - 'period' => $content['period'], - 'width' => $width, - 'date' => $report['datetime'], - 'unit' => '', - 'only_image' => $pdf, - 'homeurl' => ui_get_full_url(false, false, false, false).'/', - 'ttl' => $ttl, - 'server_id' => $id_meta, - 'height' => $config['graph_image_height'], + 'period' => $content['period'], + 'width' => $width, + 'date' => $report['datetime'], + 'unit' => '', + 'only_image' => $pdf, + 'homeurl' => ui_get_full_url(false, false, false, false).'/', + 'ttl' => $ttl, + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'], + 'landscape' => $content['landscape'], + 'return_img_base_64' => true, ]; $params_combined = [ 'projection' => $content['top_n_value'], ]; - $return['chart'] = graphic_combined_module( - [$content['id_agent_module']], - $params, - $params_combined - ); - + if ($pdf === true) { + $return['chart'] = ''; + } else { + $return['chart'] = graphic_combined_module( + [$content['id_agent_module']], + $params, + $params_combined + ); + } break; case 'data': @@ -4269,8 +4703,10 @@ function reporting_agent_configuration($report, $content) $content['name'] = __('Agent configuration'); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; @@ -4282,9 +4718,9 @@ function reporting_agent_configuration($report, $content) } $sql = ' - SELECT * - FROM tagente - WHERE id_agente='.$content['id_agent']; + SELECT * + FROM tagente + WHERE id_agente='.$content['id_agent']; $agent_data = db_get_row_sql($sql); $agent_configuration = []; @@ -4304,9 +4740,9 @@ function reporting_agent_configuration($report, $content) if (!empty($modules)) { foreach ($modules as $id_agent_module => $module) { $sql = " - SELECT * - FROM tagente_modulo - WHERE id_agente_modulo = $id_agent_module"; + SELECT * + FROM tagente_modulo + WHERE id_agente_modulo = $id_agent_module"; $module_db = db_get_row_sql($sql); $data_module = []; @@ -4352,12 +4788,12 @@ function reporting_agent_configuration($report, $content) $data_module['status_icon'] = ui_print_status_image($status, $title, true); $data_module['status'] = $title; $sql_tag = " - SELECT name - FROM ttag - WHERE id_tag IN ( - SELECT id_tag - FROM ttag_module - WHERE id_agente_modulo = $id_agent_module)"; + SELECT name + FROM ttag + WHERE id_tag IN ( + SELECT id_tag + FROM ttag_module + WHERE id_agente_modulo = $id_agent_module)"; $tags = db_get_all_rows_sql($sql_tag); if ($tags === false) { $data_module['tags'] = []; @@ -4402,22 +4838,6 @@ function reporting_value($report, $content, $type, $pdf=false) case 'sum': $return['type'] = 'sumatory'; break; - - case 'MTTR': - $return['type'] = 'MTTR'; - break; - - case 'MTBF': - $return['type'] = 'MTBF'; - break; - - case 'TTO': - $return['type'] = 'TTO'; - break; - - case 'TTRT': - $return['type'] = 'TTRT'; - break; } if (empty($content['name'])) { @@ -4437,22 +4857,6 @@ function reporting_value($report, $content, $type, $pdf=false) case 'sum': $content['name'] = __('Summatory'); break; - - case 'MTTR': - $content['name'] = __('MTTR'); - break; - - case 'MTBF': - $content['name'] = __('MTBF'); - break; - - case 'TTO': - $content['name'] = __('TTO'); - break; - - case 'TTRT': - $content['name'] = __('TTRT'); - break; } } @@ -4469,6 +4873,9 @@ function reporting_value($report, $content, $type, $pdf=false) $agent_name = io_safe_output( modules_get_agentmodule_agent_alias($content['id_agent_module']) ); + $agent_name_db = io_safe_output( + modules_get_agentmodule_agent_name($content['id_agent_module']) + ); $unit = db_get_value( 'unit', 'tagente_modulo', @@ -4476,15 +4883,18 @@ function reporting_value($report, $content, $type, $pdf=false) $content['id_agent_module'] ); - $return['title'] = io_safe_output($content['name']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = $agent_name.' - '.$module_name; - $return['description'] = io_safe_output($content['description']); + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; $return['agents'] = [$content['id_agent']]; $return['id_agent'] = $content['id_agent']; $return['id_agent_module'] = $content['id_agent_module']; + $return['agent_name_db'] = $agent_name_db; $return['agent_name'] = $agent_name; $return['module_name'] = $module_name; @@ -4493,342 +4903,131 @@ function reporting_value($report, $content, $type, $pdf=false) } $params = [ - 'agent_module_id' => $content['id_agent_module'], - 'period' => $content['period'], - 'width' => '600px', - 'pure' => false, - // true - 'date' => $report['datetime'], - 'only_image' => $only_image, - 'homeurl' => ui_get_full_url(false, false, false, false), - 'ttl' => 1, - // 2 - 'type_graph' => $config['type_module_charts'], - 'time_interval' => $content['lapse'], - 'server_id' => $id_meta, - 'height' => $config['graph_image_height'], - 'fullscale' => true, + 'agent_module_id' => $content['id_agent_module'], + 'period' => $content['period'], + 'width' => '600px', + 'pure' => false, + 'date' => $report['datetime'], + 'only_image' => $only_image, + 'homeurl' => ui_get_full_url(false, false, false, false), + 'ttl' => 1, + 'type_graph' => $config['type_module_charts'], + 'time_interval' => $content['lapse'], + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'], + 'fullscale' => true, + 'landscape' => $content['landscape'], + 'return_img_base_64' => true, ]; switch ($type) { case 'max': - if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_max( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - if (!$config['simple_module_value']) { - $formated_value = $value; - } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; - } - } else { - $value = ' - - - - - - - - - -
'; - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Maximum').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; - } - - $value .= ' -
- '; - - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'max_only'; - $value .= grafico_modulo_sparse($params); - } - - $value .= ' - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } - - $value .= '
- '.__('Lapse').' - - '.__('Maximum').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; - - if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_max( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; - } - - $value .= ' -
'; - - $formated_value = $value; - } - break; - case 'min': - if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_min( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - - if (!$config['simple_module_value']) { - $formated_value = $value; - } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; - } - } else { - $value = ' - - - - - - - - - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Minimum').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; - } - - $value .= ' -
- '; - - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'min_only'; - $value .= grafico_modulo_sparse($params); - } - - $value .= ' -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } - - $value .= '
- '.__('Lapse').' - - '.__('Minimum').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; - - if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_min( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; - } - - $value .= ' - -
'; - - $formated_value = $value; - } - break; - case 'avg': + $divisor = get_data_multiplier($unit); + if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_average( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); + switch ($type) { + case 'max': + $value = reporting_get_agentmodule_data_max( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + + case 'min': + $value = reporting_get_agentmodule_data_min( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + + case 'avg': + $value = reporting_get_agentmodule_data_average( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + } + if (!$config['simple_module_value']) { $formated_value = $value; } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; + $formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit); } } else { - $value = ' - - - - - - - - - -
'; + $return['visual_format'] = $content['visual_format']; - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Average').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; + switch ($type) { + case 'max': + $params['force_interval'] = 'max_only'; + $value = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit); + break; + + case 'min': + $params['force_interval'] = 'min_only'; + $value = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit); + break; + + case 'avg': + $params['force_interval'] = 'avg_only'; + $value = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit); + break; } - $value .= ' -
- '; - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'avg_only'; - $value .= grafico_modulo_sparse($params); - } + $return['data'][] = [ + __('Agent') => $agent_name, + __('Module') => $module_name, + __('Maximun') => $value, + ]; - $value .= ' - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } + if ($content['visual_format'] != 1) { + if ($only_image === false) { + $graph = grafico_modulo_sparse($params); + } else { + $graph = ''; } - $value .= '
- '.__('Lapse').' - - '.__('Average').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; - - if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_average( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; + $return['data'][] = ['value' => $graph]; } - $value .= ' - -
'; + if ($content['visual_format'] != 2) { + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); - $formated_value = $value; + for ($i = ($report['datetime'] - $content['period']); $i < $report['datetime']; $i += $content['lapse']) { + $row = []; + $row[__('Lapse')] = date('Y-m-d H:i:s', ($i + 1)).' to '.date('Y-m-d H:i:s', (($i + $content['lapse']) )); + + if ($i > $time_begin['utimestamp']) { + switch ($type) { + case 'max': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit); + break; + + case 'min': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit); + break; + + case 'avg': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit); + break; + } + } else { + $row[__('Maximun')] = 'N/A'; + } + + $return['data'][] = $row; + } + } + + if ($config['metaconsole']) { + metaconsole_restore_db(); + } + + return reporting_check_structure_content($return); } break; @@ -4836,56 +5035,15 @@ function reporting_value($report, $content, $type, $pdf=false) $value = reporting_get_agentmodule_data_sum( $content['id_agent_module'], $content['period'], - $report['datetime'] + $report['datetime'], + $content['uncompressed_module'] ); if (!$config['simple_module_value']) { $formated_value = $value; } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; - } - break; + $divisor = get_data_multiplier($unit); - case 'MTTR': - $value = reporting_get_agentmodule_mttr( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - $formated_value = null; - break; - - case 'MTBF': - $value = reporting_get_agentmodule_mtbf( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - $formated_value = null; - break; - - case 'TTO': - $value = reporting_get_agentmodule_tto( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - if ($value == 0) { - $formated_value = null; - } else { - $formated_value = human_time_description_raw($value); - } - break; - - case 'TTRT': - $value = reporting_get_agentmodule_ttr( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - if ($value == 0) { - $formated_value = null; - } else { - $formated_value = human_time_description_raw($value); + $formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit); } break; } @@ -4914,8 +5072,10 @@ function reporting_url($report, $content, $type='dinamic') $content['name'] = __('Url'); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text(); $return['url'] = $content['external_source']; @@ -4951,8 +5111,10 @@ function reporting_text($report, $content) $content['name'] = __('Text'); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text(); $return['data'] = html_entity_decode($content['text']); @@ -4973,6 +5135,8 @@ function reporting_sql($report, $content) } $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; $return['description'] = $content['description']; $return['date'] = reporting_get_date_text(); @@ -4986,41 +5150,20 @@ function reporting_sql($report, $content) } if ($content['treport_custom_sql_id'] != 0) { - switch ($config['dbtype']) { - case 'mysql': - $sql = io_safe_output( - db_get_value_filter( - '`sql`', - 'treport_custom_sql', - ['id' => $content['treport_custom_sql_id']] - ) - ); - break; - - case 'postgresql': - $sql = io_safe_output( - db_get_value_filter( - '"sql"', - 'treport_custom_sql', - ['id' => $content['treport_custom_sql_id']] - ) - ); - break; - - case 'oracle': - $sql = io_safe_output( - db_get_value_filter( - 'sql', - 'treport_custom_sql', - ['id' => $content['treport_custom_sql_id']] - ) - ); - break; - } + $sql = io_safe_output( + db_get_value_filter( + '`sql`', + 'treport_custom_sql', + ['id' => $content['treport_custom_sql_id']] + ) + ); } else { $sql = io_safe_output($content['external_source']); } + // Check if exist sql macro + $sql = reporting_sql_macro($report, $sql); + // Do a security check on SQL coming from the user. $sql = check_sql($sql); @@ -6073,7 +6216,7 @@ function reporting_advanced_sla( // SLA. $return['SLA'] = reporting_sla_get_compliance_from_array($return); - $return['SLA_fixed'] = sla_truncate( + $return['sla_fixed'] = sla_truncate( $return['SLA'], $config['graph_precision'] ); @@ -6116,8 +6259,10 @@ function reporting_availability($report, $content, $date=false, $time=false) $datetime_to = strtotime($date.' '.$time); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text( $report, $content @@ -6131,23 +6276,6 @@ function reporting_availability($report, $content, $date=false, $time=false) $return['kind_availability'] = 'module'; } - if (empty($content['subitems'])) { - $sql = sprintf( - ' - SELECT id_agent_module, - server_name, operation - FROM treport_content_item - WHERE id_report_content = %d', - $content['id_rc'] - ); - - $items = db_process_sql($sql); - } else { - $items = $content['subitems']; - } - - $data = []; - $avg = 0; $min = null; $min_text = ''; @@ -6155,180 +6283,241 @@ function reporting_availability($report, $content, $date=false, $time=false) $max_text = ''; $count = 0; - $style = io_safe_output($content['style']); - if ($style['hide_notinit_agents']) { - $aux_id_agents = $agents; - $i = 0; - foreach ($items as $item) { - $utimestamp = db_get_value('utimestamp', 'tagente_datos', 'id_agente_modulo', $item['id_agent_module'], true); - if (($utimestamp === false) || (intval($utimestamp) > intval($datetime_to))) { - unset($items[$i]); + if ($content['failover_mode']) { + $availability_graph_data = reporting_availability_graph($report, $content, false, true); + $data = $availability_graph_data['data']; + + foreach ($data as $key => $item_data) { + $percent_ok = $item_data['sla_value']; + $data[$key]['SLA'] = $percent_ok; + + if ($item_data['failover'] != 'result') { + $data[$key]['availability_item'] = $item_data['module']; + $text = $item_data['agent'].' ('.$item_data['module'].')'; + $avg = ((($avg * $count) + $percent_ok) / ($count + 1)); + if (is_null($min)) { + $min = $percent_ok; + $min_text = $text; + } else { + if ($min > $percent_ok) { + $min = $percent_ok; + $min_text = $text; + } + } + + if (is_null($max)) { + $max = $percent_ok; + $max_text = $text; + } else { + if ($max < $percent_ok) { + $max = $percent_ok; + $max_text = $text; + } + } + + $count++; + } else { + $data[$key]['availability_item'] = '--'; + $data[$key]['agent'] = '--'; + } + } + } else { + if (empty($content['subitems'])) { + if (is_metaconsole()) { + metaconsole_restore_db(); } - $i++; - } - } + $sql = sprintf( + ' + SELECT id_agent_module, id_agent_module_failover, + server_name, operation + FROM treport_content_item + WHERE id_report_content = %d', + $content['id_rc'] + ); + + $items = db_process_sql($sql); + } else { + $items = $content['subitems']; + } + + $data = []; + + $style = io_safe_output($content['style']); + if ($style['hide_notinit_agents']) { + $aux_id_agents = $agents; + $i = 0; + foreach ($items as $item) { + $utimestamp = db_get_value('utimestamp', 'tagente_datos', 'id_agente_modulo', $item['id_agent_module'], true); + if (($utimestamp === false) || (intval($utimestamp) > intval($datetime_to))) { + unset($items[$i]); + } + + $i++; + } + } + + if (!empty($items)) { + foreach ($items as $item) { + // aaMetaconsole connection + $server_name = $item['server_name']; + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) != NOERR) { + // ui_print_error_message ("Error connecting to ".$server_name); + continue; + } + } + + if (modules_is_disable_agent($item['id_agent_module']) + || modules_is_not_init($item['id_agent_module']) + ) { + // Restore dbconnection + if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { + metaconsole_restore_db(); + } - if (!empty($items)) { - foreach ($items as $item) { - // aaMetaconsole connection - $server_name = $item['server_name']; - if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { - $connection = metaconsole_get_connection($server_name); - if (metaconsole_load_external_db($connection) != NOERR) { - // ui_print_error_message ("Error connecting to ".$server_name); continue; } - } - if (modules_is_disable_agent($item['id_agent_module']) - || modules_is_not_init($item['id_agent_module']) - ) { + $row = []; + + $text = ''; + + $row['data'] = reporting_advanced_sla( + $item['id_agent_module'], + ($report['datetime'] - $content['period']), + $report['datetime'], + null, + // min_value -> dynamic + null, + // max_value -> dynamic + null, + // inverse_interval -> dynamic + [ + '1' => $content['sunday'], + '2' => $content['monday'], + '3' => $content['tuesday'], + '4' => $content['wednesday'], + '5' => $content['thursday'], + '6' => $content['friday'], + '7' => $content['saturday'], + ], + $content['time_from'], + $content['time_to'] + ); + + // HACK it is saved in show_graph field. + // Show interfaces instead the modules + if ($content['show_graph']) { + $text = $row['data']['availability_item'] = agents_get_address( + modules_get_agentmodule_agent($item['id_agent_module']) + ); + + if (empty($text)) { + $text = $row['data']['availability_item'] = __('No Address'); + } + } else { + $text = $row['data']['availability_item'] = modules_get_agentmodule_name( + $item['id_agent_module'] + ); + } + + $row['data']['agent'] = modules_get_agentmodule_agent_alias( + $item['id_agent_module'] + ); + + $text = $row['data']['agent'].' ('.$text.')'; + // Restore dbconnection if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { metaconsole_restore_db(); } - continue; - } + // find order + $row['data']['order'] = $row['data']['SLA']; - $row = []; - - $text = ''; - - $row['data'] = reporting_advanced_sla( - $item['id_agent_module'], - ($report['datetime'] - $content['period']), - $report['datetime'], - null, - // min_value -> dynamic - null, - // max_value -> dynamic - null, - // inverse_interval -> dynamic - [ - '1' => $content['sunday'], - '2' => $content['monday'], - '3' => $content['tuesday'], - '4' => $content['wednesday'], - '5' => $content['thursday'], - '6' => $content['friday'], - '7' => $content['saturday'], - ], - $content['time_from'], - $content['time_to'] - ); - - // HACK it is saved in show_graph field. - // Show interfaces instead the modules - if ($content['show_graph']) { - $text = $row['data']['availability_item'] = agents_get_address( - modules_get_agentmodule_agent($item['id_agent_module']) - ); - - if (empty($text)) { - $text = $row['data']['availability_item'] = __('No Address'); - } - } else { - $text = $row['data']['availability_item'] = modules_get_agentmodule_name( - $item['id_agent_module'] - ); - } - - $row['data']['agent'] = modules_get_agentmodule_agent_alias( - $item['id_agent_module'] - ); - - $text = $row['data']['agent'].' ('.$text.')'; - - // Restore dbconnection - if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { - metaconsole_restore_db(); - } - - // find order - $row['data']['order'] = $row['data']['SLA']; - - $percent_ok = $row['data']['SLA']; - $avg = ((($avg * $count) + $percent_ok) / ($count + 1)); - if (is_null($min)) { - $min = $percent_ok; - $min_text = $text; - } else { - if ($min > $percent_ok) { + $percent_ok = $row['data']['SLA']; + $avg = ((($avg * $count) + $percent_ok) / ($count + 1)); + if (is_null($min)) { $min = $percent_ok; $min_text = $text; + } else { + if ($min > $percent_ok) { + $min = $percent_ok; + $min_text = $text; + } } - } - if (is_null($max)) { - $max = $percent_ok; - $max_text = $text; - } else { - if ($max < $percent_ok) { + if (is_null($max)) { $max = $percent_ok; $max_text = $text; + } else { + if ($max < $percent_ok) { + $max = $percent_ok; + $max_text = $text; + } } + + $data[] = $row['data']; + $count++; } - $data[] = $row['data']; - $count++; - } + switch ($content['order_uptodown']) { + case REPORT_ITEM_ORDER_BY_AGENT_NAME: + $temp = []; + foreach ($data as $row) { + $i = 0; + foreach ($temp as $t_row) { + if (strcmp($row['data']['agent'], $t_row['agent']) < 0) { + break; + } - switch ($content['order_uptodown']) { - case REPORT_ITEM_ORDER_BY_AGENT_NAME: - $temp = []; - foreach ($data as $row) { - $i = 0; - foreach ($temp as $t_row) { - if (strcmp($row['data']['agent'], $t_row['agent']) < 0) { - break; + $i++; } - $i++; + array_splice($temp, $i, 0, [$row]); } - array_splice($temp, $i, 0, [$row]); - } + $data = $temp; + break; - $data = $temp; - break; + case REPORT_ITEM_ORDER_BY_ASCENDING: + $temp = []; + foreach ($data as $row) { + $i = 0; + foreach ($temp as $t_row) { + if ($row['data']['SLA'] < $t_row['order']) { + break; + } - case REPORT_ITEM_ORDER_BY_ASCENDING: - $temp = []; - foreach ($data as $row) { - $i = 0; - foreach ($temp as $t_row) { - if ($row['data']['SLA'] < $t_row['order']) { - break; + $i++; } - $i++; + array_splice($temp, $i, 0, [$row]); } - array_splice($temp, $i, 0, [$row]); - } + $data = $temp; + break; - $data = $temp; - break; + case REPORT_ITEM_ORDER_BY_DESCENDING: + $temp = []; + foreach ($data as $row) { + $i = 0; + foreach ($temp as $t_row) { + if ($row['data']['SLA'] > $t_row['order']) { + break; + } - case REPORT_ITEM_ORDER_BY_DESCENDING: - $temp = []; - foreach ($data as $row) { - $i = 0; - foreach ($temp as $t_row) { - if ($row['data']['SLA'] > $t_row['order']) { - break; + $i++; } - $i++; + array_splice($temp, $i, 0, [$row]); } - array_splice($temp, $i, 0, [$row]); - } - - $data = $temp; - break; + $data = $temp; + break; + } } } @@ -6358,12 +6547,16 @@ function reporting_availability($report, $content, $date=false, $time=false) } -/** - * reporting_availability_graph - * - * Generates a structure the report. - */ -function reporting_availability_graph($report, $content, $pdf=false) + /** + * Reporting_availability_graph. + * + * @param array $report Info report. + * @param array $content Content data. + * @param boolean $pdf Output type PDF. + * + * @return array Generates a structure the report. + */ +function reporting_availability_graph($report, $content, $pdf=false, $failover=false) { global $config; $return = []; @@ -6377,11 +6570,14 @@ function reporting_availability_graph($report, $content, $pdf=false) $content['name'] = __('Availability'); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; + $return['failover_type'] = $content['failover_type']; $return['date'] = reporting_get_date_text($report, $content); - // Get chart + // Get chart. reporting_set_conf_charts( $width, $height, @@ -6396,10 +6592,16 @@ function reporting_availability_graph($report, $content, $pdf=false) $edge_interval = 10; if (empty($content['subitems'])) { - $slas = db_get_all_rows_field_filter( - 'treport_content_sla_combined', - 'id_report_content', - $content['id_rc'] + if (is_metaconsole()) { + metaconsole_restore_db(); + } + + $slas = io_safe_output( + db_get_all_rows_field_filter( + ($failover) ? 'treport_content_item' : 'treport_content_sla_combined', + 'id_report_content', + $content['id_rc'] + ) ); } else { $slas = $content['subitems']; @@ -6423,83 +6625,8 @@ function reporting_availability_graph($report, $content, $pdf=false) foreach ($slas as $sla) { $server_name = $sla['server_name']; - // Metaconsole connection - if ($metaconsole_on && $server_name != '') { - $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { - // ui_print_error_message ("Error connecting to ".$server_name); - continue; - } - } - if (modules_is_disable_agent($sla['id_agent_module']) - || modules_is_not_init($sla['id_agent_module']) - ) { - if ($metaconsole_on) { - // Restore db connection - metaconsole_restore_db(); - } - - continue; - } - - // controller min and max == 0 then dinamic min and max critical - $dinamic_text = 0; - if ($sla['sla_min'] == 0 && $sla['sla_max'] == 0) { - $sla['sla_min'] = null; - $sla['sla_max'] = null; - $dinamic_text = __('Dynamic'); - } - - // controller inverse interval - $inverse_interval = 0; - if ((isset($sla['sla_max'])) && (isset($sla['sla_min']))) { - if ($sla['sla_max'] < $sla['sla_min']) { - $content_sla_max = $sla['sla_max']; - $sla['sla_max'] = $sla['sla_min']; - $sla['sla_min'] = $content_sla_max; - $inverse_interval = 1; - $dinamic_text = __('Inverse'); - } - } - - // for graph slice for module-interval, if not slice=0; - $module_interval = modules_get_interval($sla['id_agent_module']); - $slice = ($content['period'] / $module_interval); - - // call functions sla - $sla_array = []; - $sla_array = reporting_advanced_sla( - $sla['id_agent_module'], - ($report['datetime'] - $content['period']), - $report['datetime'], - $sla['sla_min'], - // min_value -> dynamic - $sla['sla_max'], - // max_value -> dynamic - $inverse_interval, - // inverse_interval -> dynamic - [ - '1' => $content['sunday'], - '2' => $content['monday'], - '3' => $content['tuesday'], - '4' => $content['wednesday'], - '5' => $content['thursday'], - '6' => $content['friday'], - '7' => $content['saturday'], - ], - $content['time_from'], - $content['time_to'], - $slice - ); - - if ($metaconsole_on) { - // Restore db connection - metaconsole_restore_db(); - } - - $server_name = $sla['server_name']; - // Metaconsole connection + // Metaconsole connection. if ($metaconsole_on && $server_name != '') { $connection = metaconsole_get_connection($server_name); if (metaconsole_connect($connection) != NOERR) { @@ -6507,199 +6634,149 @@ function reporting_availability_graph($report, $content, $pdf=false) } } - $planned_downtimes = reporting_get_planned_downtimes_intervals($sla['id_agent_module'], ($report['datetime'] - $content['period']), $report['datetime']); - - if ((is_array($planned_downtimes)) && (count($planned_downtimes) > 0)) { - // Sort retrieved planned downtimes - usort( - $planned_downtimes, - function ($a, $b) { - $a = intval($a['date_from']); - $b = intval($b['date_from']); - if ($a == $b) { - return 0; + if ($content['failover_mode']) { + $sla_failover = []; + $sla_failover['primary'] = $sla; + if (isset($sla['id_agent_module_failover']) === true + && $sla['id_agent_module_failover'] != 0 + ) { + $sla_failover['failover'] = $sla; + $sla_failover['failover']['id_agent_module'] = $sla['id_agent_module_failover']; + } else { + $sql_relations = sprintf( + 'SELECT module_b + FROM tmodule_relationship + WHERE module_a = %d + AND type = "failover"', + $sla['id_agent_module'] + ); + $relations = db_get_all_rows_sql($sql_relations); + if (isset($relations) === true + && is_array($relations) === true + ) { + foreach ($relations as $key => $value) { + $sla_failover['failover_'.$key] = $sla; + $sla_failover['failover_'.$key]['id_agent_module'] = $value['module_b']; } - - return ($a < $b) ? -1 : 1; } + } + + // For graph slice for module-interval, if not slice=0. + $module_interval = modules_get_interval($sla['id_agent_module']); + $slice = ($content['period'] / $module_interval); + $data_combined = []; + + foreach ($sla_failover as $k_sla => $v_sla) { + $sla_array = data_db_uncompress_module( + $v_sla, + $content, + $report['datetime'], + $slice + ); + + if ($content['failover_type'] == REPORT_FAILOVER_TYPE_NORMAL) { + $return = prepare_data_for_paint( + $v_sla, + $sla_array, + $content, + $report['datetime'], + $return, + $k_sla, + $pdf + ); + } + + $data_combined[] = $sla_array; + } + + if (isset($data_combined) === true + && is_array($data_combined) === true + && count($data_combined) > 0 + ) { + $count_failover = count($data_combined); + + $data_a = $data_combined[0]; + for ($i = 1; $count_failover > $i; $i++) { + $data_a = array_map( + function ($primary, $failover) { + $return_map = []; + if ($primary['date_from'] === $failover['date_from'] + && $primary['date_to'] === $failover['date_to'] + ) { + if ($primary['time_ok'] < $failover['time_ok']) { + $primary['time_total'] = $failover['time_total']; + $primary['time_ok'] = $failover['time_ok']; + $primary['time_error'] = $failover['time_error']; + $primary['time_unknown'] = $failover['time_unknown']; + $primary['time_not_init'] = $failover['time_not_init']; + $primary['time_downtime'] = $failover['time_downtime']; + $primary['time_out'] = $failover['time_out']; + $primary['checks_total'] = $failover['checks_total']; + $primary['checks_ok'] = $failover['checks_ok']; + $primary['checks_error'] = $failover['checks_error']; + $primary['checks_unknown'] = $failover['checks_unknown']; + $primary['checks_not_init'] = $failover['checks_not_init']; + $primary['SLA'] = $failover['SLA']; + $primary['sla_fixed'] = $failover['sla_fixed']; + } + + $return_map = $primary; + } + + return $return_map; + }, + $data_a, + $data_combined[($i)] + ); + } + + $return = prepare_data_for_paint( + $sla, + $data_a, + $content, + $report['datetime'], + $return, + 'result', + $pdf + ); + } + } else { + $sla_array = data_db_uncompress_module( + $sla, + $content, + $report['datetime'] ); - // Compress (overlapped) planned downtimes - $npd = count($planned_downtimes); - for ($i = 0; $i < $npd; $i++) { - if (isset($planned_downtimes[($i + 1)])) { - if ($planned_downtimes[$i]['date_to'] >= $planned_downtimes[($i + 1)]['date_from']) { - // merge - $planned_downtimes[$i]['date_to'] = $planned_downtimes[($i + 1)]['date_to']; - array_splice($planned_downtimes, ($i + 1), 1); - $npd--; - } - } - } - } else { - $planned_downtimes = null; + $return = prepare_data_for_paint( + $sla, + $sla_array, + $content, + $report['datetime'], + $return, + '', + $pdf + ); } - $data = []; - $data['agent'] = modules_get_agentmodule_agent_alias($sla['id_agent_module']); - $data['module'] = modules_get_agentmodule_name($sla['id_agent_module']); - $data['max'] = $sla['sla_max']; - $data['min'] = $sla['sla_min']; - $data['sla_limit'] = $sla['sla_limit']; - $data['dinamic_text'] = $dinamic_text; - - if (isset($sla_array[0])) { - $data['time_total'] = 0; - $data['time_ok'] = 0; - $data['time_error'] = 0; - $data['time_unknown'] = 0; - $data['time_not_init'] = 0; - $data['time_downtime'] = 0; - $data['checks_total'] = 0; - $data['checks_ok'] = 0; - $data['checks_error'] = 0; - $data['checks_unknown'] = 0; - $data['checks_not_init'] = 0; - - $raw_graph = []; - $i = 0; - foreach ($sla_array as $value_sla) { - $data['time_total'] += $value_sla['time_total']; - $data['time_ok'] += $value_sla['time_ok']; - $data['time_error'] += $value_sla['time_error']; - $data['time_unknown'] += $value_sla['time_unknown']; - $data['time_downtime'] += $value_sla['time_downtime']; - $data['time_not_init'] += $value_sla['time_not_init']; - $data['checks_total'] += $value_sla['checks_total']; - $data['checks_ok'] += $value_sla['checks_ok']; - $data['checks_error'] += $value_sla['checks_error']; - $data['checks_unknown'] += $value_sla['checks_unknown']; - $data['checks_not_init'] += $value_sla['checks_not_init']; - - // generate raw data for graph - $period = reporting_sla_get_status_period($value_sla, $priority_mode); - $raw_graph[$i]['data'] = reporting_translate_sla_status_for_graph($period); - $raw_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']); - $i++; - } - - $data['sla_value'] = reporting_sla_get_compliance_from_array($data); - $data['sla_fixed'] = sla_truncate($data['sla_value'], $config['graph_precision']); - } else { - // Show only table not divider in slice for defect slice=1 - $data['time_total'] = $sla_array['time_total']; - $data['time_ok'] = $sla_array['time_ok']; - $data['time_error'] = $sla_array['time_error']; - $data['time_unknown'] = $sla_array['time_unknown']; - $data['time_downtime'] = $sla_array['time_downtime']; - $data['time_not_init'] = $sla_array['time_not_init']; - $data['checks_total'] = $sla_array['checks_total']; - $data['checks_ok'] = $sla_array['checks_ok']; - $data['checks_error'] = $sla_array['checks_error']; - $data['checks_unknown'] = $sla_array['checks_unknown']; - $data['checks_not_init'] = $sla_array['checks_not_init']; - $data['sla_value'] = $sla_array['SLA']; - } - - // checks whether or not it meets the SLA - if ($data['sla_value'] >= $sla['sla_limit']) { - $data['sla_status'] = 1; - $sla_failed = false; - } else { - $sla_failed = true; - $data['sla_status'] = 0; - } - - // Do not show right modules if 'only_display_wrong' is active - if ($content['only_display_wrong'] && $sla_failed == false) { - continue; - } - - // find order - $data['order'] = $data['sla_value']; - $return['data'][] = $data; - - $data_init = -1; - $acum = 0; - $sum = 0; - $array_result = []; - $i = 0; - foreach ($raw_graph as $key => $value) { - if ($data_init == -1) { - $data_init = $value['data']; - $acum = $value['utimestamp']; - $sum = $value['data']; - } else { - if ($data_init == $value['data']) { - $acum = ($acum + $value['utimestamp']); - $sum = ($sum + $value['real_data']); - } else { - $array_result[$i]['data'] = $data_init; - $array_result[$i]['utimestamp'] = $acum; - $array_result[$i]['real_data'] = $sum; - $i++; - $data_init = $value['data']; - $acum = $value['utimestamp']; - $sum = $value['real_data']; - } - } - } - - $array_result[$i]['data'] = $data_init; - $array_result[$i]['utimestamp'] = $acum; - $array_result[$i]['real_data'] = $sum; - - // Slice graphs calculation - $dataslice = []; - $dataslice['agent'] = modules_get_agentmodule_agent_alias($sla['id_agent_module']); - $dataslice['module'] = modules_get_agentmodule_name($sla['id_agent_module']); - $dataslice['order'] = $data['sla_value']; - $dataslice['checks_total'] = $data['checks_total']; - $dataslice['checks_ok'] = $data['checks_ok']; - $dataslice['time_total'] = $data['time_total']; - $dataslice['time_not_init'] = $data['time_not_init']; - $dataslice['sla_status'] = $data['sla_status']; - $dataslice['sla_value'] = $data['sla_value']; - - $dataslice['chart'] = graph_sla_slicebar( - $sla['id_agent_module'], - $content['period'], - $sla['sla_min'], - $sla['sla_max'], - $report['datetime'], - $content, - $content['time_from'], - $content['time_to'], - 100, - 70, - $urlImage, - $ttl, - $array_result, - false - ); - - $return['charts'][] = $dataslice; - if ($metaconsole_on) { - // Restore db connection + // Restore db connection. metaconsole_restore_db(); } } - // SLA items sorted descending () + // SLA items sorted descending. if ($content['top_n'] == 2) { arsort($return['data']['']); - } - // SLA items sorted ascending - else if ($content['top_n'] == 1) { + } else if ($content['top_n'] == 1) { + // SLA items sorted ascending. asort($sla_showed_values); } - // order data for ascending or descending + // Order data for ascending or descending. if ($content['top_n'] != 0) { switch ($content['top_n']) { case 1: - // order tables + // Order tables. $temp = []; foreach ($return['data'] as $row) { $i = 0; @@ -6716,7 +6793,7 @@ function reporting_availability_graph($report, $content, $pdf=false) $return['data'] = $temp; - // order graphs + // Order graphs. $temp = []; foreach ($return['charts'] as $row) { $i = 0; @@ -6732,11 +6809,10 @@ function reporting_availability_graph($report, $content, $pdf=false) } $return['charts'] = $temp; - break; case 2: - // order tables + // Order tables. $temp = []; foreach ($return['data'] as $row) { $i = 0; @@ -6753,7 +6829,7 @@ function reporting_availability_graph($report, $content, $pdf=false) $return['data'] = $temp; - // order graph + // Order graph. $temp = []; foreach ($return['charts'] as $row) { $i = 0; @@ -6769,7 +6845,10 @@ function reporting_availability_graph($report, $content, $pdf=false) } $return['charts'] = $temp; + break; + default: + // If not posible. break; } } @@ -6779,6 +6858,323 @@ function reporting_availability_graph($report, $content, $pdf=false) } +/** + * Return data db uncompress for module. + * + * @param array $sla Data neccesary for db_uncompress. + * @param array $content Conetent report. + * @param array $datetime Date. + * @param integer $slice Defined slice. + * + * @return array + */ +function data_db_uncompress_module($sla, $content, $datetime, $slice=0) +{ + // Controller min and max == 0 then dinamic min and max critical. + $dinamic_text = 0; + if ($sla['sla_min'] == 0 && $sla['sla_max'] == 0) { + $sla['sla_min'] = null; + $sla['sla_max'] = null; + $dinamic_text = __('Dynamic'); + } + + // Controller inverse interval. + $inverse_interval = 0; + if ((isset($sla['sla_max'])) && (isset($sla['sla_min']))) { + if ($sla['sla_max'] < $sla['sla_min']) { + $content_sla_max = $sla['sla_max']; + $sla['sla_max'] = $sla['sla_min']; + $sla['sla_min'] = $content_sla_max; + $inverse_interval = 1; + $dinamic_text = __('Inverse'); + } + } + + if ($slice === 0) { + // For graph slice for module-interval, if not slice=0. + $module_interval = modules_get_interval($sla['id_agent_module']); + $slice = ($content['period'] / $module_interval); + } + + // Call functions sla. + $sla_array = []; + $sla_array = reporting_advanced_sla( + $sla['id_agent_module'], + ($datetime - $content['period']), + $datetime, + $sla['sla_min'], + $sla['sla_max'], + $inverse_interval, + [ + '1' => $content['sunday'], + '2' => $content['monday'], + '3' => $content['tuesday'], + '4' => $content['wednesday'], + '5' => $content['thursday'], + '6' => $content['friday'], + '7' => $content['saturday'], + ], + $content['time_from'], + $content['time_to'], + $slice + ); + + return $sla_array; +} + + +/** + * Return array planned downtimes. + * + * @param integer $id_agent_module Id module. + * @param integer $datetime Date utimestamp. + * @param integer $period Period utimestamp. + * + * @return array + */ +function reporting_get_planned_downtimes_sla($id_agent_module, $datetime, $period) +{ + $planned_downtimes = reporting_get_planned_downtimes_intervals( + $id_agent_module, + ($datetime - $period), + $datetime + ); + + if ((is_array($planned_downtimes)) + && (count($planned_downtimes) > 0) + ) { + // Sort retrieved planned downtimes. + usort( + $planned_downtimes, + function ($a, $b) { + $a = intval($a['date_from']); + $b = intval($b['date_from']); + if ($a == $b) { + return 0; + } + + return ($a < $b) ? (-1) : 1; + } + ); + + // Compress (overlapped) planned downtimes. + $npd = count($planned_downtimes); + for ($i = 0; $i < $npd; $i++) { + if (isset($planned_downtimes[($i + 1)])) { + if ($planned_downtimes[$i]['date_to'] >= $planned_downtimes[($i + 1)]['date_from']) { + // Merge. + $planned_downtimes[$i]['date_to'] = $planned_downtimes[($i + 1)]['date_to']; + array_splice($planned_downtimes, ($i + 1), 1); + $npd--; + } + } + } + } else { + $planned_downtimes = []; + } + + return $planned_downtimes; +} + + +/** + * Prepare data for Paint in report. + * + * @param array $sla Data Module to sla. + * @param array $sla_array Data uncompressed. + * @param array $content Content report data. + * @param integer $datetime Date. + * @param array $return Array return. + * @param string $failover Type primary, failover, Result. + * @param boolean $pdf Chart pdf mode. + * + * @return array Return modify. + */ +function prepare_data_for_paint( + $sla, + $sla_array, + $content, + $datetime, + $return, + $failover='', + $pdf=false +) { + $data = []; + $alias_agent = modules_get_agentmodule_agent_alias( + $sla['id_agent_module'] + ); + + if ($content['show_graph']) { + $name_module = agents_get_address( + modules_get_agentmodule_agent($sla['id_agent_module']) + ); + if (empty($name_module)) { + $name_module = __('No Address'); + } + } else { + $name_module = modules_get_agentmodule_name( + $sla['id_agent_module'] + ); + } + + $data['agent'] = $alias_agent; + $data['module'] = $name_module; + $data['max'] = $sla['sla_max']; + $data['min'] = $sla['sla_min']; + $data['sla_limit'] = $sla['sla_limit']; + $data['dinamic_text'] = $dinamic_text; + $data['failover'] = $failover; + if (isset($sla_array[0])) { + $data['time_total'] = 0; + $data['time_ok'] = 0; + $data['time_error'] = 0; + $data['time_unknown'] = 0; + $data['time_not_init'] = 0; + $data['time_downtime'] = 0; + $data['checks_total'] = 0; + $data['checks_ok'] = 0; + $data['checks_error'] = 0; + $data['checks_unknown'] = 0; + $data['checks_not_init'] = 0; + + $raw_graph = []; + $i = 0; + foreach ($sla_array as $value_sla) { + $data['time_total'] += $value_sla['time_total']; + $data['time_ok'] += $value_sla['time_ok']; + $data['time_error'] += $value_sla['time_error']; + $data['time_unknown'] += $value_sla['time_unknown']; + $data['time_downtime'] += $value_sla['time_downtime']; + $data['time_not_init'] += $value_sla['time_not_init']; + $data['checks_total'] += $value_sla['checks_total']; + $data['checks_ok'] += $value_sla['checks_ok']; + $data['checks_error'] += $value_sla['checks_error']; + $data['checks_unknown'] += $value_sla['checks_unknown']; + $data['checks_not_init'] += $value_sla['checks_not_init']; + + // Generate raw data for graph. + $period = reporting_sla_get_status_period( + $value_sla, + $priority_mode + ); + $raw_graph[$i]['data'] = reporting_translate_sla_status_for_graph( + $period + ); + $raw_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']); + $i++; + } + + $data['sla_value'] = reporting_sla_get_compliance_from_array( + $data + ); + $data['sla_fixed'] = sla_truncate( + $data['sla_value'], + $config['graph_precision'] + ); + } else { + // Show only table not divider in slice for defect slice=1. + $data['time_total'] = $sla_array['time_total']; + $data['time_ok'] = $sla_array['time_ok']; + $data['time_error'] = $sla_array['time_error']; + $data['time_unknown'] = $sla_array['time_unknown']; + $data['time_downtime'] = $sla_array['time_downtime']; + $data['time_not_init'] = $sla_array['time_not_init']; + $data['checks_total'] = $sla_array['checks_total']; + $data['checks_ok'] = $sla_array['checks_ok']; + $data['checks_error'] = $sla_array['checks_error']; + $data['checks_unknown'] = $sla_array['checks_unknown']; + $data['checks_not_init'] = $sla_array['checks_not_init']; + $data['sla_value'] = $sla_array['SLA']; + } + + // Checks whether or not it meets the SLA. + if ($data['sla_value'] >= $sla['sla_limit']) { + $data['sla_status'] = 1; + $sla_failed = false; + } else { + $sla_failed = true; + $data['sla_status'] = 0; + } + + // Do not show right modules if 'only_display_wrong' is active. + if ($content['only_display_wrong'] && $sla_failed == false) { + return $return; + } + + // Find order. + $data['order'] = $data['sla_value']; + $return['data'][] = $data; + + $data_init = -1; + $acum = 0; + $sum = 0; + $array_result = []; + $i = 0; + foreach ($raw_graph as $key => $value) { + if ($data_init == -1) { + $data_init = $value['data']; + $acum = $value['utimestamp']; + $sum = $value['data']; + } else { + if ($data_init == $value['data']) { + $acum = ($acum + $value['utimestamp']); + $sum = ($sum + $value['real_data']); + } else { + $array_result[$i]['data'] = $data_init; + $array_result[$i]['utimestamp'] = $acum; + $array_result[$i]['real_data'] = $sum; + $i++; + $data_init = $value['data']; + $acum = $value['utimestamp']; + $sum = $value['real_data']; + } + } + } + + $array_result[$i]['data'] = $data_init; + $array_result[$i]['utimestamp'] = $acum; + $array_result[$i]['real_data'] = $sum; + + // Slice graphs calculation. + $dataslice = []; + $dataslice['agent'] = $alias_agent; + $dataslice['module'] = $name_module; + $dataslice['order'] = $data['sla_value']; + $dataslice['checks_total'] = $data['checks_total']; + $dataslice['checks_ok'] = $data['checks_ok']; + $dataslice['time_total'] = $data['time_total']; + $dataslice['time_not_init'] = $data['time_not_init']; + $dataslice['sla_status'] = $data['sla_status']; + $dataslice['sla_value'] = $data['sla_value']; + + $height = 80; + if ($failover !== '' && $failover !== 'result') { + $height = 50; + } + + $dataslice['chart'] = graph_sla_slicebar( + $sla['id_agent_module'], + $content['period'], + $sla['sla_min'], + $sla['sla_max'], + $datetime, + $content, + $content['time_from'], + $content['time_to'], + 100, + $height, + $urlImage, + ($pdf) ? 2 : 0, + $array_result, + false + ); + + $return['charts'][] = $dataslice; + + return $return; +} + + /** * reporting_increment * @@ -6794,8 +7190,10 @@ function reporting_increment($report, $content) $content['name'] = __('Increment'); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['id_agent_module'] = $content['id_agent_module']; $return['id_agent'] = $content['id_agent']; @@ -6809,13 +7207,14 @@ function reporting_increment($report, $content) if (is_metaconsole()) { $sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' - AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC'; + AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC'; $sql2 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC'; + metaconsole_restore_db(); $servers = db_get_all_rows_sql( 'SELECT * - FROM tmetaconsole_setup - WHERE disabled = 0' + FROM tmetaconsole_setup + WHERE disabled = 0' ); if ($servers === false) { @@ -6839,7 +7238,7 @@ function reporting_increment($report, $content) } else { $old_data = db_get_value_sql( 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' - AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC' + AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC' ); $last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC'); @@ -6893,8 +7292,10 @@ function reporting_general($report, $content) $content['name'] = __('General'); } - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text( $report, $content @@ -6915,6 +7316,10 @@ function reporting_general($report, $content) $return['show_in_same_row'] = $content['style']['show_in_same_row']; if (empty($content['subitems'])) { + if (is_metaconsole()) { + metaconsole_restore_db(); + } + $generals = db_get_all_rows_filter( 'treport_content_item', ['id_report_content' => $content['id_rc']] @@ -6955,6 +7360,7 @@ function reporting_general($report, $content) $mod_name = modules_get_agentmodule_name($row['id_agent_module']); $ag_name = modules_get_agentmodule_agent_alias($row['id_agent_module']); + $name_agent = modules_get_agentmodule_agent_name($row['id_agent_module']); $type_mod = modules_get_last_value($row['id_agent_module']); $is_string[$index] = modules_is_string($row['id_agent_module']); $unit = db_get_value( @@ -7004,6 +7410,8 @@ function reporting_general($report, $content) } } + $divisor = get_data_multiplier($unit); + switch ($content['group_by_agent']) { case REPORT_GENERAL_NOT_GROUP_BY_AGENT: $id_agent_module[$index] = $row['id_agent_module']; @@ -7029,12 +7437,12 @@ function reporting_general($report, $content) } if ($data_res[$index] === false) { - $return['data'][$ag_name][$mod_name] = null; + $return['data'][$name_agent][$mod_name] = null; } else { if (!is_numeric($data_res[$index])) { - $return['data'][$ag_name][$mod_name] = $data_res[$index]; + $return['data'][$name_agent][$mod_name] = $data_res[$index]; } else { - $return['data'][$ag_name][$mod_name] = format_for_graph($data_res[$index], 2).' '.$unit; + $return['data'][$name_agent][$mod_name] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit); } } break; @@ -7053,7 +7461,7 @@ function reporting_general($report, $content) if ($change_min) { $return['min']['value'] = $data_res[$index]; - $return['min']['formated_value'] = format_for_graph($data_res[$index], 2).' '.$unit; + $return['min']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit); $return['min']['agent'] = $ag_name; $return['min']['module'] = $mod_name; } @@ -7069,7 +7477,7 @@ function reporting_general($report, $content) if ($change_max) { $return['max']['value'] = $data_res[$index]; - $return['max']['formated_value'] = format_for_graph($data_res[$index], 2).' '.$unit; + $return['max']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit); $return['max']['agent'] = $ag_name; $return['max']['module'] = $mod_name; } @@ -7187,13 +7595,15 @@ function reporting_general($report, $content) break; } + $divisor = get_data_multiplier($units[$i]); + if (!is_numeric($d) || $is_string[$i]) { $data['value'] = $d; // to see the chains on the table $data['formated_value'] = $d; } else { $data['value'] = $d; - $data['formated_value'] = format_for_graph($d, 2).' '.$units[$i]; + $data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, $units[$i]); } } @@ -7262,8 +7672,8 @@ function reporting_custom_graph( if (is_metaconsole()) { $module_source = db_get_all_rows_sql( 'SELECT id_agent_module, id_server - FROM tgraph_source - WHERE id_graph = '.$content['id_gs'] + FROM tgraph_source + WHERE id_graph = '.$content['id_gs'] ); if (isset($module_source) && is_array($module_source)) { @@ -7280,9 +7690,40 @@ function reporting_custom_graph( $content['name'] = __('Simple graph'); } - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = io_safe_output($graph['name']); - $return['description'] = io_safe_output($content['description']); + if ($type_report != 'automatic_graph') { + $module_source = db_get_all_rows_sql( + 'SELECT id_agent_module + FROM tgraph_source + WHERE id_graph = '.$content['id_gs'] + ); + + if (isset($module_source) && is_array($module_source)) { + $modules = []; + foreach ($module_source as $key => $value) { + $modules[$key] = $value['id_agent_module']; + } + } + } + + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $graph['name']; + $return['agent_name'] = $agent_alias; + $return['module_name'] = $module_name; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text( $report, $content @@ -7296,16 +7737,18 @@ function reporting_custom_graph( case 'dinamic': case 'static': $params = [ - 'period' => $content['period'], - 'width' => $width, - 'date' => $report['datetime'], - 'only_image' => $pdf, - 'homeurl' => ui_get_full_url(false, false, false, false), - 'ttl' => $ttl, - 'percentil' => $graphs[0]['percentil'], - 'fullscale' => $graphs[0]['fullscale'], - 'server_id' => $id_meta, - 'height' => $config['graph_image_height'], + 'period' => $content['period'], + 'width' => $width, + 'date' => $report['datetime'], + 'only_image' => $pdf, + 'homeurl' => ui_get_full_url(false, false, false, false), + 'ttl' => $ttl, + 'percentil' => $graphs[0]['percentil'], + 'fullscale' => $graphs[0]['fullscale'], + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'], + 'landscape' => $content['landscape'], + 'return_img_base_64' => true, ]; $params_combined = [ @@ -7318,12 +7761,34 @@ function reporting_custom_graph( 'labels' => $content['style']['label'], ]; - $return['chart'] = graphic_combined_module( - $modules, - $params, - $params_combined - ); + if ($pdf === true) { + $return['chart'] = ''; + } else { + $return['chart'] = graphic_combined_module( + $modules, + $params, + $params_combined + ); + } + break; + case 'data': + $data = []; + foreach ($modules as $key => $value) { + $data[$value] = modules_get_agentmodule_data( + $value, + $content['period'], + $report['datetime'] + ); + } + + $return['chart'] = $data; break; } @@ -7337,6 +7802,17 @@ function reporting_custom_graph( } +/** + * Simple graph report. + * + * @param array $report Info report. + * @param array $content Content report. + * @param string $type Type report. + * @param integer $force_width_chart Width chart. + * @param integer $force_height_chart Height chart. + * + * @return array + */ function reporting_simple_graph( $report, $content, @@ -7346,13 +7822,6 @@ function reporting_simple_graph( ) { global $config; - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content['server_name']); - - $server = metaconsole_get_connection_by_id($id_meta); - metaconsole_connect($server); - } - $return = []; $return['type'] = 'simple_graph'; @@ -7360,28 +7829,62 @@ function reporting_simple_graph( $content['name'] = __('Simple graph'); } - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module']) + if ($config['metaconsole']) { + $id_meta = metaconsole_get_id_server($content['server_name']); + + $server = metaconsole_get_connection_by_id($id_meta); + metaconsole_connect($server); + } + + $id_agent = agents_get_module_id( + $content['id_agent_module'] ); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias($content['id_agent_module']) + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module ); - $return['title'] = io_safe_output($content['name']); - $return['subtitle'] = $agent_name.' - '.$module_name; - $return['agent_name'] = io_safe_output($agent_name); - $return['module_name'] = io_safe_output($module_name); - $return['description'] = io_safe_output($content['description']); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_label = [ + 'type' => $return['type'], + 'id_agent' => $id_agent, + 'id_agent_module' => $id_agent_module, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; + if ($label != '') { + $label = reporting_label_macro( + $items_label, + $label + ); + } + + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['subtitle'] = $agent_alias.' - '.$module_name; + $return['agent_name_db'] = agents_get_name($id_agent); + $return['agent_name'] = $agent_alias; + $return['module_name'] = $module_name; + $return['description'] = $content['description']; $return['date'] = reporting_get_date_text( $report, $content ); - $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - if ($label != '') { - $label = reporting_label_macro($content, $label); - } - if (isset($content['style']['fullscale'])) { $fullscale = (bool) $content['style']['fullscale']; } @@ -7389,7 +7892,14 @@ function reporting_simple_graph( $return['chart'] = ''; // Get chart. - reporting_set_conf_charts($width, $height, $only_image, $type, $content, $ttl); + reporting_set_conf_charts( + $width, + $height, + $only_image, + $type, + $content, + $ttl + ); if (!empty($force_width_chart)) { $width = $force_width_chart; @@ -7409,24 +7919,35 @@ function reporting_simple_graph( } $params = [ - 'agent_module_id' => $content['id_agent_module'], - 'period' => $content['period'], - 'title' => $label, - 'pure' => false, - 'date' => $report['datetime'], - 'only_image' => $only_image, - 'homeurl' => ui_get_full_url(false, false, false, false), - 'ttl' => $ttl, - 'compare' => $time_compare_overlapped, - 'show_unknown' => true, - 'percentil' => ($content['style']['percentil'] == 1) ? $config['percentil'] : null, - 'fullscale' => $fullscale, - 'server_id' => $id_meta, - 'height' => $config['graph_image_height'], + 'agent_module_id' => $content['id_agent_module'], + 'period' => $content['period'], + 'title' => $label, + 'pure' => false, + 'date' => $report['datetime'], + 'only_image' => $only_image, + 'homeurl' => ui_get_full_url( + false, + false, + false, + false + ), + 'ttl' => $ttl, + 'compare' => $time_compare_overlapped, + 'show_unknown' => true, + 'percentil' => ($content['style']['percentil'] == 1) ? $config['percentil'] : null, + 'fullscale' => $fullscale, + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'], + 'landscape' => $content['landscape'], + 'backgroundColor' => 'transparent', + 'return_img_base_64' => true, ]; - $return['chart'] = grafico_modulo_sparse($params); - + if ($only_image === false) { + $return['chart'] = grafico_modulo_sparse($params); + } else { + $return['chart'] = ''; + } break; case 'data': @@ -7440,6 +7961,10 @@ function reporting_simple_graph( $return['chart'][$d['utimestamp']] = $d['data']; } break; + + default: + // Not Possible. + break; } if ($config['metaconsole']) { @@ -7566,13 +8091,8 @@ function reporting_set_conf_charts( case 'static': $ttl = 2; $only_image = true; - if ($content['style']['show_in_landscape']) { - $height = 1100; - $width = 1700; - } else { - $height = 360; - $width = 780; - } + $height = 360; + $width = 780; break; case 'data': @@ -8001,10 +8521,10 @@ function reporting_get_group_stats($id_group=0, $access='AR') foreach ($id_group as $group) { $group_stat = db_get_all_rows_sql( "SELECT * - FROM tgroup_stat, tgrupo - WHERE tgrupo.id_grupo = tgroup_stat.id_group - AND tgroup_stat.id_group = $group - ORDER BY nombre" + FROM tgroup_stat, tgrupo + WHERE tgrupo.id_grupo = tgroup_stat.id_group + AND tgroup_stat.id_group = $group + ORDER BY nombre" ); $data['monitor_checks'] += $group_stat[0]['modules']; @@ -8232,10 +8752,10 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR') foreach ($id_group as $group) { $group_stat = db_get_all_rows_sql( "SELECT * - FROM tgroup_stat, tgrupo - WHERE tgrupo.id_grupo = tgroup_stat.id_group - AND tgroup_stat.id_group = $group - ORDER BY nombre" + FROM tgroup_stat, tgrupo + WHERE tgrupo.id_grupo = tgroup_stat.id_group + AND tgroup_stat.id_group = $group + ORDER BY nombre" ); $data['monitor_checks'] += $group_stat[0]['modules']; @@ -8270,8 +8790,8 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR') $tags = db_get_value('tags', 'tusuario_perfil', 'id_usuario', $config['id_user']); if ($tags) { $tags_sql = " AND tae.id_agente_modulo IN ( SELECT id_agente_modulo - FROM ttag_module - WHERE id_tag IN ($tags) ) "; + FROM ttag_module + WHERE id_tag IN ($tags) ) "; } else { $tags_sql = ''; } @@ -8282,27 +8802,27 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR') // for stats modules $sql = "SELECT tg.id_grupo as id, tg.nombre as name, - SUM(tae.estado=0) as monitor_ok, - SUM(tae.estado=1) as monitor_critical, - SUM(tae.estado=2) as monitor_warning, - SUM(tae.estado=3) as monitor_unknown, - SUM(tae.estado=4) as monitor_not_init, - COUNT(tae.estado) as monitor_total + SUM(tae.estado=0) as monitor_ok, + SUM(tae.estado=1) as monitor_critical, + SUM(tae.estado=2) as monitor_warning, + SUM(tae.estado=3) as monitor_unknown, + SUM(tae.estado=4) as monitor_not_init, + COUNT(tae.estado) as monitor_total - FROM - tagente_estado tae, - tagente ta, - tagente_modulo tam, - tgrupo tg + FROM + tagente_estado tae, + tagente ta, + tagente_modulo tam, + tgrupo tg - WHERE 1=1 - AND tae.id_agente = ta.id_agente - AND tae.id_agente_modulo = tam.id_agente_modulo - AND ta.id_grupo = tg.id_grupo - AND tam.disabled = 0 - AND ta.disabled = 0 - AND ta.id_grupo IN ($id_group) $tags_sql - GROUP BY tg.id_grupo;"; + WHERE 1=1 + AND tae.id_agente = ta.id_agente + AND tae.id_agente_modulo = tam.id_agente_modulo + AND ta.id_grupo = tg.id_grupo + AND tam.disabled = 0 + AND ta.disabled = 0 + AND ta.id_grupo IN ($id_group) $tags_sql + GROUP BY tg.id_grupo;"; $data_array = db_get_all_rows_sql($sql); $data = $data_array[0]; @@ -8315,27 +8835,27 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR') // for stats agents $sql = "SELECT tae.id_agente id_agente, tg.id_grupo id_grupo, - SUM(tae.estado=0) as monitor_agent_ok, - SUM(tae.estado=1) as monitor_agent_critical, - SUM(tae.estado=2) as monitor_agent_warning, - SUM(tae.estado=3) as monitor_agent_unknown, - SUM(tae.estado=4) as monitor_agent_not_init, - COUNT(tae.estado) as monitor_agent_total + SUM(tae.estado=0) as monitor_agent_ok, + SUM(tae.estado=1) as monitor_agent_critical, + SUM(tae.estado=2) as monitor_agent_warning, + SUM(tae.estado=3) as monitor_agent_unknown, + SUM(tae.estado=4) as monitor_agent_not_init, + COUNT(tae.estado) as monitor_agent_total - FROM - tagente_estado tae, - tagente ta, - tagente_modulo tam, - tgrupo tg - - WHERE 1=1 - AND tae.id_agente = ta.id_agente - AND tae.id_agente_modulo = tam.id_agente_modulo - AND ta.id_grupo = tg.id_grupo - AND tam.disabled = 0 - AND ta.disabled = 0 - AND ta.id_grupo IN ($id_group) $tags_sql - GROUP BY tae.id_agente;"; + FROM + tagente_estado tae, + tagente ta, + tagente_modulo tam, + tgrupo tg + + WHERE 1=1 + AND tae.id_agente = ta.id_agente + AND tae.id_agente_modulo = tam.id_agente_modulo + AND ta.id_grupo = tg.id_grupo + AND tam.disabled = 0 + AND ta.disabled = 0 + AND ta.id_grupo IN ($id_group) $tags_sql + GROUP BY tae.id_agente;"; $data_array_2 = db_get_all_rows_sql($sql); if (is_array($data_array_2) || is_object($data_array_2)) { @@ -8446,22 +8966,22 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru if ($html) { $tdata[0] = '
- '.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), $servers['down']), true).''.progress_bar($servers['health'], $width, $height, '', 0).'
'; + '.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), $servers['down']), true).''.progress_bar($servers['health'], $width, $height, '', 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; $tdata[0] = '
- '.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), $data['monitor_not_normal']), true).''.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'
'; + '.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), $data['monitor_not_normal']), true).''.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; $tdata[0] = '
- '.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), $data['monitor_not_init']), true).''.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'
'; + '.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), $data['monitor_not_init']), true).''.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; $tdata[0] = '
- '.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), $data['monitor_alerts_fired']), true).''.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'
'; + '.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), $data['monitor_alerts_fired']), true).''.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; @@ -8544,7 +9064,7 @@ function reporting_get_stats_alerts($data, $links=false) if (!is_metaconsole()) { $output = '
- '.__('Defined and fired alerts').''.html_print_table($table_al, true).'
'; + '.__('Defined and fired alerts').''.html_print_table($table_al, true).''; } else { // Remove the defined alerts cause with the new cache table is difficult to retrieve them unset($table_al->data[0][0], $table_al->data[0][1]); @@ -8552,7 +9072,7 @@ function reporting_get_stats_alerts($data, $links=false) $table_al->class = 'tactical_view'; $table_al->style = []; $output = '
- '.__('Fired alerts').''.html_print_table($table_al, true).'
'; + '.__('Fired alerts').''.html_print_table($table_al, true).''; } return $output; @@ -8628,14 +9148,14 @@ function reporting_get_stats_modules_status($data, $graph_width=250, $graph_heig if (!is_metaconsole()) { $output = ' -
- '.__('Monitors by status').''.html_print_table($table_mbs, true).'
'; +
+ '.__('Monitors by status').''.html_print_table($table_mbs, true).'
'; } else { $table_mbs->class = 'tactical_view'; $table_mbs->style = []; $output = ' -
- '.__('Monitors by status').''.html_print_table($table_mbs, true).'
'; +
+ '.__('Monitors by status').''.html_print_table($table_mbs, true).'
'; } return $output; @@ -8701,7 +9221,7 @@ function reporting_get_stats_agents_monitors($data) $table_am->data[] = $tdata; $output = '
- '.__('Total agents and monitors').''.html_print_table($table_am, true).'
'; + '.__('Total agents and monitors').''.html_print_table($table_am, true).''; return $output; } @@ -8732,7 +9252,7 @@ function reporting_get_stats_users($data) $table_us->data[] = $tdata; $output = '
- '.__('Users').''.html_print_table($table_us, true).'
'; + '.__('Users').''.html_print_table($table_us, true).''; return $output; } @@ -8767,8 +9287,8 @@ function reporting_get_agentmodule_data_average($id_agent_module, $period=0, $da // Get module data $interval_data = db_get_all_rows_sql( 'SELECT * - FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', + FROM tagente_datos + WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', $search_in_history_db ); if ($interval_data === false) { @@ -8893,8 +9413,8 @@ function reporting_get_agentmodule_mttr($id_agent_module, $period=0, $date=0) $module = db_get_row_sql( 'SELECT max_critical, min_critical, id_tipo_modulo - FROM tagente_modulo - WHERE id_agente_modulo = '.(int) $id_agent_module + FROM tagente_modulo + WHERE id_agente_modulo = '.(int) $id_agent_module ); if ($module === false) { return false; @@ -8915,7 +9435,7 @@ function reporting_get_agentmodule_mttr($id_agent_module, $period=0, $date=0) // Get module data $interval_data = db_get_all_rows_sql( 'SELECT * FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', + WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', $search_in_history_db ); if ($interval_data === false) { @@ -9039,8 +9559,8 @@ function reporting_get_agentmodule_mtbf($id_agent_module, $period=0, $date=0) $module = db_get_row_sql( 'SELECT max_critical, min_critical, id_tipo_modulo - FROM tagente_modulo - WHERE id_agente_modulo = '.(int) $id_agent_module + FROM tagente_modulo + WHERE id_agente_modulo = '.(int) $id_agent_module ); if ($module === false) { return false; @@ -9061,7 +9581,7 @@ function reporting_get_agentmodule_mtbf($id_agent_module, $period=0, $date=0) // Get module data $interval_data = db_get_all_rows_sql( 'SELECT * FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', + WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', $search_in_history_db ); if ($interval_data === false) { @@ -9181,8 +9701,8 @@ function reporting_get_agentmodule_tto($id_agent_module, $period=0, $date=0) $module = db_get_row_sql( 'SELECT max_critical, min_critical, id_tipo_modulo - FROM tagente_modulo - WHERE id_agente_modulo = '.(int) $id_agent_module + FROM tagente_modulo + WHERE id_agente_modulo = '.(int) $id_agent_module ); if ($module === false) { return false; @@ -9203,7 +9723,7 @@ function reporting_get_agentmodule_tto($id_agent_module, $period=0, $date=0) // Get module data $interval_data = db_get_all_rows_sql( 'SELECT * FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', + WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', $search_in_history_db ); if ($interval_data === false) { @@ -9290,8 +9810,8 @@ function reporting_get_agentmodule_ttr($id_agent_module, $period=0, $date=0) $module = db_get_row_sql( 'SELECT max_critical, min_critical, id_tipo_modulo - FROM tagente_modulo - WHERE id_agente_modulo = '.(int) $id_agent_module + FROM tagente_modulo + WHERE id_agente_modulo = '.(int) $id_agent_module ); if ($module === false) { return false; @@ -9312,7 +9832,7 @@ function reporting_get_agentmodule_ttr($id_agent_module, $period=0, $date=0) // Get module data $interval_data = db_get_all_rows_sql( 'SELECT * FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', + WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', $search_in_history_db ); if ($interval_data === false) { @@ -9761,9 +10281,9 @@ function reporting_get_agentmodule_sla( // Get interval data $sql = sprintf( 'SELECT * - FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d', + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp > %d AND utimestamp <= %d', $id_agent_module, $datelimit, $date @@ -9982,43 +10502,43 @@ function reporting_get_planned_downtimes_intervals($id_agent_module, $start_date } $sql_downtime = ' - SELECT DISTINCT(tpdr.id), - tpdr.name, - '.$tpdr_description.", - tpdr.date_from, - tpdr.date_to, - tpdr.executed, - tpdr.id_group, - tpdr.only_alerts, - tpdr.monday, - tpdr.tuesday, - tpdr.wednesday, - tpdr.thursday, - tpdr.friday, - tpdr.saturday, - tpdr.sunday, - tpdr.periodically_time_from, - tpdr.periodically_time_to, - tpdr.periodically_day_from, - tpdr.periodically_day_to, - tpdr.type_downtime, - tpdr.type_execution, - tpdr.type_periodicity, - tpdr.id_user - FROM ( - SELECT tpd.* - FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam - WHERE tpd.id = tpda.id_downtime - AND tpda.all_modules = 1 - AND tpda.id_agent = tam.id_agente - AND tam.id_agente_modulo = $id_agent_module - UNION ALL - SELECT tpd.* - FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm - WHERE tpd.id = tpdm.id_downtime - AND tpdm.id_agent_module = $id_agent_module - ) tpdr - ORDER BY tpdr.id"; + SELECT DISTINCT(tpdr.id), + tpdr.name, + '.$tpdr_description.", + tpdr.date_from, + tpdr.date_to, + tpdr.executed, + tpdr.id_group, + tpdr.only_alerts, + tpdr.monday, + tpdr.tuesday, + tpdr.wednesday, + tpdr.thursday, + tpdr.friday, + tpdr.saturday, + tpdr.sunday, + tpdr.periodically_time_from, + tpdr.periodically_time_to, + tpdr.periodically_day_from, + tpdr.periodically_day_to, + tpdr.type_downtime, + tpdr.type_execution, + tpdr.type_periodicity, + tpdr.id_user + FROM ( + SELECT tpd.* + FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam + WHERE tpd.id = tpda.id_downtime + AND tpda.all_modules = 1 + AND tpda.id_agent = tam.id_agente + AND tam.id_agente_modulo = $id_agent_module + UNION ALL + SELECT tpd.* + FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm + WHERE tpd.id = tpdm.id_downtime + AND tpdm.id_agent_module = $id_agent_module + ) tpdr + ORDER BY tpdr.id"; $downtimes = db_get_all_rows_sql($sql_downtime); @@ -10227,8 +10747,8 @@ function reporting_get_agentmodule_data_max($id_agent_module, $period=0, $date=0 // Get module data $interval_data = db_get_all_rows_sql( 'SELECT * - FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', + FROM tagente_datos + WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', $search_in_history_db ); @@ -10333,8 +10853,8 @@ function reporting_get_agentmodule_data_min($id_agent_module, $period=0, $date=0 // Get module data $interval_data = db_get_all_rows_sql( 'SELECT * - FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', + FROM tagente_datos + WHERE id_agente_modulo = '.(int) $id_agent_module.' AND utimestamp > '.(int) $datelimit.' AND utimestamp < '.(int) $date.' ORDER BY utimestamp ASC', $search_in_history_db ); if ($interval_data === false) { @@ -10413,17 +10933,19 @@ function reporting_get_agentmodule_data_min($id_agent_module, $period=0, $date=0 * @param int Agent module id to get the sumatory. * @param int Period of time to check (in seconds) * @param int Top date to check the values. Default current time. + * @param boolean Show uncompressed data from module * * @return float The sumatory of the module values in the interval. */ function reporting_get_agentmodule_data_sum( $id_agent_module, $period=0, - $date=0 + $date=0, + $uncompressed_module=true ) { global $config; - // Initialize variables + // Initialize variables. if (empty($date)) { $date = get_system_time(); } @@ -10445,25 +10967,28 @@ function reporting_get_agentmodule_data_sum( $id_module_type ); $module_interval = modules_get_interval($id_agent_module); - $uncompressed_module = is_module_uncompressed($module_name); + // Check if module must be compressed. + if (!$uncompressed_module) { + $uncompressed_module = is_module_uncompressed($module_name); + } // Wrong module type if (is_module_data_string($module_name)) { return 0; } - // Incremental modules are treated differently + // Incremental modules are treated differently. $module_inc = is_module_inc($module_name); - if ($uncompressed_module) { - // Get module data + if (!$uncompressed_module) { + // Get module data. $interval_data = db_get_all_rows_sql( ' - SELECT * FROM tagente_datos - WHERE id_agente_modulo = '.(int) $id_agent_module.' - AND utimestamp > '.(int) $datelimit.' - AND utimestamp < '.(int) $date.' - ORDER BY utimestamp ASC', + SELECT * FROM tagente_datos + WHERE id_agente_modulo = '.(int) $id_agent_module.' + AND utimestamp > '.(int) $datelimit.' + AND utimestamp < '.(int) $date.' + ORDER BY utimestamp ASC', $search_in_history_db ); } else { @@ -10480,7 +11005,7 @@ function reporting_get_agentmodule_data_sum( return false; } - // Set initial conditions + // Set initial conditions. $total = 0; $partial_total = 0; $count_sum = 0; @@ -10489,18 +11014,9 @@ function reporting_get_agentmodule_data_sum( $partial_total = 0; $count_sum = 0; - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - // Do none - break; - - case 'oracle': - $data['datos'] = oracle_format_float_to_php($data['datos']); - break; - } - - if (!$module_inc) { + if (!$uncompressed_module) { + $total += $data['datos']; + } else if (!$module_inc) { foreach ($data['data'] as $val) { if (is_numeric($val['datos'])) { $partial_total += $val['datos']; @@ -10512,7 +11028,7 @@ function reporting_get_agentmodule_data_sum( continue; } - $total += ($partial_total / $count_sum); + $total += $partial_total; } else { $last = end($data['data']); $total += $last['datos']; @@ -10558,24 +11074,24 @@ function reporting_get_planned_downtimes($start_date, $end_date, $id_agent_modul // is inside the planned downtime execution. // The start and end time is very important. $periodically_monthly_w = "type_periodicity = 'monthly' - AND (((periodically_day_from > '$start_day' - OR (periodically_day_from = '$start_day' - AND periodically_time_from >= '$start_time')) - AND (periodically_day_to < '$end_day' - OR (periodically_day_to = '$end_day' - AND periodically_time_to <= '$end_time'))) - OR ((periodically_day_from < '$start_day' - OR (periodically_day_from = '$start_day' - AND periodically_time_from <= '$start_time')) - AND (periodically_day_to > '$start_day' - OR (periodically_day_to = '$start_day' - AND periodically_time_to >= '$start_time'))) - OR ((periodically_day_from < '$end_day' - OR (periodically_day_from = '$end_day' - AND periodically_time_from <= '$end_time')) - AND (periodically_day_to > '$end_day' - OR (periodically_day_to = '$end_day' - AND periodically_time_to >= '$end_time'))))"; + AND (((periodically_day_from > '$start_day' + OR (periodically_day_from = '$start_day' + AND periodically_time_from >= '$start_time')) + AND (periodically_day_to < '$end_day' + OR (periodically_day_to = '$end_day' + AND periodically_time_to <= '$end_time'))) + OR ((periodically_day_from < '$start_day' + OR (periodically_day_from = '$start_day' + AND periodically_time_from <= '$start_time')) + AND (periodically_day_to > '$start_day' + OR (periodically_day_to = '$start_day' + AND periodically_time_to >= '$start_time'))) + OR ((periodically_day_from < '$end_day' + OR (periodically_day_from = '$end_day' + AND periodically_time_from <= '$end_time')) + AND (periodically_day_to > '$end_day' + OR (periodically_day_to = '$end_day' + AND periodically_time_to >= '$end_time'))))"; } $periodically_weekly_days = []; @@ -10595,13 +11111,13 @@ function reporting_get_planned_downtimes($start_date, $end_date, $id_agent_modul // the start or end time of the date range. $weekday_actual = strtolower(date('l', $start_date)); $periodically_weekly_days[] = "($weekday_actual = 1 - AND ((periodically_time_from > '$start_time' AND periodically_time_to < '$end_time') - OR (periodically_time_from = '$start_time' - OR (periodically_time_from < '$start_time' - AND periodically_time_to >= '$start_time')) - OR (periodically_time_from = '$end_time' - OR (periodically_time_from < '$end_time' - AND periodically_time_to >= '$end_time'))))"; + AND ((periodically_time_from > '$start_time' AND periodically_time_to < '$end_time') + OR (periodically_time_from = '$start_time' + OR (periodically_time_from < '$start_time' + AND periodically_time_to >= '$start_time')) + OR (periodically_time_from = '$end_time' + OR (periodically_time_from < '$end_time' + AND periodically_time_to >= '$end_time'))))"; } else { while ($date_aux <= $end_date && $i < 7) { $weekday_actual = strtolower(date('l', $date_aux)); @@ -10646,68 +11162,68 @@ function reporting_get_planned_downtimes($start_date, $end_date, $id_agent_modul } $sql_downtime = ' - SELECT - DISTINCT(tpdr.id), - tpdr.name, - '.$tpdr_description.", - tpdr.date_from, - tpdr.date_to, - tpdr.executed, - tpdr.id_group, - tpdr.only_alerts, - tpdr.monday, - tpdr.tuesday, - tpdr.wednesday, - tpdr.thursday, - tpdr.friday, - tpdr.saturday, - tpdr.sunday, - tpdr.periodically_time_from, - tpdr.periodically_time_to, - tpdr.periodically_day_from, - tpdr.periodically_day_to, - tpdr.type_downtime, - tpdr.type_execution, - tpdr.type_periodicity, - tpdr.id_user - FROM ( - SELECT tpd.* - FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam - WHERE (tpd.id = tpda.id_downtime - AND tpda.all_modules = 1 - AND tpda.id_agent = tam.id_agente - AND tam.id_agente_modulo IN ($id_agent_modules_str)) - AND ((type_execution = 'periodically' - AND $periodically_condition) - OR (type_execution = 'once' - AND ((date_from >= '$start_date' AND date_to <= '$end_date') - OR (date_from <= '$start_date' AND date_to >= '$end_date') - OR (date_from <= '$start_date' AND date_to >= '$start_date') - OR (date_from <= '$end_date' AND date_to >= '$end_date')))) - UNION ALL - SELECT tpd.* - FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm - WHERE (tpd.id = tpdm.id_downtime - AND tpdm.id_agent_module IN ($id_agent_modules_str)) - AND ((type_execution = 'periodically' - AND $periodically_condition) - OR (type_execution = 'once' - AND ((date_from >= '$start_date' AND date_to <= '$end_date') - OR (date_from <= '$start_date' AND date_to >= '$end_date') - OR (date_from <= '$start_date' AND date_to >= '$start_date') - OR (date_from <= '$end_date' AND date_to >= '$end_date')))) - ) tpdr - ORDER BY tpdr.id"; + SELECT + DISTINCT(tpdr.id), + tpdr.name, + '.$tpdr_description.", + tpdr.date_from, + tpdr.date_to, + tpdr.executed, + tpdr.id_group, + tpdr.only_alerts, + tpdr.monday, + tpdr.tuesday, + tpdr.wednesday, + tpdr.thursday, + tpdr.friday, + tpdr.saturday, + tpdr.sunday, + tpdr.periodically_time_from, + tpdr.periodically_time_to, + tpdr.periodically_day_from, + tpdr.periodically_day_to, + tpdr.type_downtime, + tpdr.type_execution, + tpdr.type_periodicity, + tpdr.id_user + FROM ( + SELECT tpd.* + FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam + WHERE (tpd.id = tpda.id_downtime + AND tpda.all_modules = 1 + AND tpda.id_agent = tam.id_agente + AND tam.id_agente_modulo IN ($id_agent_modules_str)) + AND ((type_execution = 'periodically' + AND $periodically_condition) + OR (type_execution = 'once' + AND ((date_from >= '$start_date' AND date_to <= '$end_date') + OR (date_from <= '$start_date' AND date_to >= '$end_date') + OR (date_from <= '$start_date' AND date_to >= '$start_date') + OR (date_from <= '$end_date' AND date_to >= '$end_date')))) + UNION ALL + SELECT tpd.* + FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm + WHERE (tpd.id = tpdm.id_downtime + AND tpdm.id_agent_module IN ($id_agent_modules_str)) + AND ((type_execution = 'periodically' + AND $periodically_condition) + OR (type_execution = 'once' + AND ((date_from >= '$start_date' AND date_to <= '$end_date') + OR (date_from <= '$start_date' AND date_to >= '$end_date') + OR (date_from <= '$start_date' AND date_to >= '$start_date') + OR (date_from <= '$end_date' AND date_to >= '$end_date')))) + ) tpdr + ORDER BY tpdr.id"; } else { $sql_downtime = "SELECT * - FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm - WHERE (type_execution = 'periodically' - AND $periodically_condition) - OR (type_execution = 'once' - AND ((date_from >= '$start_date' AND date_to <= '$end_date') - OR (date_from <= '$start_date' AND date_to >= '$end_date') - OR (date_from <= '$start_date' AND date_to >= '$start_date') - OR (date_from <= '$end_date' AND date_to >= '$end_date')))"; + FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm + WHERE (type_execution = 'periodically' + AND $periodically_condition) + OR (type_execution = 'once' + AND ((date_from >= '$start_date' AND date_to <= '$end_date') + OR (date_from <= '$start_date' AND date_to >= '$end_date') + OR (date_from <= '$start_date' AND date_to >= '$start_date') + OR (date_from <= '$end_date' AND date_to >= '$end_date')))"; } $downtimes = db_get_all_rows_sql($sql_downtime); @@ -10775,10 +11291,10 @@ function reporting_get_agentmodule_sla_day($id_agent_module, $period=0, $min_val // Get interval data $sql = sprintf( 'SELECT * - FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp > %d - AND utimestamp <= %d', + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp > %d + AND utimestamp <= %d', $id_agent_module, $datelimit, $date @@ -10980,10 +11496,10 @@ function reporting_get_stats_servers() $tdata = []; ''.format_numeric($server_performance['total_local_modules']).''; - $tdata[0] = html_print_image('images/module.png', true, ['title' => __('Total running modules'), 'width' => '25px']); + $tdata[0] = html_print_image('images/module.png', true, ['title' => __('Total running modules')]); $tdata[1] = ''.format_numeric($server_performance['total_modules']).''; $tdata[2] = ''.format_numeric($server_performance['total_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'width' => '16px']).'/sec '; + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second')]).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -10995,22 +11511,22 @@ function reporting_get_stats_servers() $table_srv->data[] = $tdata; $tdata = []; - $tdata[0] = html_print_image('images/database.png', true, ['title' => __('Local modules'), 'width' => '25px']); + $tdata[0] = html_print_image('images/database.png', true, ['title' => __('Local modules')]); $tdata[1] = ''.format_numeric($server_performance['total_local_modules']).''; $tdata[2] = ''.format_numeric($server_performance['local_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'width' => '16px']).'/sec '; + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second')]).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; if (isset($server_performance['total_network_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/network.png', true, ['title' => __('Network modules'), 'width' => '25px']); + $tdata[0] = html_print_image('images/network.png', true, ['title' => __('Network modules')]); $tdata[1] = ''.format_numeric($server_performance['total_network_modules']).''; $tdata[2] = ''.format_numeric($server_performance['network_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'width' => '16px']).'/sec '; + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second')]).'/sec '; if ($server_performance['total_remote_modules'] > 10000 && !enterprise_installed()) { $tdata[4] = "
"; @@ -11024,11 +11540,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_plugin_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/plugin.png', true, ['title' => __('Plugin modules'), 'width' => '25px']); + $tdata[0] = html_print_image('images/plugin.png', true, ['title' => __('Plugin modules')]); $tdata[1] = ''.format_numeric($server_performance['total_plugin_modules']).''; $tdata[2] = ''.format_numeric($server_performance['plugin_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'width' => '16px']).'/sec '; + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second')]).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -11036,11 +11552,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_prediction_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/chart_bar.png', true, ['title' => __('Prediction modules'), 'width' => '25px']); + $tdata[0] = html_print_image('images/chart_bar.png', true, ['title' => __('Prediction modules')]); $tdata[1] = ''.format_numeric($server_performance['total_prediction_modules']).''; $tdata[2] = ''.format_numeric($server_performance['prediction_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'width' => '16px']).'/sec '; + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second')]).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -11048,11 +11564,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_wmi_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/wmi.png', true, ['title' => __('WMI modules'), 'width' => '25px']); + $tdata[0] = html_print_image('images/wmi.png', true, ['title' => __('WMI modules')]); $tdata[1] = ''.format_numeric($server_performance['total_wmi_modules']).''; $tdata[2] = ''.format_numeric($server_performance['wmi_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'width' => '16px']).'/sec '; + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second')]).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -11060,11 +11576,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_web_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/world.png', true, ['title' => __('Web modules'), 'width' => '25px']); + $tdata[0] = html_print_image('images/world.png', true, ['title' => __('Web modules')]); $tdata[1] = ''.format_numeric($server_performance['total_web_modules']).''; $tdata[2] = ''.format_numeric($server_performance['web_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'width' => '16px']).'/sec '; + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second')]).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -11082,7 +11598,6 @@ function reporting_get_stats_servers() true, [ 'title' => __('Total events'), - 'width' => '25px', ] ); $tdata[1] = ''.html_print_image('images/spinner.gif', true).''; @@ -11104,23 +11619,40 @@ function reporting_get_stats_servers() $table_srv->data[] = $tdata; $output = '
- '.__('Server performance').''.html_print_table($table_srv, true).'
'; + '.__('Server performance').''.html_print_table($table_srv, true).''; - $output .= ''; + $output .= ''; + } else { + // This is for public link on the dashboard + $sql_count_event = 'SELECT SQL_NO_CACHE COUNT(id_evento) FROM tevento '; + if ($config['event_view_hr']) { + $sql_count_event .= 'WHERE utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')'; + } - return $output; + $system_events = db_get_value_sql($sql_count_event); + + $output .= ''; + } + + return $output; } @@ -11462,120 +11994,100 @@ function reporting_get_agentmodule_sla_working_timestamp($period, $date_end, $wt } +/** + * Convert macros for value. + * Item content: + * type + * id_agent + * id_agent_module + * agent_description + * agent_group + * agent_address + * agent_alias + * module_name + * module_description. + * + * @param array $item Data to replace in the macros. + * @param string $label String check macros. + * + * @return string + */ function reporting_label_macro($item, $label) { - switch ($item['type']) { - case 'event_report_agent': - case 'alert_report_agent': - case 'agent_configuration': - case 'event_report_log': - if (preg_match('/_agent_/', $label)) { - $agent_name = agents_get_alias($item['id_agent']); - $label = str_replace('_agent_', $agent_name, $label); - } + if (preg_match('/_agent_/', $label)) { + $label = str_replace( + '_agent_', + $item['agent_alias'], + $label + ); + } - if (preg_match('/_agentdescription_/', $label)) { - $agent_name = agents_get_description($item['id_agent']); - $label = str_replace('_agentdescription_', $agent_name, $label); - } + if (preg_match('/_agentdescription_/', $label)) { + $label = str_replace( + '_agentdescription_', + $item['agent_description'], + $label + ); + } - if (preg_match('/_agentgroup_/', $label)) { - $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); - $label = str_replace('_agentgroup_', $agent_name, $label); - } + if (preg_match('/_agentgroup_/', $label)) { + $label = str_replace( + '_agentgroup_', + $item['agent_group'], + $label + ); + } - if (preg_match('/_address_/', $label)) { - $agent_name = agents_get_address($item['id_agent']); - $label = str_replace('_address_', $agent_name, $label); - } - break; + if (preg_match('/_address_/', $label)) { + $label = str_replace( + '_address_', + $item['agent_address'], + $label + ); + } - case 'simple_graph': - case 'module_histogram_graph': - case 'custom_graph': - case 'simple_baseline_graph': - case 'event_report_module': - case 'alert_report_module': - case 'historical_data': - case 'sumatory': - case 'database_serialized': - case 'monitor_report': - case 'min_value': - case 'max_value': - case 'avg_value': - case 'projection_graph': - case 'prediction_date': - case 'TTRT': - case 'TTO': - case 'MTBF': - case 'MTTR': - case 'automatic_graph': - if (preg_match('/_agent_/', $label)) { - if (isset($item['agents']) && count($item['agents']) > 1) { - $agent_name = count($item['agents']).__(' agents'); - } else { - $agent_name = agents_get_alias($item['id_agent']); - } + if (preg_match('/_module_/', $label)) { + $label = str_replace( + '_module_', + $item['module_name'], + $label + ); + } - $label = str_replace('_agent_', $agent_name, $label); - } - - if (preg_match('/_agentdescription_/', $label)) { - if (count($item['agents']) > 1) { - $agent_name = ''; - } else { - $agent_name = agents_get_description($item['id_agent']); - } - - $label = str_replace('_agentdescription_', $agent_name, $label); - } - - if (preg_match('/_agentgroup_/', $label)) { - if (count($item['agents']) > 1) { - $agent_name = ''; - } else { - $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); - } - - $label = str_replace('_agentgroup_', $agent_name, $label); - } - - if (preg_match('/_address_/', $label)) { - if (count($item['agents']) > 1) { - $agent_name = ''; - } else { - $agent_name = agents_get_address($item['id_agent']); - } - - $label = str_replace('_address_', $agent_name, $label); - } - - if (preg_match('/_module_/', $label)) { - if ($item['modules'] > 1) { - $module_name = $item['modules'].__(' modules'); - } else { - $module_name = modules_get_agentmodule_name($item['id_agent_module']); - } - - $label = str_replace('_module_', $module_name, $label); - } - - if (preg_match('/_moduledescription_/', $label)) { - if ($item['modules'] > 1) { - $module_description = ''; - } else { - $module_description = modules_get_agentmodule_descripcion($item['id_agent_module']); - } - - $label = str_replace('_moduledescription_', $module_description, $label); - } - break; + if (preg_match('/_moduledescription_/', $label)) { + $label = str_replace( + '_moduledescription_', + $item['module_description'], + $label + ); } return $label; } +/** + * Convert macro in sql string to value + * + * @param array $report + * @param string $sql + * + * @return string + */ +function reporting_sql_macro(array $report, string $sql): string +{ + if (preg_match('/_timefrom_/', $sql)) { + $sql = str_replace( + '_timefrom_', + $report['datetime'], + $sql + ); + } + + return $sql; +} + + /** * @brief Calculates the SLA compliance value given an sla array * @@ -11758,7 +12270,7 @@ function reporting_translate_sla_status_for_graph($status) */ function reporting_header_table_for_pdf($title='', $description='') { - $result_pdf .= ''; + $result_pdf = ''; $result_pdf .= ''; $result_pdf .= ''; $result_pdf .= '
'; @@ -11785,8 +12297,10 @@ function reporting_nt_top_n_report($period, $content, $pdf) { $return = []; $return['type'] = 'nt_top_n'; - $return['title'] = io_safe_output($content['name']); - $return['description'] = io_safe_output($content['description']); + $return['title'] = $content['name']; + $return['landscape'] = $content['landscape']; + $return['pagebreak'] = $content['pagebreak']; + $return['description'] = $content['description']; // Get the data sent and received $return['data'] = []; diff --git a/pandora_console/include/functions_reporting_xml.php b/pandora_console/include/functions_reporting_xml.php index 1a50db787d..938961da75 100644 --- a/pandora_console/include/functions_reporting_xml.php +++ b/pandora_console/include/functions_reporting_xml.php @@ -31,6 +31,14 @@ function reporting_xml_get_report($report, $filename, $return=false) unset($report['private']); unset($report['custom_logo']); // ---------------------------------------------------------------------- + // change agent name. + if (count($report['contents']) > 0) { + for ($i = 0; $i < count($report['contents']); $i++) { + $aux = explode('-', $report['contents'][$i]['subtitle']); + $report['contents'][$i]['subtitle'] = db_get_value('alias', 'tagente', 'nombre', $report['contents'][$i]['agent_name']).' -'.$aux[1]; + } + } + // Remove entities. $report = io_safe_output($report); From e28415250cb5d57970868eddfc8a4297b2a97151 Mon Sep 17 00:00:00 2001 From: marcos Date: Wed, 26 Feb 2020 15:18:42 +0100 Subject: [PATCH 11/45] remove entities from reports --- pandora_console/include/functions.php | 2 -- pandora_console/include/functions_reporting.php | 16 ++++++++-------- .../include/functions_reporting_xml.php | 8 -------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 85274c4f91..693e72d744 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3081,8 +3081,6 @@ function array2XML($data, $root=null, $xml=null) $node = $xml->addChild($key); array2XML($value, $root, $node); } else { - $value = htmlentities($value); - if (!is_numeric($value) && !is_bool($value)) { if (!empty($value)) { $xml->addChild($key, $value); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index ad8bc7765a..ec01cf13bf 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2298,7 +2298,7 @@ function reporting_agent_module($report, $content) $content['name'] = __('Agent/Modules'); } - $return['title'] = $content['name']; + $return['title'] = io_safe_output($content['name']); $return['landscape'] = $content['landscape']; $return['pagebreak'] = $content['pagebreak']; $group_name = groups_get_name($content['id_group'], true); @@ -2314,7 +2314,7 @@ function reporting_agent_module($report, $content) } $return['subtitle'] = $group_name.' - '.$module_group_name; - $return['description'] = $content['description']; + $return['description'] = io_safe_output($content['description']); $return['date'] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; @@ -2871,11 +2871,11 @@ function reporting_group_report($report, $content) } $return['server_name'] = $server[0]; - $return['title'] = $content['name']; + $return['title'] = io_safe_output($content['name']); $return['landscape'] = $content['landscape']; $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = groups_get_name($content['id_group'], true); - $return['description'] = $content['description']; + $return['description'] = io_safe_output($content['description']); $return['date'] = reporting_get_date_text($report, $content); $return['data'] = []; @@ -2975,7 +2975,7 @@ function reporting_event_report_agent( } $return['label'] = $label; - $return['title'] = $content['name']; + $return['title'] = io_safe_output($content['name']); $return['landscape'] = $content['landscape']; $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = io_safe_output($agent_alias); @@ -7358,7 +7358,7 @@ function reporting_general($report, $content) continue; } - $mod_name = modules_get_agentmodule_name($row['id_agent_module']); + $mod_name = io_safe_output(modules_get_agentmodule_name($row['id_agent_module'])); $ag_name = modules_get_agentmodule_agent_alias($row['id_agent_module']); $name_agent = modules_get_agentmodule_agent_name($row['id_agent_module']); $type_mod = modules_get_last_value($row['id_agent_module']); @@ -7872,14 +7872,14 @@ function reporting_simple_graph( ); } - $return['title'] = $content['name']; + $return['title'] = io_safe_output($content['name']); $return['landscape'] = $content['landscape']; $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = $agent_alias.' - '.$module_name; $return['agent_name_db'] = agents_get_name($id_agent); $return['agent_name'] = $agent_alias; $return['module_name'] = $module_name; - $return['description'] = $content['description']; + $return['description'] = io_safe_output($content['description']); $return['date'] = reporting_get_date_text( $report, $content diff --git a/pandora_console/include/functions_reporting_xml.php b/pandora_console/include/functions_reporting_xml.php index 938961da75..1a50db787d 100644 --- a/pandora_console/include/functions_reporting_xml.php +++ b/pandora_console/include/functions_reporting_xml.php @@ -31,14 +31,6 @@ function reporting_xml_get_report($report, $filename, $return=false) unset($report['private']); unset($report['custom_logo']); // ---------------------------------------------------------------------- - // change agent name. - if (count($report['contents']) > 0) { - for ($i = 0; $i < count($report['contents']); $i++) { - $aux = explode('-', $report['contents'][$i]['subtitle']); - $report['contents'][$i]['subtitle'] = db_get_value('alias', 'tagente', 'nombre', $report['contents'][$i]['agent_name']).' -'.$aux[1]; - } - } - // Remove entities. $report = io_safe_output($report); From a9590892bff81f47b5ec0dbdbcdfbc1a0aef3c01 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 27 Feb 2020 01:00:09 +0100 Subject: [PATCH 12/45] Auto-updated build strings. --- 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.rhel7.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 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a6c0f1ecd1..001f0a29c3 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.743-200226 +Version: 7.0NG.743-200227 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 4c621278c0..e95136b33d 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.743-200226" +pandora_version="7.0NG.743-200227" 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 98d3a9c315..821fc0c888 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.743'; -use constant AGENT_BUILD => '200226'; +use constant AGENT_BUILD => '200227'; # 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 10d5649817..707bd0ac80 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.743 -%define release 200226 +%define release 200227 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 db51f701d4..bd4543745a 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.743 -%define release 200226 +%define release 200227 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 002489bcb5..e1c8ee6023 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.743" -PI_BUILD="200226" +PI_BUILD="200227" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 71ab0834a4..27de9dfb3f 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200226} +{200227} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f040a056c6..b1742ee522 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.743(Build 200226)") +#define PANDORA_VERSION ("7.0NG.743(Build 200227)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 0566d55675..e83e5ddd72 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.743(Build 200226))" + VALUE "ProductVersion", "(7.0NG.743(Build 200227))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index e4d01504de..40d630de57 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.743-200226 +Version: 7.0NG.743-200227 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 345aa9c6de..c194a13328 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.743-200226" +pandora_version="7.0NG.743-200227" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index b89c70b805..9a66189fc2 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200226'; +$build_version = 'PC200227'; $pandora_version = 'v7.0NG.743'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 69b1197687..eae7295b5c 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index a087989e35..89dd77a302 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.743 -%define release 200226 +%define release 200227 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 978fcebb9b..c67b3bce46 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.743 -%define release 200226 +%define release 200227 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 7d2a53d374..7f7483f02e 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.743" -PI_BUILD="200226" +PI_BUILD="200227" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 5fdab63ed0..f053063e2d 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.743 PS200226"; +my $version = "7.0NG.743 PS200227"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b4bcdd5689..9701044517 100755 --- 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.743 PS200226"; +my $version = "7.0NG.743 PS200227"; # save program name for logging my $progname = basename($0); From ac6ca52c45b5e06920e21c3367e9ea12aaf2dd38 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 27 Feb 2020 10:52:01 +0100 Subject: [PATCH 13/45] Fixed resulution charts --- pandora_console/include/chart_generator.php | 4 ++-- pandora_console/include/functions.php | 21 +++++-------------- .../include/functions_reporting_html.php | 8 +------ 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index e0c3d2e40b..b78d2c348a 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -169,7 +169,7 @@ if (file_exists('languages/'.$user_language.'.mo') === true) { $module_list = json_decode($_REQUEST['data_module_list'], true); $type_graph_pdf = $_REQUEST['type_graph_pdf']; - if ($params['vconsole'] === false) { + if (isset($params['vconsole']) === false || $params['vconsole'] === false) { $params['width'] = (int) $_REQUEST['viewport_width']; if ((isset($params['width']) === false || ($params['width'] <= 0)) @@ -180,7 +180,7 @@ if (file_exists('languages/'.$user_language.'.mo') === true) { } if ($type_graph_pdf === 'slicebar') { - $params['width'] = 150; + $params['width'] = 100; $params['height'] = 70; } } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 693e72d744..0ebd4bf419 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3870,23 +3870,12 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined=false $img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file; } - $width_img = 500; + $width_img = 550; + $height_img = $params['height']; - if ($params['vconsole'] === false) { - // Set height image. - $height_img = 170; - $params['height'] = 170; - if ((int) $params['landscape'] === 1) { - $height_img = 150; - $params['height'] = 150; - } - - if ($type_graph_pdf === 'slicebar') { - $width_img = 360; - $height_img = 70; - } - } else { - $height_img = $params['height']; + if ((int) $params['landscape'] === 1) { + $height_img = 150; + $params['height'] = 150; } $params_encode_json = urlencode(json_encode($params)); diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index dc832dd870..f859eb8f32 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3473,7 +3473,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) } // Check failover availability report. - if ($item['data'][$k_chart]['failover'] === '') { + if (empty($item['data'][$k_chart]['failover']) === true) { $table1 = new stdClass(); $table1->width = '100%'; $table1->data = []; @@ -3482,12 +3482,6 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table1->size[1] = '80%'; $table1->size[2] = '5%'; $table1->size[3] = '5%'; - if ($pdf !== 0) { - $table1->size[0] = '20%'; - $table1->size[1] = '60%'; - $table1->size[2] = '10%'; - $table1->size[3] = '10%'; - } $table1->data[0][0] = $chart['agent'].'
'.$chart['module']; $table1->data[0][1] = $chart['chart']; From ec57540fb0228b35afe4d98b1dcba09e95b8147e Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Thu, 27 Feb 2020 11:20:24 +0100 Subject: [PATCH 14/45] Ent 5432 libreria de modulos de pandora integrada en consola --- pandora_console/godmode/menu.php | 17 + .../module_library/module_library_view.php | 160 ++++++ pandora_console/godmode/setup/setup.php | 13 + .../images/gm_library.menu_gray.png | Bin 0 -> 362 bytes .../images/gm_library.menu_white.png | Bin 0 -> 337 bytes pandora_console/images/library.png | Bin 0 -> 349 bytes .../module_library/Application-monitoring.png | Bin 0 -> 1327 bytes .../images/module_library/Artwork.png | Bin 0 -> 1110 bytes .../images/module_library/Inventory.png | Bin 0 -> 1054 bytes .../images/module_library/Miscelaneus.png | Bin 0 -> 1646 bytes .../module_library/Network-Monitoring.png | Bin 0 -> 876 bytes .../module_library/Operating-Systems.png | Bin 0 -> 1715 bytes .../module_library/Security-monitoring.png | Bin 0 -> 1323 bytes .../module_library/System-Integrations.png | Bin 0 -> 1405 bytes .../images/module_library/Tools.png | Bin 0 -> 1563 bytes pandora_console/include/functions.php | 16 + pandora_console/include/functions_config.php | 21 + .../include/javascript/module_library.js | 514 ++++++++++++++++++ pandora_console/include/styles/menu.css | 6 + .../include/styles/module_library.css | 265 +++++++++ 20 files changed, 1012 insertions(+) create mode 100644 pandora_console/godmode/module_library/module_library_view.php create mode 100644 pandora_console/images/gm_library.menu_gray.png create mode 100644 pandora_console/images/gm_library.menu_white.png create mode 100644 pandora_console/images/library.png create mode 100644 pandora_console/images/module_library/Application-monitoring.png create mode 100644 pandora_console/images/module_library/Artwork.png create mode 100644 pandora_console/images/module_library/Inventory.png create mode 100644 pandora_console/images/module_library/Miscelaneus.png create mode 100644 pandora_console/images/module_library/Network-Monitoring.png create mode 100644 pandora_console/images/module_library/Operating-Systems.png create mode 100644 pandora_console/images/module_library/Security-monitoring.png create mode 100644 pandora_console/images/module_library/System-Integrations.png create mode 100644 pandora_console/images/module_library/Tools.png create mode 100644 pandora_console/include/javascript/module_library.js create mode 100644 pandora_console/include/styles/module_library.css diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 4ac5fd265d..b370bc2ac9 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -313,6 +313,8 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=integria']['text'] = __('Integria IMS'); $sub2['godmode/setup/setup&section=integria']['refr'] = 0; + enterprise_hook('module_library_submenu'); + $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; @@ -498,6 +500,21 @@ if (check_acl($config['id_user'], 0, 'PM') && $config['enable_update_manager']) $menu_godmode['messages']['sub'] = $sub; } +// Module library. +if (check_acl($config['id_user'], 0, 'AR')) { + $menu_godmode['gmodule_library']['text'] = __('Module library'); + $menu_godmode['gmodule_library']['sec2'] = 'godmode/module_library/module_library_view'; + $menu_godmode['gmodule_library']['id'] = 'god-module_library'; + + $sub = []; + $sub['godmode/module_library/module_library_view']['text'] = __('View'); + $sub['godmode/module_library/module_library_view']['id'] = 'View'; + + $sub['godmode/module_library/module_library_view&tab=categories']['text'] = __('Categories'); + $sub['godmode/module_library/module_library_view&tab=categories']['id'] = 'categories'; + + $menu_godmode['gmodule_library']['sub'] = $sub; +} if (!$config['pure']) { menu_print_menu($menu_godmode); diff --git a/pandora_console/godmode/module_library/module_library_view.php b/pandora_console/godmode/module_library/module_library_view.php new file mode 100644 index 0000000000..bad7dd1308 --- /dev/null +++ b/pandora_console/godmode/module_library/module_library_view.php @@ -0,0 +1,160 @@ + false, + 'text' => ''.html_print_image('images/gm_setup.png', true, ['title' => __('Setup')]).'', + ]; +} + +$buttons['categories'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/list.png', true, ['title' => __('Categories')]).'', +]; + +$buttons['view'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/operation.png', true, ['title' => __('View')]).'', +]; + + +$tab = get_parameter('tab', 'view'); +if ($tab != 'search_module') { + $buttons[$tab]['active'] = true; +} + +ui_print_page_header(__('Module Library').' » '.__('View'), '', false, 'module_library', true, $buttons); + + +// Styles. +ui_require_css_file('module_library'); + + +// Get params. +$page = get_parameter('page', '1'); +$search = get_parameter('search', ''); +$id_cat = get_parameter('id_cat', ''); + +// Show error messages. +echo '
'; + +echo '
'; + +$sidebar_library = ' + +'; + +switch ($tab) { + case 'search_module': + echo '
'; + echo '

'.__('Search').':

'; + echo '
'; + echo '
'; + echo ''; + echo '
'; + echo $sidebar_library; + break; + + case 'categories': + if ($id_cat != '') { + echo '
'; + echo '

'.__('Category').':

'; + echo '
'; + echo '
'; + echo ''; + echo '
'; + echo $sidebar_library; + } else { + echo '
'; + echo '
'; + } + break; + + default: + echo '
'; + echo ''; + echo '

'; + echo '
'; + // Show 9 categories. + for ($i = 1; $i <= 9; $i++) { + echo '
'; + } + + echo '
'; + echo ''; + echo '
'; + echo $sidebar_library; + break; +} + +echo '
'; + +?> + + + ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', ]; +if (check_acl($config['id_user'], 0, 'PM') && enterprise_installed()) { + $buttons['module_library'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/library.png', true, ['title' => __('Module Library')]).'', + ]; +} + // FIXME: Not definitive icon $buttons['notifications'] = [ 'active' => false, @@ -190,6 +197,12 @@ switch ($section) { $help_header = 'setup_integria_tab'; break; + case 'module_library': + $buttons['module_library']['active'] = true; + $subpage = ' » '.__('Module Library'); + $help_header = 'setup_module_library_tab'; + break; + case 'gis': $buttons['gis']['active'] = true; $subpage = ' » '.__('Map conections GIS'); diff --git a/pandora_console/images/gm_library.menu_gray.png b/pandora_console/images/gm_library.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..1923a2e2727b4c8899bf8a5624f6cd42a2796a90 GIT binary patch literal 362 zcmV-w0hRuVP)L;LkKOalj!3;%?ELbG%hl+iGih&HDfX(|L z+d!$IkO&`Mfci!dNC$!(1a!RsDPf8YYy@HfXt32o#T>91+7DFpA4C%qc~I}KhlVW! za>^jfrO*t3o(UW%^*#fZBxV2$S4s>$h(*kS+Af8ME7^wP3s)uzOF69JN~xh(!`o^>;M1& literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_library.menu_white.png b/pandora_console/images/gm_library.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..199acd82ea67e65497062ef58d3119915c149672 GIT binary patch literal 337 zcmV-X0j~auP)&G^y*{mELs~fsW`}2GC*T-0)%TEp#&v j-cbLQ8@0lR-2@l_B~QsZ%lkXf00000NkvXXu0mjf@3)UN literal 0 HcmV?d00001 diff --git a/pandora_console/images/library.png b/pandora_console/images/library.png new file mode 100644 index 0000000000000000000000000000000000000000..4096717a1d81ae0b95dbbb9836e2ebd0ee1996fd GIT binary patch literal 349 zcmV-j0iyniP)GWZ5toF$y}bgEnvW)& zc<|uC2ZRh|!XpPV)B%VuK(PZ70TwIS7G*}H?4-E#q5duw8AiN%k3t%abQkNpTmVuB9D zqn1liTuYXrz;OM5C6(Ay>QcPnN{OKd(f9(eaHXb8;jSgyP<-J^iA!<07GCrfqLoq` vpt+_IO+C8H7DCHdQ21^jrT`}!00bBS3Gha`B}_!f00000NkvXXu0mjfbtr(1 literal 0 HcmV?d00001 diff --git a/pandora_console/images/module_library/Application-monitoring.png b/pandora_console/images/module_library/Application-monitoring.png new file mode 100644 index 0000000000000000000000000000000000000000..4ef6a9da2abc91747218cc65ddc97ae80a8b54c1 GIT binary patch literal 1327 zcmV+~1RCwC#THSHlKoC9{-c2fq+(5>z zz|vD5ZC8M(z@~v<(g30YGCcVU3w@N$fA_JlW zn|CC%KE_=8c7#!@&{~rs_jfjYmcX+5!t9$O)@x}QCLLkdT5mNibxQcm%@L(6 zmQb2~ry$rVeEXPWNbBws=&%rAg0PA z@40pEK5FeM8Xnq~Y(kp>$iORYiqezC&B+9g=EHRX9u)wq8wb}k_W=5%uCr3Wi-Nkg9Kz7Pd~7N4%EDxjp7|#em^t+-uTVVKALGL9GXMpX)B0TskcNf{T&&}2<&6$>-^LNz0Hj@W{q0sd7 z&_3*Cr4tc>*P7MA22}5ZWt9^OfcknLRMiFONfv$Fmk)1B86nJL8xtRwBvh`I@U^Khzgr7}QKTSY z%ZNm~sFa4&EP_x{E({Wq8ij*3H_s>_67d_|(k2bZk3~Oeir1iinc$VxoxroW3VOz~ zojeP{cb;i1d6ROwC`nZx9zfGwQML3+1~0QE6A3fde<)j;{cSD_0n8WoMj2qk%0UZS zJ_qm-#$$zuEkV12NCd)#u5#QV!S8DYR0f+FwBT<$d(DA9l&+H2f0v+Zf7Iq?J_CzU z1MB*^U$q&3katS}otHb^O;r!*C|g}O&u8^tEix*$K`nrDntt2TNorW#ru*GSY1o2> z{s*>TN7Az`FRkD4(&EOba8d-dL^WSr5hs|W#6wCZ7 zlht$nv(~!-?s)5${qyVh&psRcHUj(d_#-X4?@E9MY=~KZXt6SL)|U+UsuVDS-Lmd= z#EMr8bW{fTfM$G>5bFt>khKXR!!TyUob>>24LOEh!GqjqBQS@yfkppK*f2t+L3@!! z>3~dHx7m)_`T=Yr;*zDMv?Km|R7y)VdOuLyG7bYCG*A$I%)`+~@ ziiSn)IuyK2%K~LxA`7Br9A`vI=81EURsai&2A})IJNgoh*q(&4<`T;K%C%fGV%ymO zkn!xA&!&xmvJP}CI)IkgQ~r&P;`1%PG_4Cn`RYaqmh zXPv6cX3#Rxd{Wu$gfx~b1}zX4xWj#u0Xu|gCAjdp=5LHuh|0xHTF9??!L@4sO|fT< z1YDAj_nI*QBKnACi>3kg$zqE@e!9dWt^!zSdkrSnnkan&DEPB?W?UFF9WeitBQ{SF z?98d&54);K4{8XalRmu1!hNJuzzZ7yL)H1$FzK9bzMoV70!L@_l{Nre!7mm%?4<>b z=j_{&2U>)`cL3kLNLl+8MSiOrx@axHre7SgVOsLYjtiJQyTO1oxui+^hTk)-sD|Kw z3sU2r>RlTf0)0spbJ}b(c-$f4K+5J8|7iek&ffn$is)MN4(6C3!OVfK}4<=Zc>9l0?gLdNF+KqTr cw%-B_0M+W2Nr0q}*#H0l07*qoM6N<$f+~CfeEgT&KG;XE zS5xlS1pTardPWU- zasdhqR@8uJ!;+@!&84jL1}m$C@rp`#qIY=8EWCDMj@()VdU*-JY@O$5RV=pT;l22^ zgonZ2P-7ol%RP-P0p3Ge3m6U_E3>Hj-g^NgulT-5@a!)k;ZR78)%3B1ho$P(;8`0y zxp;SbfXQ0!;8sGk8ODluVuR8eNV;dL<23kT!}|KjV6^nMW%Z(Kpiu$X2>#SZp8ARf zP^c(`UD=nmB)k;h9Qf7^fzBZ5tU~bdd}{35ii8mwG6ja!O^n}%3kLu?HS*-EQ0V}Yaz*ek$Cw8FL_lxhjyx=itT~0EqUozc@y#}c zbrO_ONm3t(p%egS0PjH36D&k7z^29|CTA4dXKQXr8yo=AD(h+0)p0ALDoz*@ECP@1 z)uE8b&sh^stlm~BZBSNp%J3dlI%+}vmt9hTh0v3K6%xH@l!c6KTBhQaA}xAAAbhTN zO+E}3tNgS{QM}Wko9c7`?+`N;X9xs5m-27r+`;k01#CUE!~9?TtqTxq5C}Ca}L_pNl;FzctFzH z=RFu7sCY({=AKd2_jS_LMu0_ZJm)hcP8sR9o%+9MCyknI%GywAM@VjGW?DxyA??B* z{%|#|0dNl}9V9#e{y;Qt<0a-tXqG9g`W0VmfYsYdrfsU_ zlX*K07o-=n2Uy$Ksq0QHF!z{K&$UvQ2HUgTqQNfJoV!*5tA**sykJoUzE09@ zlv?iH!}_WEeAFi3S6HHQr{RYQG2sIpu`x&bTm!wYVb&}Dys~Xz)#wI-9b$ob9j(;o znv#83O@Aj*-@m0`Ctx#d-hIt{1!x`-BR&@}`H|D^>P3QnV%d!XdnC)J0PAY4C%j&_ z1-NHCIC2C&*OWG_qtndDGu33qIzAULXjeD}dd>C@Eu-qo9?Cl;k-?HY}FW4Y&dD#T;hlhfW1EiZ@ z@V@8D0t9Kla-_>9WQDPE<0l;K)}87okKrT)IL)!*F` zutx%`cd)N5Wub~#VgR~DlwNir9SJG{w_;@yBs1FR|1d*cSJ>nNz>lVa>sSCk<7N>F zX$|d#?swR2@xQ)LFRLc?@!UE+^&K_4;CL@RyB0;nH@R5of#@dIy=w|q=E3WN{CVrZ z5RtDLe0x(y=_xHZ^9V9I<<0_b(0IUib3?%FJltZ0^$dmDU8A=YQ@!gm9ypLS?MIhb zS>i(B84D!Nj7X>vK1BdPSGNl^z!x<0QaP+B#T}n&iTD~jujEEc z=E>+l_NrPt6?0B}PY;_k@s6mtNVkcEm}>Ak5EGArJ*%^Q^1!2-!Xeq4*?yL*jC(sCg7kQ zreE%Ts96Ilt2oq`Ljf1QQ4*k@iN<{@`4W_LzRb#f7k&!iF{z5KmQxH3aw#-M@LEw2 ztP>qvKzIv}CO%wt{$pD8g}`c{bM{$8=ZVpDSXb228>)<2wQy`uRJt8@~ literal 0 HcmV?d00001 diff --git a/pandora_console/images/module_library/Network-Monitoring.png b/pandora_console/images/module_library/Network-Monitoring.png new file mode 100644 index 0000000000000000000000000000000000000000..ee62020ad57849667fef2fcf6952724878196d03 GIT binary patch literal 876 zcmV-y1C#uTP)21Gp-?Ck3WY+UP$(1%#ea`*jzPbE`w+vAEeRB3%jZu&nmL6aXM*M8;|ymYEumzN z<{eDn%M3yz7x@pi_SDn4#FBz*W=glLV6gex zZ@*(~pQDV)v#8UeySMdt(?{kxhkE}lI!4zRK2BO+Njfb%_!}F1hdW;&al6_TnEn08 zqwWBGH>CZIv|00gg7ylX=$3qH7pTuAcX;n`C|6vBl9^Tk6MF0!#89yY7qM+GnJHVR zbb|U{j^k?8zO)e7-IAGW)5EcpJw(S$?4P4<0B75;7CDC<#77u>g<|NgS~E6|_g7GV z>==Jd#%*qJ7A)ejQC%e#OZ$jN^y?HY!8uv*RN^tBCB%9Kqt{*I*_q)tV!hxC)_IAc z?;cHSgV9cJ(fIp7Ow;y%zQs97FdhXb_6_>L#ZnPB(?N&mU?}HMEIjE}%)&D>P;Ap4 z^j*OImB+gpX|b+jY0ZuTn_=Xb!{*HWzcO!1#pYe++!3W2%z9GfOquZSQ;$(D_<>Ej zW=R2!knSAg4HZi{E$(Swd|r9p6%kCszs6yL7ZO0w4C#OtkPZ|Zu<);Ta2k^JBvS>y zlgiIJ(!zfVzR)s52j=qN@z9K?XKLx=jLD^-krsR;roE>VAUBdNUW5ccljk$zjL6lI z2xsV6%`5TL?eP+^D;2TZM-=tb!jNF0R{k<_m9JevcK`CDYZrsflxPx1TbzYCuaJhps##teVHdB#XxI5A&4C?g{? zH>92vX@G8zB_Ge2;Tb$O<{8W8$5@?sfHGC12#(Dl#K%~-$e(%w8{!!Oo*|Z9z?km< zNBF+LtY_-@P&aFnKk+o76HI80XIz=@66dBiz%pXY*2Lq|s#&ok$PZ|#G~W@P5%Tjj z;DTKH#iv4Mwri5VQ}Q!U?!2Ny&v-@zu$c{TLQ3&id0NLd`H7i~$^+OPCa@+qmbH9^ z34b4!XuXBzqSE}{62+(Hm=9~*z#0YCnNP4+(0c;UDxGn-MW|QMz5us@b=@=Wx&D|@ zw;sckFUtmf!1e}Apz|LAv;}P12kc&eMKBSjDQn;0>h#HX3 z2wP&^JIAC|6yuw`eW&W$0M*azW)#dk1^JGPh$wY}r+7Q_si|;tP?w4!1BA zol@+}TCNG%YF*atIZAbJ&_a5`A!6aOXlQPte+CIx3Dm1pu$QUXxBBab1_Y3y{Fumyr3lg6Il*t7Gc7wwV43P znxYmW344@(u4`Q9CIjRq&_6^TK9R(yjisAdSI}C{6ggc(P)YGo54onY5Zfh`wcWp? zxLZ2p>U$e-4@&=7rM&L|XArhk9f@1+9mDc77irNNtSrre8z@uj`ypGxUDZNLL15W= zB#>JFye%v(gSWc?Qsz~bwoI4Xl^rp)i@>UuQKuNjwUbalM-qRSoqSp$jmThxMTw=|fV>N03@W5X+Wqss@N= zw@~_66LQN4vA=}dO*$-m-BoHHEww}jQvuMTV;#$Gp%nHpxqHK`Uk&gVDhj@JWKg%K zDi7tsb1uxA-{$jRiIWwULPZ|H>7=;yHRsAyUrS%BI!OaS73L*My&2Lvy>8D%QN5W) zd%N0GHki~k1Fi<>m*DMt90{@Yv?GU}5EchKDw5rB@8rg z&731#-E|f1NK#?~m0+@hwglpo7Pf_^8Lh#M^sV5^wy~!5S%MGdmXNjEBg7qT4f7U= z-gzjn24m`frC{e35t!V6g~?l}?5_yEzdu$6^a{gAcP$snI%!MCvQ{K!+gq|-lTs&i z;sf-M&9s>c6{#g|&Rt~Xh~0ONPRk(Bqho+o*G9qj{o%-BS!pgjp+f4~AC9Sn+#B@h zm|z_;-o)X7I_w2{{Lx^247htrC2DW>9v=v{I2G8TpvOJI#>$0~;0G9ofF8Ag`vQV_ z1VAq_kmSp|A5B?!;UO2$Yx))>+35VljIZ0YQ)-0S!o^Uqx?d)}tHd*CJ^tkz?b2Jy zkT#ayP(4tuwMG8a$3{1-$X(1lc>5B1Yy&L*pWu~wQR;puSl*r?`Pq<0pQGXMx?Kya z7TgPKYwEk8iW=SeXoGws0K|MmH^sn|tkuAxR49$to(ZPogNk84I z`yq)adMVGl#HZ-=^VjzYdzrAh|Mcc0lA0j(g}q2m3Z;PDA0%0UYOgzqhgiU$Rc0~n)W1E_MX5+gQNfNy=S z@z@h+ioxd6fUS&D19$}RHEU;k5?~_D8&)&LS6W+Nw4DQ7))d~}nz!Gk?YPBYIOG)u z6x9sI+uFk#ubb2o{cTO*V?%Y#06DDr+7or-zw_x^HOq#=^I)cI1n`ys`b$x* zft9`!kbOYP!NU;H_xN3~g7K_SM+jS|O}{Y({>d9B){}$wYg9={e|CbrWbX@D6cH6g zis0a`$yl6Au?0?i2Lk5~Ow0VtC7SvMPC}0uLB|#PDzR*iF2JuG##04`U9y)YtbPW+ zet>sqU0$_?45`k5%_ZwEv})5O@Iykt>UBr3e1b37x-_j3BbCNY^w0xR=|}`!bGxs zYh}hO&rNBDMWF+$@jK!|k1i5UkPA1ey$JhQXDbDC-octpb(*OIzHiv>5oJvzy=#E( z!a!wB>TJ7)FKeQ&71_$sK?j2+E>RYgIWPuQX(SwBfI8?ZulCQ{qXsu7L+_;Km@MYJ?6HL5*t! zWUtZ+RUMez%TTEI2ySEHJ6uFqo9NWpCbV3W=c!@tEK7P52sS6d&zo5oM~Ws z`-Yq|(NfrEJ#afaXiJYA3>-+n(bH}6+2q4>TPZ`*{Mh9p`g8nJU{JQObT2C*5}goO zqx0g}vSTXc5qxYH8w9jpe)e3zG9Sd+6;k)TiC2*4h0A7|-)ZEl^k_hU_vcP8> z;(kg*d96<_y_`HCnxeBlZ&Umqr}Bb9RMLbF>UE|yNE{jb7j2pilF^n8@b1VFf)elfz`HuA5_0a4jz|z{T`@aJP4gSA}PXEvnzPZFh~ZW?+{QwNo{v8nA}> z`uFRWY|O9mYh2X0YWm{yKYtcSvL&Oh2}x~JB;*yM&bsbf_wDQ6~>!{8Tf?z>j&Pq?la zEN%K9Py9fJ^%mqJ|cr;;TY{eR)KJ!1Um-j0BVS zn$zDcP=xJ)wOzAwK-GOgdNX zpNTNxrY(}aOqV*!e8Pr1+ynS!?obY9{W5Xr@y@4ffUyl%&R&%VECMu|Ioo6K_!PM z0>+{M$l5%ffh$=8^T?J+pFM~aw{f_Ue;$@ix3+Ai!7BF9>IjEhiB874X>XK{Q_(Ca zVI?Es5>JkR=p0uqHS`sS4Sv}L2b^QcuOzTZE>+36L0+}3+mGh^yJI$G-Qg_yjf4TT zUO+fpeEb#)cxv8u9e191YXIB|tys`G1aT)JT57MkXR zKO*qd4Lz{jynV~SC@U#6=#v0GaTVoi?dS~9cL;Z;gzg3UY=DLK3IIRk!!-ihBi;ek zuF)FwSphrh=G5WCm8;Jk3OX9VM_7m#=<6;628e;6lw9Ezi0b#M@z;F~D^1JDZ+W%N z*RLexA^&UjHxRq5wC5e)CTt7YA5?&W-1PyjF8eER#(i8(FID9y~_V{`gw#(;)BjwIvC$hd0+ zOt5S5@!X81x#{r&pjMul8GX-Xg^_Jk8(6^FH`jv)S=gz$@#c*{dnC&ko^Q4InSNiB zeD?E^k*ln_XI24gZ*pTH>82+E%ylnj4Br5D53ox!Zj3y+)h21Y7VH_Y0(&xFb3Q$c z9-5HtGv;^^1NID<-ef_)ExLy^k1%0uDp)}H6Q$y?Q9zV2O%ZD9PS7VBz7NCI8Xd!RZyl9-%IdmSbmE3_GI1D;|rhGU?c`@ZFx))N6YD@jrn**utNdb|zE- zl^5~h4q+1l{0eE~xUEm8HNdz`dnckMN71OTaGmwtM@6JY&}jhZkorZwnzR#GaW8(U zB~?s~G@VwM>H=z6t}#Dr4f3vF13DVD?vV!gCHv1jWS>XPq~cYFF|^`o1MLFdlL_-; zbR9vykq|!E1H=LR`D{xCSlU@Z-vnCQX`T zbYGh~s)V&xU`9$?Df-~scuff@Ca-PvL=9ewG<5IU!61Qo8FHog5J%$_NAhz4eWq-3 zsZ-+3L@-ObfR@0lMO@c;ggG!*IvlvVD1DNJng-OfINenNHHOYK0U==Ylb;(*<{qJ4 z+a!XEb_#Miv|VFCZ}FPUku~u#5t?)fTY#4DMWT{i2zmB~u zU>{cuXfk80pC=q&GEKYuM>1^&c<}7JTSHJQAlUVkRf4Xd7mg|F05i}Ta3O*hFF+q$ zT?eXWIH*m<6vwsfp<_*3xu=e7fS}V@|>D=4$|8v9RYcS^@ zmYP=FT=tV}0Qxt1y;1F5@_O&%E`gmi9j$CgXzavDd0y4!X`q=th*pmpxX222$r~JG z&g;az48#A8Q#S2d_Q=HFgQ*-y-ST}ubIYxAs literal 0 HcmV?d00001 diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 0ebd4bf419..6a5b183b85 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -4999,6 +4999,14 @@ function get_help_info($section_name) } break; + case 'setup_module_library_tab': + if ($es) { + $result .= 'Configuracion_Consola&printable=yes#Librer.C3.ADa_de_m.C3.B3dulos'; + } else { + $result .= 'Console_Setup&printable=yes#Module_library'; + } + break; + case 'diagnostic_tool_tab': if ($es) { $result .= 'Gestion_y_Administracion&printable=yes#Diagnostic_tool'; @@ -5127,6 +5135,14 @@ function get_help_info($section_name) } break; + case 'module_library': + if ($es) { + $result .= 'Intro_Monitorizacion&printable=yes#Librer.C3.ADa_de_m.C3.B3dulos'; + } else { + $result .= 'Intro_Monitoring&printable=yes#Module_library'; + } + break; + case 'agent_snmp_explorer_tab': if ($es) { $result .= 'Monitorizacion_remota&printable=yes#Wizard_SNMP'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index c4458df66f..96f266fc1e 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1587,6 +1587,18 @@ function config_update_config() } break; + case 'module_library': + $module_library_user = get_parameter('module_library_user'); + if ($module_library_user == '' || !config_update_value('module_library_user', $module_library_user)) { + $error_update[] = __('User'); + } + + $module_library_password = get_parameter('module_library_password'); + if ($module_library_password == '' || !config_update_value('module_library_password', $module_library_password)) { + $error_update[] = __('Password'); + } + break; + default: // Ignore. break; @@ -3025,6 +3037,15 @@ function config_process_config() config_update_value('integria_hostname', ''); } + // Module Library. + if (!isset($config['module_library_user'])) { + config_update_value('module_library_user', ''); + } + + if (!isset($config['module_library_password'])) { + config_update_value('module_library_password', ''); + } + // Finally, check if any value was overwritten in a form. config_update_config(); } diff --git a/pandora_console/include/javascript/module_library.js b/pandora_console/include/javascript/module_library.js new file mode 100644 index 0000000000..9f5c64fc1f --- /dev/null +++ b/pandora_console/include/javascript/module_library.js @@ -0,0 +1,514 @@ +/* +Variables from PHP: +- token +- more_details +- total_modules_text +- view_web +- empty_result +- error_get_token +- invalid_user +- error_main +- error_category +- error_categories +- error_no_category +- error_search +*/ + +$(document).ready(function() { + // Save categories in sessionStorage to avoid making the request to the API many times. + function set_local_categories() { + var local_categories_exist = sessionStorage.getItem("categories"); + + if (local_categories_exist === null) { + get_all_categories(); + } else { + // Categories view. + var local_categories = JSON.parse(atob(local_categories_exist)); + if ($("#categories_library").length) { + var local_cat = ""; + $.each(local_categories, function(index, value) { + if (value.count != 0) { + local_cat += + '"; + } + }); + $("#categories_library").append(local_cat); + } + + // Sidebar. + if ( + $("#categories_sidebar").length && + $("#categories_sidebar ul li").length < 1 + ) { + var first_level = ""; + var second_level = ""; + var parents = []; + var children = []; + + $.each(local_categories, function(index, value) { + // First level list - parents. + if (value.parent == 0 && value.count != 0) { + first_level += + '
  • ' + + value.name + + " (" + + value.count + + ')
  • '; + + parents.push(value.id); + } else { + children.push(value); + } + }); + $("#categories_sidebar ul").append(first_level); + + // Second level list - children. + $.each(parents, function(index, id_parent) { + $.each(children, function(i, v) { + if (id_parent == v.parent && v.count != 0) { + second_level += "
  • "; //'
  • '; + second_level += + ''; + second_level += v.name + " (" + v.count + ")"; + second_level += ""; + second_level += "
  • "; + } + }); + $("#categories_sidebar span#parent-" + id_parent).append( + '
      ' + second_level + "
    " + ); + second_level = ""; + }); + } + } + } + // Call first time. + set_local_categories(); + + // Get all categories from Module library. + function get_all_categories() { + $.ajax({ + url: + "https://pandorafms.com/library/wp-json/wp/v2/categories?per_page=100", + type: "GET", + crossDomain: true, + contentType: "application/json", + success: function(data) { + sessionStorage.setItem("categories", btoa(JSON.stringify(data))); + set_local_categories(); + }, + error: function(error) { + if ($("#categories_library").length) { + show_error_msg("#categories_library", error_categories); + } + } + }); + } + + // Posts returned from the search / Get all posts from a category. + function get_modules(search_modules, page, selector) { + // Pagination. + if (!page) { + page = 1; + } + + var api_url = ""; + if (selector == "search") { + api_url = "https://pandorafms.com/library/wp-json/wp/v2/posts?search="; + } else if (selector == "category") { + api_url = + "https://pandorafms.com/library/wp-json/wp/v2/posts/?categories="; + } + + $.ajax({ + url: + api_url + search_modules + "&orderby=modified&per_page=9&page=" + page, + type: "GET", + crossDomain: true, + contentType: "application/json", + beforeSend: function(xhr) { + if (token !== null) { + xhr.setRequestHeader("Authorization", "Bearer " + token); + } + $("#" + selector + "_result").addClass("loading_posts"); + }, + success: function(response, textStatus, jqXHR) { + var total_pages = parseInt( + jqXHR.getResponseHeader("X-WP-TotalPages"), + 10 + ); + var total_posts = parseInt(jqXHR.getResponseHeader("X-WP-Total"), 10); + + if (selector == "search") { + $("#search_title_result h2").append( + "" + search_modules + "" + ); + } + + if (total_posts < 1) { + $("#" + selector + "_result").css("grid-template-columns", "unset"); + $("#" + selector + "_result").append( + '
    ' + empty_result + "
    " + ); + } else { + var link = ""; + if (selector == "search") { + link = + "index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=search_module&search=" + + search_modules; + } else if (selector == "category") { + link = + "index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories&id_cat=" + + search_modules; + } + + print_excerpt(selector + "_result", response); + pagination_library(link, total_pages, total_posts, page); + } + }, + error: function(error) { + if (selector == "search") { + show_error_msg("#search_result", error_search); + } + //show_error_msg("#category_result", error_category); + }, + complete: function(data) { + $("#" + selector + "_result").removeClass("loading_posts"); + } + }); + } + + // Show results. + if ($("#category_result").length || $("#search_result").length) { + var result = ""; + if ($("#category_result").length) { + result = "category_result"; + var id_cat = $("#" + result).attr("class"); + id_cat = id_cat.replace("result_category-", ""); + } else if ($("#search_result").length) { + result = "search_result"; + var search_string = $("#" + result).attr("class"); + search_string = search_string.replace("result_string-", ""); + } + + if ($("#pagination_library").length) { + var page = $("#pagination_library").attr("class"); + page = page.replace("page-", ""); + } + + if (id_cat != "" && result == "category_result") { + get_modules(id_cat, page, "category"); + if (result == "category_result") { + get_category(id_cat); + } + } else if (search_string != "" && result == "search_result") { + get_modules(search_string, page, "search"); + } + } else if ($("#library_main").length) { + library_main(); + } + + // Sidebar search. + $("#search_module").keypress(function(event) { + var keycode = event.keyCode ? event.keyCode : event.which; + if (keycode == "13") { + var browse = $("#search_module").val(); + window.location = + "index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=search_module&search=" + + browse; + } + event.stopPropagation(); + }); +}); // document ready ends + +/* Print main page */ +function library_main() { + $.ajax({ + url: "https://pandorafms.com/library/wp-json/wp/v2/pages/121", + type: "GET", + crossDomain: true, + contentType: "application/json", + beforeSend: function(xhr) { + $("#library_main").addClass("loading_posts"); + }, + complete: function(data) { + $("#library_main").removeClass("loading_posts"); + } + }) + .done(function(data) { + var array_cat = [ + "", + "Miscelaneus", + "Application monitoring", + "Network Monitoring", + "Operating Systems", + "Artwork", + "Security monitoring", + "Tools", + "Inventory", + "System Integrations" + ]; + + var array_cat_ids = ["", 4, 5, 7, 6, 9, 8, 11, 12, 13]; + + var main_page = data.content.rendered; + + // Remove code from Divi Theme. + main_page = main_page.replace(/

    \[.*?\]<\/p>/g, ""); + + var clean_page = main_page.split("\n"); + clean_page = clean_page.filter(function(element) { + return element != ""; + }); + + // Title. + $("#library_main>span").append(clean_page[0]); + // Description. + $("#library_main>span+p").append(clean_page[1]); + + // Remove unused items. + // Remove only 1 index because we need the index 1 to exist for the loop. The 0 index in the loop will be ignored. + clean_page.splice(0, 1); + + $.each(clean_page, function(i, v) { + var main_category = $( + "#library_main_content div.library_main_category:nth-child(" + i + ")" + ); + + if (main_category.length > 0) { + main_category.append( + "

    " + + array_cat[i] + + "

    " + + v + + "" + ); + } + }); + }) + .fail(function(jqXHR, textStatus, errorThrown) { + $("#library_main_content").empty(); + show_error_msg("#library_main_content", error_main); + }); +} + +// Get all data from one category. This is necessary to get the category name. +function get_category(id) { + $.ajax({ + url: "https://pandorafms.com/library/wp-json/wp/v2/categories/" + id, + type: "GET", + contentType: "application/json", + success: function(response) { + $("#category_title_result h2").append( + '' + response.name + "" + ); + }, + error: function(error) { + if (error.readyState == 4) { + if (error.status == "404") { + show_error_msg("#category_result", error_no_category); + } + } else { + show_error_msg("#category_result", error_category); + } + } + }); +} + +// Print a summary text of the returned posts (by a category or a search). +function print_excerpt(id_div, response) { + var return_posts = ""; + + $.each(response, function(i, elem) { + var excerpt = elem.excerpt.rendered; + + if (excerpt.length > 250) { + excerpt = excerpt.substr(0, 230) + "[…]

    "; + } + + return_posts += "
    "; + return_posts += + "

    " + + elem.title.rendered + + "

    " + + excerpt + + "
    "; + return_posts += + '"; + + return_posts += "
    "; + }); + // Append to modal window. + $("#" + id_div).append(return_posts); + + var modal_details = $("#modal_library").dialog({ + resizable: false, + autoOpen: false, + draggable: true, + modal: true, + maxHeight: 600, + width: 700, + overlay: { + opacity: 0.5, + background: "black" + }, + open: function() { + $(".ui-dialog-content").scrollTop(0); + }, + buttons: { + Close: function() { + modal_details.dialog("close"); + } + } + }); + + $.each(response, function(i, elem) { + $("#card_link-" + elem.id).on("click", function() { + var id = $(this).attr("id"); + id = id.replace("card_link-", ""); + + var updated = ""; + var modification_date = new Date(elem.modified).setHours(0, 0, 0, 0); + var creation_date = new Date(elem.date).setHours(0, 0, 0, 0); + if (modification_date > creation_date) { + updated = + "

    Update in: " + + format_date(elem.modified) + + "

    "; + } + + if (elem.id == id) { + $("#modal_library").html( + '

    ' + + format_date(elem.date) + + " | " + + category_names(elem.categories) + + "

    " + + updated + + elem.content.rendered + + '" + ); + } + var title = elem.title.rendered.replace(/<.*?>/g, ""); + modal_details.dialog("option", "title", title).dialog("open"); + }); + }); +} + +// Function to format date from posts. (To show in modal window). +function format_date(date_string) { + const months = [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" + ]; + + var date = new Date(date_string); + let formatted_date = + months[date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear(); + + return formatted_date; +} + +// Function to get the names of the categories. (To show in modal window). +function category_names(categories) { + var local_categories_exist = sessionStorage.getItem("categories"); + if (local_categories_exist !== null) { + var local_categories = JSON.parse(atob(local_categories_exist)); + var category_names = ""; + $.each(categories, function(index, value) { + $.each(local_categories, function(i, v) { + if (value == v.id) { + category_names += + "" + + v.name + + "" + + ", "; + } + }); + }); + category_names = category_names.replace(/,\s*$/, ""); + return category_names; + } +} + +// Function to print the pagination. +//?per_page=5&page=4 is equivalent to ?per_page=5&offset=15 +function pagination_library(link, total_pages, total_posts, page) { + $("#pagination_library").append( + '
    ' + + total_modules_text + + ": " + + total_posts + + "
    " + ); + + // If only one page, don't show pagination. + if (total_pages <= 1) { + return; + } + + var links_pagination = ""; + for (var i = 1; i <= total_pages; i++) { + if (i == page) { + links_pagination += + '' + + i + + ""; + } else { + links_pagination += '' + i + ""; + } + } + $("#pagination_library").append( + '
    ' + links_pagination + "
    " + ); +} + +// Show error messsage. +function show_error_msg(selector, message_error) { + $("#search_result, #category_result").css("grid-template-columns", "unset"); + if (selector == "#categories_library") { + $(selector).append("
    " + message_error + "
    "); + } else { + $(selector).append("
    " + message_error + "
    "); + } +} diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index 983b1d9b05..e343d44d4f 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -210,6 +210,9 @@ li.sub_subMenu.selected { #icon_god-um_messages { background-image: url(../../images/um_messages.menu_gray.png); } +#icon_god-module_library { + background-image: url(../../images/gm_library.menu_gray.png); +} #menu_container { z-index: 3; @@ -371,6 +374,9 @@ ul li { .selected#icon_god-um_messages { background-image: url(../../images/um_messages.menu_white.png); } +.selected#icon_god-module_library { + background-image: url(../../images/gm_library.menu_white.png); +} #menu_full { height: 100%; diff --git a/pandora_console/include/styles/module_library.css b/pandora_console/include/styles/module_library.css new file mode 100644 index 0000000000..9081464a67 --- /dev/null +++ b/pandora_console/include/styles/module_library.css @@ -0,0 +1,265 @@ +* { + font-size: 12px; +} + +#module_library_main { + display: grid; + grid-template-columns: 1fr minmax(min-content, max-content); + justify-content: space-between; +} + +.no-enterprise { + background-color: #f7f7f7; + padding: 20px 20px; + padding-right: 50px; + margin-bottom: 20px; + margin-top: 20px; + border: 1px solid #d0d0d0; + border-radius: 2px; + text-shadow: none; + color: #ff5f5f; +} + +.card { + border: 1px solid #e2e2e2; + background-color: #fff; + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 0; + border-radius: 4px; + text-align: center; + font-size: 16px; +} + +.card_excerpt { + padding: 0px 20px; +} + +.card_excerpt p { + word-break: break-word; +} + +.card_link { + border-top: 1px solid #e2e2e2; +} + +.card_link_button { + cursor: pointer; + padding: 10px 20px; +} + +.card_link_button:hover { + cursor: pointer; + padding: 10px 20px; + background-color: #eaeaea; +} + +.loading_posts { + background: url("../../images/wait.gif") no-repeat center center; + height: 200px; +} + +#show_errors_library { + margin-bottom: 20px; +} + +/* --- Main page --- */ +#library_main { + text-align: center; +} + +#library_main h2 { + margin-top: 0; +} + +#library_main_content { + display: grid; + grid-template-columns: repeat(3, minmax(300px, 1fr)); + grid-gap: 20px; + gap: 20px; + text-align: center; + margin-bottom: 15px; +} + +#library_main_content div.library_main_category { + padding: 20px; +} + +#library_main_content div.library_main_category h4 { + margin-top: 5px; +} + +#library_main_content div.library_main_category p { + margin-bottom: 0; +} + +#library_main_content div.library_main_category:hover a { + text-decoration: none; +} + +#library_main_content div.library_main_category:hover { + border: 1px solid #e2e2e2; + background-color: #fff; + border-radius: 4px; + padding: 19px; + cursor: pointer; +} + +/* --- Sidebar --- */ +.sidebar_library { + min-width: 360px; + margin-left: 50px; + border-left: 1px solid #d0d0d0; + padding: 0px 0px 0px 30px; +} + +@media screen and (max-height: 1080px) { + #categories_sidebar > ul { + max-height: 620px; + overflow-y: scroll; + } +} + +.sidebar_library h3:first-child { + margin-top: 0; +} + +.categories_sidebar_children { + padding-left: 10px; +} + +/* --- Search results --- */ +#category_title_result, +#search_title_result { + text-align: center; +} + +#category_title_result h2, +#search_title_result h2 { + margin-top: 0; +} + +#category_title_result span, +#search_title_result span { + font-size: 15px; +} + +#category_result, +#search_result { + display: grid; + grid-template-columns: repeat(3, minmax(300px, 1fr)); + grid-gap: 20px; +} + +#empty_result { + padding: 10px; + border: 1px solid #f85858; + border: 1px solid #e2e2e2; + border-radius: 4px; + text-align: center; + color: #f85858; + background-color: #fff; + text-transform: uppercase; + font-weight: bold; +} + +/* --- Categories page --- */ +#categories_library { + display: grid; + grid-template-columns: repeat(6, minmax(150px, 1fr)); + grid-template-rows: repeat(8, 1fr); + grid-auto-rows: 1fr; + grid-gap: 20px; + width: 100%; +} + +.card_category { + justify-content: center; + align-items: center; + padding: 5px 10px; +} + +#categories_library .card_category a { + font-weight: bold; + font-size: 11pt; +} + +#categories_library .card_category a:hover { + color: #82b92e; + text-decoration: none; +} + +/* --- Pagination --- */ +#pagination_library { + margin-top: 20px; + display: flex; + justify-content: space-between; +} + +#pagination_library .pagination_pages { + text-align: center; +} + +#pagination_library .pagination_pages a { + border: 1px solid#cacaca; + border-right: 0; + padding: 5px; + min-width: 22px; + display: inline-block; +} + +#pagination_library .pagination_pages a:last-child { + border-right: 1px solid#cacaca; +} + +#pagination_library .pagination_pages a:hover { + background-color: #e2e2e2; +} + +#pagination_library .pagination_pages a.active_number { + background-color: #82b92e; + color: #fff; +} + +/* Modal */ +#modal_library { + padding-left: 30px; + padding-right: 30px; +} + +#modal_library h2 { + color: #82b92e !important; +} + +#modal_library ul { + list-style-type: disc; + padding-left: 30px; +} + +#modal_library a { + color: #82b92e; +} + +#modal_library pre { + border: 1px solid #e2e2e2; + background: #f5f5f5; + word-wrap: break-word; + white-space: pre-wrap; + padding: 20px 20px; + color: #383838; + margin-bottom: 10px; + font-family: Courier New, monospace; +} + +#modal_library div.view_web { + text-align: center; +} + +#modal_library .date { + color: #8c8c8c; +} + +#modal_library .bold { + font-weight: bold; +} From 82fe47cfd92b631b17c9acb5684b17bf071e4591 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 27 Feb 2020 16:31:09 +0100 Subject: [PATCH 15/45] Ent 5312 snmp browser enchancements --- .../godmode/agentes/module_manager_editor.php | 19 + .../agentes/module_manager_editor_network.php | 4 +- .../include/ajax/snmp_browser.ajax.php | 261 ++++-- .../include/functions_snmp_browser.php | 751 ++++++++++++++---- .../javascript/pandora_snmp_browser.js | 182 ++++- pandora_console/include/styles/pandora.css | 28 + .../operation/snmpconsole/snmp_browser.php | 696 ++++++++++++---- 7 files changed, 1556 insertions(+), 385 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 9428a362bc..1d41d1ccba 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -494,6 +494,25 @@ if ($id_agent_module) { $module_macros = []; } + + $create_network_from_snmp_browser = get_parameter('create_network_from_snmp_browser', 0); + + if ($create_network_from_snmp_browser) { + $moduletype = get_parameter('id_component_type', 2); + $id_module_type = get_parameter('type', 1); + $name = get_parameter('name', ''); + $description = get_parameter('description'); + $ip_target = get_parameter('target_ip'); + $snmp_community = get_parameter('community'); + $snmp_version = get_parameter('snmp_version'); + $snmp3_auth_user = get_parameter('snmp3_auth_user'); + $snmp3_auth_pass = get_parameter('snmp3_auth_pass'); + $snmp3_auth_method = get_parameter('snmp3_auth_method'); + $snmp3_privacy_method = get_parameter('snmp3_privacy_method'); + $snmp3_privacy_pass = get_parameter('snmp3_privacy_pass'); + $snmp3_security_level = get_parameter('snmp3_security_level'); + $snmp_oid = get_parameter('snmp_oid'); + } } $is_function_policies = enterprise_include_once( diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 0ce82eddd9..f179da95fe 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -183,7 +183,7 @@ if ($id_module_type >= 15 && $id_module_type <= 18) { $data[3] = html_print_select( $snmp_versions, 'snmp_version', - $tcp_send, + $snmp_version, '', '', '', @@ -496,7 +496,7 @@ if ($id_module_type !== 34 $table_simple->rowstyle['row-cmd-row-2'] = 'display: none;'; } -snmp_browser_print_container(false, '100%', '60%', 'none'); +snmp_browser_print_container(false, '100%', '60%', 'display:none'); ?> + } + + if (is_array($ids)) { + foreach ($ids as $id) { + // Id < 0 for error codes. + if (!$id || $id < 0) { + array_push($fail_modules, $oid['oid']); + } + } + } else { + if (empty($id)) { + array_push($fail_modules, $oid['oid']); + } + } + } + + return $fail_modules; +} + + +/** + * Prints html for create module from snmp massive dialog + * + * @param string $url_form + * @param string $title + * @param boolean $return + * @return void + */ +function snmp_browser_print_create_module_massive($target='agent', $snmp_conf, $return=false) +{ + // String for labels. + switch ($target) { + case 'agent': + $target_item = 'Agents'; + break; + + case 'policy': + $target_item = 'Policies'; + break; + } + + $output .= "
    "; + + $strict_user = db_get_value( + 'strict_acl', + 'tusuario', + 'id_user', + $config['id_user'] + ); + + $keys_field = 'id_grupo'; + + $table = new stdClass(); + $table->width = '100%'; + $table->data = []; + + $table->data[0][0] = __('Filter group').""; + + $table->data[0][1] = html_print_select_groups( + false, + 'RR', + users_can_manage_group_all('RR'), + 'group', + '', + '', + '', + 0, + true, + false, + false, + '', + false, + false, + false, + false, + $keys_field, + $strict_user + ); + + $table->data[1][0] = __('Search').""; + $table->data[1][1] = html_print_input_text( + 'filter', + '', + '', + 20, + 150, + true + ); + + $table->data[2][0] = __($target_item.' available').html_print_input_image('select_all_left', 'images/tick.png', 1, '', true, ['title' => __('Select all')]); + $table->data[2][1] = ''; + $table->data[2][2] = __($target_item.' to apply').html_print_input_image('select_all_right', 'images/tick.png', 1, '', true, ['title' => __('Select all')]); + + $table->data[3][0] = html_print_select( + [], + 'id_item[]', + 0, + false, + '', + '', + true, + true, + true, + '', + false, + 'width: 100%;', + [] + ); + + if ($target == 'policy') { + if (enterprise_installed()) { + $table->data[4][0] = html_print_button( + __('Create new policy'), + 'snmp_browser_create_policy', + false, + '', + 'class="sub add" style="margin-left:0px"', + true + ); + } + + $table->data[4][1] = html_print_div( + [ + 'style' => 'display:none', + 'id' => 'policy_modal', + ], + true + ); + } + + $table->cellstyle[3][1] = 'text-align: center'; + $table->data[3][1] = html_print_image( + 'images/darrowright.png', + true, + [ + 'id' => 'right', + 'title' => __('Add'), + ] + ).'



    '.html_print_image( + 'images/darrowleft.png', + true, + [ + 'id' => 'left', + 'title' => __('Undo'), + ] + ); + $table->data[3][2] = html_print_select( + [], + 'id_item2[]', + 0, + false, + '', + '', + true, + true, + true, + '', + false, + 'width: 100%;', + [] + ); + + $output .= html_print_table($table, true); + + // SNMP extradata. + $output .= html_print_input_hidden('snmp_extradata', $snmp_conf, true); + + $output .= '
    '; + + $output .= '
    '; + + $script = 'add_module_massive_controller("'.$target.'")'; + + // Add script to output. + $output .= ''; + + if ($return) { + return $output; + } else { + echo $output; + } + +} + + +/** + * Prints form from create snmp module dialog + * + * @param boolean $return + * @return void + */ +function snmp_browser_print_create_modules($return=false) +{ + $output = "'; + + if ($return) { + return $output; + } + + echo $output; + +} + + +function snmp_browser_print_create_policy() +{ + $table = new stdClass(); + + $table->width = '100%'; + $table->class = 'databox filters'; + $table->style = []; + $table->style[0] = 'font-weight: bold; vertical-align: top'; + $table->data = []; + + $table->data[0][0] = __('Name'); + $table->data[0][1] = html_print_input_text('name', $name, '', '60%', 150, true); + + $table->data[1][0] = __('Group'); + $table->data[1][1] = html_print_select_groups( + false, + 'AW', + false, + 'id_group', + $id_group, + '', + '', + '', + true + ); + $table->data[1][1] .= ' '; + $table->data[1][1] .= ui_print_group_icon($id_group, true, 'groups_small', '', false); + $table->data[1][1] .= ''; + + $table->data[2][0] = __('Description'); + $table->data[2][1] = html_print_textarea('description', 3, 30, $description, '', true); + + $output = '
    '; + $output .= html_print_table($table, true); + $output .= '
    '; + + return $output; + +} diff --git a/pandora_console/include/javascript/pandora_snmp_browser.js b/pandora_console/include/javascript/pandora_snmp_browser.js index dbe8121a64..ef746aa5f4 100644 --- a/pandora_console/include/javascript/pandora_snmp_browser.js +++ b/pandora_console/include/javascript/pandora_snmp_browser.js @@ -42,7 +42,7 @@ function snmpBrowse() { params["snmp3_browser_privacy_method"] = snmp3_privacy_method; params["snmp3_browser_privacy_pass"] = snmp3_privacy_pass; params["action"] = "snmptree"; - params["page"] = "operation/snmpconsole/snmp_browser"; + params["page"] = "include/ajax/snmp_browser.ajax"; // Browse! jQuery.ajax({ @@ -57,6 +57,63 @@ function snmpBrowse() { // Load the SNMP tree $("#snmp_browser").html(data); + + // Manage click and select events. + snmp_browser_events_manage(); + } + }); +} + +function snmp_browser_events_manage() { + // Hide create buttons. + $("#snmp_create_buttons").hide(); + + $("input[id^=checkbox-create]").change(function() { + if ($(this).is(":checked")) { + $("#snmp_create_buttons").show(); + var id_input = $(this).attr("id"); + id_input = id_input.match("checkbox-create_([0-9]+)"); + var checks = $("#ul_" + id_input[1]) + .find("input") + .map(function() { + if (this.id.indexOf("checkbox-create_") != -1) { + return this.id; + } + }) + .get(); + + checks.forEach(function(product, index) { + $("#" + product).prop("checked", "true"); + }); + } else { + var id_input = $(this).attr("id"); + + id_input = id_input.match("checkbox-create_([0-9]+)"); + var checks = $("#ul_" + id_input[1]) + .find("input") + .map(function() { + if (this.id.indexOf("checkbox-create_") != -1) { + return this.id; + } + }) + .get(); + + checks.forEach(function(product, index) { + $("#" + product).prop("checked", false); + }); + } + + // Hide buttons if no ckbox is checked. + var checked = false; + $("input[id^=checkbox-create]").each(function() { + checked = $(this).is(":checked"); + if (checked == true) { + return false; + } + }); + + if (checked == false) { + $("#snmp_create_buttons").hide(); } }); } @@ -187,7 +244,7 @@ function snmpGet(oid) { "server_to_exec=" + server_to_exec, "action=" + "snmpget", "custom_action=" + custom_action, - "page=operation/snmpconsole/snmp_browser" + "page=include/ajax/snmp_browser.ajax" ]; // SNMP get! @@ -224,7 +281,7 @@ function hideOIDData() { // Search the SNMP tree for a matching string function searchText() { var text = $("#text-search_text").val(); - var regexp = new RegExp(text); + var regexp = new RegExp(text, "i"); var search_matches_translation = $( "#hidden-search_matches_translation" ).val(); @@ -348,6 +405,7 @@ function searchNextMatch() { var id = $(".match:eq(" + search_index + ")").attr("id"); // Scroll + var body = $("html, body"); $("#snmp_browser").animate( { scrollTop: @@ -355,7 +413,16 @@ function searchNextMatch() { $("#" + id).offset().top - $("#snmp_browser").offset().top }, - 1000 + 1000, + function() { + // Blink. + $("#" + id) + .fadeOut(100) + .fadeIn(100) + .fadeOut(100) + .fadeIn(100) + .focus(); + } ); // Save the search index @@ -384,7 +451,16 @@ function searchPrevMatch() { $("#" + id).offset().top - $("#snmp_browser").offset().top }, - 1000 + 1000, + function() { + // Blink. + $("#" + id) + .fadeOut(100) + .fadeIn(100) + .fadeOut(100) + .fadeIn(100) + .focus(); + } ); // Save the search index @@ -464,3 +540,99 @@ function setOID() { // Close the SNMP browser $(".ui-dialog-titlebar-close").trigger("click"); } + +/** + * Create module on selected module_target (agent, networlk component or policy). + * + * @param string module_target Target to create module. + * @param return_values Return snmp values. + */ +function snmp_browser_create_modules(module_target, return_post = true) { + var id_check = $("#ul_0") + .find("input") + .map(function() { + if (this.id.indexOf("checkbox-create_") != -1) { + if ($(this).is(":checked")) { + return this.id; + } + } + }) + .get(); + + var target_ip = $("#text-target_ip").val(); + var community = $("#text-community").val(); + var snmp_version = $("#snmp_browser_version").val(); + var snmp3_auth_user = $("#text-snmp3_browser_auth_user").val(); + var snmp3_security_level = $("#snmp3_browser_security_level").val(); + var snmp3_auth_method = $("#snmp3_browser_auth_method").val(); + var snmp3_auth_pass = $("#password-snmp3_browser_auth_pass").val(); + var snmp3_privacy_method = $("#snmp3_browser_privacy_method").val(); + var snmp3_privacy_pass = $("#password-snmp3_browser_privacy_pass").val(); + + var custom_action = $("#hidden-custom_action").val(); + if (custom_action == undefined) { + custom_action = ""; + } + + var oids = []; + id_check.forEach(function(product, index) { + var oid = $("#" + product) + .siblings("a") + .attr("href"); + if (oid.indexOf('javascript: snmpGet("') != -1) { + oid = oid.replace('javascript: snmpGet("', ""); + oid = oid.replace('");', ""); + oids.push(oid); + } + }); + + var snmp_conf = {}; + + snmp_conf["target_ip"] = target_ip; + snmp_conf["community"] = community; + snmp_conf["oids"] = oids; + snmp_conf["snmp_browser_version"] = snmp_version; + snmp_conf["snmp3_browser_auth_user"] = snmp3_auth_user; + snmp_conf["snmp3_browser_security_level"] = snmp3_security_level; + snmp_conf["snmp3_browser_auth_method"] = snmp3_auth_method; + snmp_conf["snmp3_browser_auth_pass"] = snmp3_auth_pass; + snmp_conf["snmp3_browser_privacy_method"] = snmp3_privacy_method; + snmp_conf["snmp3_browser_privacy_pass"] = snmp3_privacy_pass; + snmp_conf["module_target"] = module_target; + snmp_conf["custom_action"] = custom_action; + + var snmp_data = []; + + for (var snmp_data_name in snmp_conf) { + snmp_data.push({ + name: snmp_data_name, + value: snmp_conf[snmp_data_name] + }); + } + + if (return_post) { + return snmp_data; + } else { + var params = {}; + + params["method"] = "snmp_browser_create_modules"; + params["module_target"] = module_target; + params["page"] = "include/ajax/snmp_browser.ajax"; + params["snmp_extradata"] = snmp_data; + + $("input[name=create_modules_" + module_target + "]").removeClass( + "sub add" + ); + $("input[name=create_modules_" + module_target + "]").addClass("sub spinn"); + + $.ajax({ + method: "post", + url: "ajax.php", + data: params, + dataType: "html", + success: function(data) { + snmp_show_result_message(data); + } + }); + } +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 4c48f12e80..8d4330003a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -730,6 +730,7 @@ input.sub { padding-bottom: 10px; padding-top: 10px; padding-left: 15px; + margin-left: 10px; border: 1px solid #888; font-family: "lato", "Open Sans", sans-serif; cursor: pointer; @@ -4300,6 +4301,33 @@ form ul.form_flex li ul li { border: 0px; } +#snmp_browser { + text-align: left; + font-family: "lato-lighter", "Open Sans", sans-serif; + letter-spacing: 0.03pt; + font-size: 8pt; + box-sizing: border-box; + height: 100%; + min-height: 100px; + max-height: 500px; + overflow: auto; + background-color: #f4f5f4; + border: 1px solid #e2e2e2; + border-radius: 4px; + padding: 5px; +} +#snmp_create_buttons { + display: flex; + justify-content: flex-end; + flex-wrap: nowrap; +} + +#snmp_create_buttons > .sub { + display: flex; + margin-left: 10px; + margin-top: 10px; +} + /* library for graphs */ .yAxis.y1Axis > .tickLabel { white-space: nowrap; diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index b68f2d4da5..8db508da27 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -30,140 +30,14 @@ global $config; require_once $config['homedir'].'/include/functions_snmp_browser.php'; ui_require_javascript_file('pandora_snmp_browser'); - -// AJAX call. -if (is_ajax()) { - // Read the action to perform. - $action = (string) get_parameter('action', ''); - $target_ip = (string) get_parameter('target_ip', ''); - $community = (string) get_parameter('community', ''); - $snmp_version = (string) get_parameter('snmp_browser_version', ''); - $server_to_exec = (int) get_parameter('server_to_exec', 0); - $snmp3_auth_user = io_safe_output(get_parameter('snmp3_browser_auth_user')); - $snmp3_security_level = get_parameter('snmp3_browser_security_level'); - $snmp3_auth_method = get_parameter('snmp3_browser_auth_method'); - $snmp3_auth_pass = io_safe_output(get_parameter('snmp3_browser_auth_pass')); - $snmp3_privacy_method = get_parameter('snmp3_browser_privacy_method'); - $snmp3_privacy_pass = io_safe_output( - get_parameter('snmp3_browser_privacy_pass') - ); - - // SNMP browser. - if ($action == 'snmptree') { - $starting_oid = (string) get_parameter('starting_oid', '.'); - - $snmp_tree = snmp_browser_get_tree( - $target_ip, - $community, - $starting_oid, - $snmp_version, - $snmp3_auth_user, - $snmp3_security_level, - $snmp3_auth_method, - $snmp3_auth_pass, - $snmp3_privacy_method, - $snmp3_privacy_pass, - $server_to_exec - ); - if (! is_array($snmp_tree)) { - echo $snmp_tree; - } else { - snmp_browser_print_tree( - $snmp_tree, - // Id. - 0, - // Depth. - 0, - // Last. - 0, - // Last_array. - [], - // Sufix. - false, - // Checked. - [], - // Return. - false, - // Descriptive_ids. - false, - // Previous_id. - '' - ); - echo html_print_submit_button( - __('Create network components'), - 'create_network_component', - false, - [ - 'style' => 'display: none; position: absolute; bottom: 0px; right: 35px;', - 'class' => 'sub add', - ], - true - ); - - echo '