From d769917dfc025fbc003eb5d2027a2ac19cca227d Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Mon, 15 Apr 2024 14:19:46 +0200 Subject: [PATCH 01/48] 13389-Add references in reports headers --- pandora_console/include/functions_reporting_html.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 4869343a84..03c920f577 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -112,8 +112,8 @@ function reporting_html_header( } $data[] = $title.$sizhfin; - $data[] = $sizh.$subtitle.$sizhfin; - $data[] = "
".$sizh.$date_text.$sizhfin.'
'; + $data[] = $sizh.__('Group').': '.$subtitle.$sizhfin; + $data[] = '
'.$sizh.__('Data time').': '.$sizhfin."
".$sizh.$date_text.$sizhfin.'
'; } array_push($table->data, $data); @@ -194,6 +194,9 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust $table->head = []; $table->colspan = []; $table->rowstyle = ['background-color: #686868']; + $table->size[0] = '33%'; + $table->size[1] = '33%'; + $table->size[2] = '33%'; if (isset($item['label']) && $item['label'] != '') { $id_agent = $item['id_agent']; From e3c842b36cc761c95a4fd1217236973605ef0d1a Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 18 Apr 2024 12:41:17 +0200 Subject: [PATCH 02/48] #13453 Fixed dark theme styles in Netflow Widgets --- pandora_console/include/functions_netflow.php | 14 +++++++++++--- .../include/lib/Dashboard/Widgets/netflow.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index e4d76387bc..3a87ea8be7 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1389,6 +1389,7 @@ function netflow_draw_item( $show_summary=true, $show_table=true ) { + global $config; $aggregate = $filter['aggregate']; $interval = ($end_date - $start_date); if (is_metaconsole() === true) { @@ -1568,13 +1569,20 @@ function netflow_draw_item( $data_top_n ); + // Theme. + $theme = $config['style']; + $text_color = ($theme !== 'pandora_black') ? '#333' : '#fff'; + $graph_output = pie_graph( $pie_data, [ 'width' => 200, 'height' => 200, 'ttl' => ($output === 'PDF') ? 2 : 1, - 'dataLabel' => ['display' => 'auto'], + 'dataLabel' => [ + 'display' => 'auto', + 'color' => $text_color, + ], 'layout' => [ 'padding' => [ 'top' => 15, @@ -1650,8 +1658,8 @@ function netflow_draw_item( netflow_aggregate_is_ip($aggregate) ); - $data_circular['width'] = $width_content; - $data_circular['height'] = $height_content; + $data_circular['width'] = 390; + $data_circular['height'] = 390; $html = '
'; $html .= graph_netflow_circular_mesh($data_circular); diff --git a/pandora_console/include/lib/Dashboard/Widgets/netflow.php b/pandora_console/include/lib/Dashboard/Widgets/netflow.php index 6c0aa76eca..dccf1cffda 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/netflow.php +++ b/pandora_console/include/lib/Dashboard/Widgets/netflow.php @@ -462,7 +462,7 @@ class Netflow extends Widget public function getSizeModalConfiguration(): array { $size = [ - 'width' => 400, + 'width' => 600, 'height' => 530, ]; From d5d67f78f83d14d8583ff15d231697e3991002e3 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Thu, 18 Apr 2024 13:42:59 +0200 Subject: [PATCH 03/48] 13190-Fix SNMP console Severity & Max. hours old filter --- .../include/class/SnmpConsole.class.php | 80 ++++++------------- 1 file changed, 25 insertions(+), 55 deletions(-) diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php index d166f03590..f564b6599d 100644 --- a/pandora_console/include/class/SnmpConsole.class.php +++ b/pandora_console/include/class/SnmpConsole.class.php @@ -554,6 +554,10 @@ class SnmpConsole extends HTML $filters = get_parameter('filter', []); // Build ranges. + if (empty($filters['filter_hours_ago']) === true) { + $filters['filter_hours_ago'] = 8; + } + $now_timestamp = time(); $interval_seconds = ($filters['filter_hours_ago'] * 3600); $ago_timestamp = ($now_timestamp - $interval_seconds); @@ -637,42 +641,25 @@ class SnmpConsole extends HTML $whereSubquery .= ' AND alerted = '.$filters['filter_alert']; } + $filters['filter_severity'] = (int) $filters['filter_severity']; if ($filters['filter_severity'] != -1) { // There are two special severity values aimed to match two different trap standard severities // in database: warning/critical and critical/normal. - if ($filters['filter_severity'] != EVENT_CRIT_OR_NORMAL - && $filters['filter_severity'] != EVENT_CRIT_WARNING_OR_CRITICAL + if ($filters['filter_severity'] !== EVENT_CRIT_OR_NORMAL + && $filters['filter_severity'] !== EVENT_CRIT_WARNING_OR_CRITICAL + && $filters['filter_severity'] !== EVENT_CRIT_NOT_NORMAL ) { // Test if enterprise is installed to search oid in text or oid field in ttrap. - if ($config['enterprise_installed']) { - $whereSubquery .= ' AND ( - (alerted = 0 AND severity = '.$filters['filter_severity'].') OR - (alerted = 1 AND priority = '.$filters['filter_severity'].'))'; - } else { - $whereSubquery .= ' AND ( - (alerted = 0 AND 1 = '.$filters['filter_severity'].') OR - (alerted = 1 AND priority = '.$filters['filter_severity'].'))'; - } + $whereSubquery .= ' AND severity = '.$filters['filter_severity']; } else if ($filters['filter_severity'] === EVENT_CRIT_WARNING_OR_CRITICAL) { // Test if enterprise is installed to search oid in text or oid field in ttrap. - if ($config['enterprise_installed']) { - $whereSubquery .= ' AND ( - (alerted = 0 AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR - (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } else { - $whereSubquery .= ' AND ( - (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } + $whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_WARNING_OR_CRITICAL.')'; } else if ($filters['filter_severity'] === EVENT_CRIT_OR_NORMAL) { // Test if enterprise is installed to search oid in text or oid field in ttrap. - if ($config['enterprise_installed']) { - $whereSubquery .= ' AND ( - (alerted = 0 AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR - (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } else { - $whereSubquery .= ' AND ( - (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } + $whereSubquery .= ' AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_OR_NORMAL.')'; + } else if ($filters['filter_severity'] === EVENT_CRIT_NOT_NORMAL) { + // Test if enterprise is installed to search oid in text or oid field in ttrap. + $whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_NOT_NORMAL.')'; } } @@ -1142,42 +1129,25 @@ class SnmpConsole extends HTML $whereSubquery .= ' AND alerted = '.$$alert; } - if ($severity != -1) { + $severity = (int) $severity; + if ($severity !== -1) { // There are two special severity values aimed to match two different trap standard severities // in database: warning/critical and critical/normal. - if ($severity != EVENT_CRIT_OR_NORMAL - && $severity != EVENT_CRIT_WARNING_OR_CRITICAL + if ($severity !== EVENT_CRIT_OR_NORMAL + && $severity !== EVENT_CRIT_WARNING_OR_CRITICAL + && $severity !== EVENT_CRIT_NOT_NORMAL ) { // Test if enterprise is installed to search oid in text or oid field in ttrap. - if ($config['enterprise_installed']) { - $whereSubquery .= ' AND ( - (alerted = 0 AND severity = '.$severity.') OR - (alerted = 1 AND priority = '.$severity.'))'; - } else { - $whereSubquery .= ' AND ( - (alerted = 0 AND 1 = '.$severity.') OR - (alerted = 1 AND priority = '.$severity.'))'; - } + $whereSubquery .= ' AND severity = '.$severity; } else if ($severity === EVENT_CRIT_WARNING_OR_CRITICAL) { // Test if enterprise is installed to search oid in text or oid field in ttrap. - if ($config['enterprise_installed']) { - $whereSubquery .= ' AND ( - (alerted = 0 AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR - (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } else { - $whereSubquery .= ' AND ( - (alerted = 1 AND (priority = '.EVENT_CRIT_WARNING.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } + $whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_WARNING_OR_CRITICAL.')'; } else if ($severity === EVENT_CRIT_OR_NORMAL) { // Test if enterprise is installed to search oid in text or oid field in ttrap. - if ($config['enterprise_installed']) { - $whereSubquery .= ' AND ( - (alerted = 0 AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.')) OR - (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } else { - $whereSubquery .= ' AND ( - (alerted = 1 AND (priority = '.EVENT_CRIT_NORMAL.' OR priority = '.EVENT_CRIT_CRITICAL.')))'; - } + $whereSubquery .= ' AND (severity = '.EVENT_CRIT_NORMAL.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_OR_NORMAL.')'; + } else if ($severity === EVENT_CRIT_NOT_NORMAL) { + // Test if enterprise is installed to search oid in text or oid field in ttrap. + $whereSubquery .= ' AND (severity = '.EVENT_CRIT_WARNING.' OR severity = '.EVENT_CRIT_CRITICAL.' OR severity = '.EVENT_CRIT_NOT_NORMAL.')'; } } From 0e97e8dc2b8e7fe022ca34ddad06711f19e5d8ed Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 18 Apr 2024 20:12:01 +0200 Subject: [PATCH 04/48] Fix master detection for multiprocess mode. --- pandora_server/lib/PandoraFMS/Core.pm | 17 +++++++++++++++-- .../lib/PandoraFMS/DiscoveryServer.pm | 2 +- .../lib/PandoraFMS/InventoryServer.pm | 2 +- pandora_server/lib/PandoraFMS/NetworkServer.pm | 2 +- pandora_server/lib/PandoraFMS/PluginServer.pm | 2 +- .../lib/PandoraFMS/PredictionServer.pm | 2 +- pandora_server/lib/PandoraFMS/WMIServer.pm | 2 +- pandora_server/lib/PandoraFMS/WebServer.pm | 2 +- 8 files changed, 22 insertions(+), 9 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 1f78ab8079..7817a40167 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -7010,8 +7010,21 @@ Returns 1 if this server is the current master, 0 otherwise. =cut ########################################################################## -sub pandora_is_master ($) { - my ($pa_config) = @_; +sub pandora_is_master ($;$) { + my ($pa_config, $dbh) = @_; + + # When multiprocess is enabled the variable $Master is not shared between + # servers. + if (defined($dbh) && $pa_config->{'multiprocess'} == 1) { + my $current_master = get_db_value_limit ($dbh, 'SELECT name FROM tserver + WHERE master <> 0 AND status = 1 + ORDER BY master DESC', 1); + if (defined($current_master) && $current_master eq $pa_config->{'servername'}) { + return 1; + } + + return 0; + } if ($Master eq $pa_config->{'servername'}) { return 1; diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 3dc3d44f17..cc9b8fe963 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -143,7 +143,7 @@ sub data_producer ($) { # By default, after create a tasks it takes the utimestamp to 0 # Status -1 means "done". my @rows; - if (pandora_is_master($pa_config) == 0) { + if (pandora_is_master($pa_config, $dbh) == 0) { @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task WHERE id_recon_server = ? AND disabled = 0 diff --git a/pandora_server/lib/PandoraFMS/InventoryServer.pm b/pandora_server/lib/PandoraFMS/InventoryServer.pm index e6b070f4d8..daab7f624f 100644 --- a/pandora_server/lib/PandoraFMS/InventoryServer.pm +++ b/pandora_server/lib/PandoraFMS/InventoryServer.pm @@ -83,7 +83,7 @@ sub data_producer ($) { my @tasks; my @rows; - if (pandora_is_master($pa_config) == 0) { + if (pandora_is_master($pa_config, $dbh) == 0) { if ($pa_config->{'dbengine'} ne 'oracle') { @rows = get_db_rows ($dbh, 'SELECT tagent_module_inventory.id_agent_module_inventory, tagent_module_inventory.flag, tagent_module_inventory.timestamp diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index 87ef0fe2c7..6d0b848fb1 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -96,7 +96,7 @@ sub data_producer ($) { my @rows; my $network_filter = enterprise_hook ('get_network_filter', [$pa_config]); - if (pandora_is_master($pa_config) == 0) { + if (pandora_is_master($pa_config, $dbh) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index 9751372d04..a8cbd159b5 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -96,7 +96,7 @@ sub data_producer ($) { my @tasks; my @rows; - if (pandora_is_master($pa_config) == 0) { + if (pandora_is_master($pa_config, $dbh) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index 282a8eeb20..dfa70f38db 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -93,7 +93,7 @@ sub data_producer ($) { my @tasks; my @rows; - if (pandora_is_master($pa_config) == 0) { + if (pandora_is_master($pa_config, $dbh) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, last_execution_try FROM tagente, tagente_modulo, tagente_estado diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index 2b053c7ce0..2a01cf89dd 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -94,7 +94,7 @@ sub data_producer ($) { my @tasks; my @rows; - if (pandora_is_master($pa_config) == 0) { + if (pandora_is_master($pa_config, $dbh) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/lib/PandoraFMS/WebServer.pm b/pandora_server/lib/PandoraFMS/WebServer.pm index 7f66d8ad89..40b4af3073 100644 --- a/pandora_server/lib/PandoraFMS/WebServer.pm +++ b/pandora_server/lib/PandoraFMS/WebServer.pm @@ -124,7 +124,7 @@ sub data_producer ($) { my @tasks; my @rows; - if (pandora_is_master($pa_config) == 0) { + if (pandora_is_master($pa_config, $dbh) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? From d7c879862dc2c19fdf3757710549373948b33715 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Fri, 19 Apr 2024 09:49:32 +0200 Subject: [PATCH 05/48] 9940-Fix translation VC module deleted --- pandora_console/include/rest-api/models/VisualConsole/View.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/View.php b/pandora_console/include/rest-api/models/VisualConsole/View.php index e2e28f419a..8f912a5375 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/View.php +++ b/pandora_console/include/rest-api/models/VisualConsole/View.php @@ -139,7 +139,7 @@ class View extends \HTML }); ui.jqXHR.fail(function () { ui.panel.html( - "Couldn\'t load Data. Plz Reload Page or Try Again Later." + "'.__('The data could not be loaded. Please reload the page or try again later.').'" ); }); }, From e1841ba04cf24024701f9c2dbb1fc300f8f55247 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 22 Apr 2024 09:50:46 +0200 Subject: [PATCH 06/48] #13178 Fixed Discovery app download modal styling --- .../include/class/ExtensionsDiscovery.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/class/ExtensionsDiscovery.class.php b/pandora_console/include/class/ExtensionsDiscovery.class.php index 9c9affaf77..c38fc95b06 100644 --- a/pandora_console/include/class/ExtensionsDiscovery.class.php +++ b/pandora_console/include/class/ExtensionsDiscovery.class.php @@ -234,18 +234,18 @@ class ExtensionsDiscovery extends Wizard url_str = `'.__('here').'`; } - var markup = "