From 3ecf171fdbbe9e1473c431f1feb8c400f71f8ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Tue, 1 Aug 2023 18:14:11 -0600 Subject: [PATCH 01/62] Ignore disabled nodes --- pandora_server/util/pandora_ha.pl | 45 +++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/pandora_server/util/pandora_ha.pl b/pandora_server/util/pandora_ha.pl index 941b6dc854..be54f8d0ca 100755 --- a/pandora_server/util/pandora_ha.pl +++ b/pandora_server/util/pandora_ha.pl @@ -361,7 +361,7 @@ sub ha_load_databases($) { return unless defined($conf->{'ha_hosts'}); @HA_DB_Hosts = grep { !/^#/ } map { s/^\s+|\s+$//g; $_; } split(/,/, $conf->{'ha_hosts'}); - log_message($conf, 'DEBUG', "Loaded databases from disk (@HA_DB_Hosts)"); + log_message($conf, 'DEBUG', "Loaded databases from disk (@HA_DB_Hosts)"); } ############################################################################### @@ -388,9 +388,20 @@ sub ha_database_connect_pandora($) { # Load the list of HA databases. ha_load_databases($conf); - + # Select a new master database. my ($dbh, $utimestamp, $max_utimestamp) = (undef, undef, -1); + + my @disabled_nodes = get_disabled_nodes($conf); + + # If there are disabled nodes ignore them from the HA_DB_Hosts. + if(scalar @disabled_nodes ne 0){ + @HA_DB_Hosts = grep { my $item = $_; !grep { $_ eq $item } @disabled_nodes } @HA_DB_Hosts; + + my $data = join(",", @disabled_nodes); + log_message($conf, 'LOG', "Ignoring disabled hosts: " . $data); + } + foreach my $ha_dbhost (@HA_DB_Hosts) { # Retry each database ha_connect_retries times. @@ -481,6 +492,36 @@ sub ha_restart_pandora($) { `$config->{'pandora_service_cmd'} $control_command 2>/dev/null`; } +############################################################################### +# Get ip of the disabled nodes. +############################################################################### +sub get_disabled_nodes($) { + my ($conf) = @_; + + my $dbh = db_connect('mysql', + $conf->{'dbname'}, + $conf->{'dbhost'}, + $conf->{'dbport'}, + $conf->{'ha_dbuser'}, + $conf->{'ha_dbpass'}); + + my $disabled_nodes = get_db_value($dbh, "SELECT value FROM tconfig WHERE token = 'ha_disabled_nodes'"); + + if(!defined($disabled_nodes) || $disabled_nodes eq ""){ + $disabled_nodes = ','; + } + + my @disabled_nodes = split(',', $disabled_nodes); + + if(scalar @disabled_nodes ne 0){ + $disabled_nodes = join(",", @disabled_nodes); + @disabled_nodes = get_db_rows($dbh, "SELECT host FROM tdatabase WHERE id IN ($disabled_nodes)"); + @disabled_nodes = map { $_->{host} } @disabled_nodes; + } + + return @disabled_nodes; +} + ############################################################################### # Main (Pacemaker) ############################################################################### From 9c9467c2da9961f32606cabe098839eb437caa94 Mon Sep 17 00:00:00 2001 From: alejandro Date: Mon, 14 Aug 2023 13:57:14 +0200 Subject: [PATCH 02/62] fix in plugin output --- pandora_server/util/plugin/wizard_wmi_module.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/plugin/wizard_wmi_module.pl b/pandora_server/util/plugin/wizard_wmi_module.pl index 23e49a7f83..d9c1b3d1aa 100755 --- a/pandora_server/util/plugin/wizard_wmi_module.pl +++ b/pandora_server/util/plugin/wizard_wmi_module.pl @@ -172,5 +172,6 @@ foreach my $k (keys %{$fields_values}){ # Get operation result my $result = eval $operation; if (defined($result)){ - print $result . "\n"; + + print $result, "\n"; } From 682494f51fa15479cdefacbf6347838e3423fa19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20S=C3=A1nchez?= Date: Mon, 14 Aug 2023 11:59:41 +0000 Subject: [PATCH 03/62] remove clear line --- pandora_server/util/plugin/wizard_wmi_module.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_server/util/plugin/wizard_wmi_module.pl b/pandora_server/util/plugin/wizard_wmi_module.pl index d9c1b3d1aa..fa25c26d0b 100755 --- a/pandora_server/util/plugin/wizard_wmi_module.pl +++ b/pandora_server/util/plugin/wizard_wmi_module.pl @@ -172,6 +172,5 @@ foreach my $k (keys %{$fields_values}){ # Get operation result my $result = eval $operation; if (defined($result)){ - print $result, "\n"; } From 64d2d78137ef966d4f27d47c374a16e863bf6d1b Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 6 Sep 2023 13:59:12 +0200 Subject: [PATCH 04/62] #11014 fixed responsive user QR code --- pandora_console/include/styles/pandora.css | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d87d959ac5..a1821011d7 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12566,3 +12566,31 @@ tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { .ui-date-range-in > a { background-color: #81b92e3b !important; } + +@media screen and (min-width: 1190px) and (max-width: 1290px) { + #api_qrcode_display { + left: 580px; + } +} + +@media screen and (min-width: 1143px) and (max-width: 1189px) { + #api_qrcode_display { + left: 528px; + } +} + +@media screen and (min-width: 860px) and (max-width: 1142px) { + #api_qrcode_display { + left: 356px; + top: 120px; + } + + .font-title-font { + line-height: 0; + } + + #qr_code_agent_view > img { + width: 250px; + height: 250px; + } +} From d5c24609d61f7cc38f2b5a8b28db8580a918e4c6 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 30 Nov 2023 11:21:54 +0100 Subject: [PATCH 05/62] add tables merge process pandora_enterprise#12352 --- pandora_console/extras/mr/68.sql | 40 +++++++++++++++++++++++++++++ pandora_console/pandoradb.sql | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 pandora_console/extras/mr/68.sql diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..999d8e6c3c --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,40 @@ +START TRANSACTION; + +DROP TABLE IF EXISTS `tmerge_error`; +CREATE TABLE IF NOT EXISTS `tmerge_error` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `step` int(10) default 0, + `msg` LONGTEXT default "", + `action` text default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +DROP TABLE IF EXISTS `tmerge_steps`; +CREATE TABLE IF NOT EXISTS `tmerge_steps` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `total` int(10) default 0, + `step` int(10) default 0, + `debug` varchar(1024) default "", + `action` varchar(100) default "", + `affected` varchar(100) default "", + `query` mediumtext default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +DROP TABLE IF EXISTS `tmerge_queries`; +CREATE TABLE IF NOT EXISTS `tmerge_queries` ( + `steps` int(10) NOT NULL auto_increment, + `action` varchar(100) default "", + `affected` varchar(100) default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + `query` LONGTEXT NOT NULL default "", + PRIMARY KEY (`steps`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b98f706667..78a7833861 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4534,4 +4534,47 @@ CREATE TABLE IF NOT EXISTS `tpandora_cve` ( `cvss_score` DOUBLE DEFAULT NULL, `cvss_vector` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`cve_id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tmerge_error` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmerge_error` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `step` int(10) default 0, + `msg` LONGTEXT default "", + `action` text default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tmerge_steps` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmerge_steps` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `total` int(10) default 0, + `step` int(10) default 0, + `debug` varchar(1024) default "", + `action` varchar(100) default "", + `affected` varchar(100) default "", + `query` mediumtext default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tmerge_queries` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmerge_queries` ( + `steps` int(10) NOT NULL auto_increment, + `action` varchar(100) default "", + `affected` varchar(100) default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + `query` LONGTEXT NOT NULL default "", + PRIMARY KEY (`steps`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; \ No newline at end of file From 9da2ad8682b69f929e97dfdb27ce2017d79ff25c Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 1 Dec 2023 09:26:48 +0100 Subject: [PATCH 06/62] add tables merge process pandora_enterprise#12352 --- pandora_console/extras/mr/68.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index 999d8e6c3c..c0e5788091 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -1,6 +1,5 @@ START TRANSACTION; -DROP TABLE IF EXISTS `tmerge_error`; CREATE TABLE IF NOT EXISTS `tmerge_error` ( `id` int(10) NOT NULL auto_increment, `id_node` int(10) default 0, @@ -12,7 +11,8 @@ CREATE TABLE IF NOT EXISTS `tmerge_error` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -DROP TABLE IF EXISTS `tmerge_steps`; +ALTER TABLE `tmerge_error` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + CREATE TABLE IF NOT EXISTS `tmerge_steps` ( `id` int(10) NOT NULL auto_increment, `id_node` int(10) default 0, @@ -27,7 +27,8 @@ CREATE TABLE IF NOT EXISTS `tmerge_steps` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -DROP TABLE IF EXISTS `tmerge_queries`; +ALTER TABLE `tmerge_steps` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + CREATE TABLE IF NOT EXISTS `tmerge_queries` ( `steps` int(10) NOT NULL auto_increment, `action` varchar(100) default "", @@ -37,4 +38,6 @@ CREATE TABLE IF NOT EXISTS `tmerge_queries` ( PRIMARY KEY (`steps`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; +ALTER TABLE `tmerge_queries` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + COMMIT; From cc1c138552271abbcf2804f6bce13e46dc19df73 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 4 Dec 2023 11:23:43 +0100 Subject: [PATCH 07/62] #12518 Fixed up custom field type link --- pandora_console/operation/agentes/estado_generalagente.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index dd4effe693..6e6615df51 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -298,8 +298,9 @@ foreach ($fields as $field) { if ($custom_value[0]['is_password_type']) { $data[1] = '••••••••'; } else if ($field['is_link_enabled'] === '1') { - list($link_text, $link_url) = json_decode($custom_value[0]['description'], true); - + $custom_link_type = io_safe_output($custom_value[0]['description']); + $custom_link_type = json_decode($custom_link_type); + list($link_text, $link_url) = $custom_link_type; if (json_last_error() !== JSON_ERROR_NONE) { $link_text = ''; $link_url = ''; @@ -309,7 +310,7 @@ foreach ($fields as $field) { $link_text = $link_url; } - $data[1] = ''.$link_text.''; + $data[1] = ''.$link_text.''; } else { $custom_value[0]['description'] = ui_bbcode_to_html($custom_value[0]['description']); $data[1] = $custom_value[0]['description']; From 8a92b39eee596013fc4b95eedd425e5fe599999e Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 4 Dec 2023 11:59:31 +0100 Subject: [PATCH 08/62] add new filters widget modules status pandora_enterprise#12267 --- pandora_console/include/ajax/module.php | 33 +++ .../lib/Dashboard/Widgets/ModulesByStatus.php | 278 +++++++----------- 2 files changed, 145 insertions(+), 166 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index e4eba79858..c3e099f0cb 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1851,6 +1851,8 @@ if (check_login()) { $table_id = get_parameter('table_id', ''); $search = get_parameter('search', ''); + $search_agent = get_parameter('search_agent', ''); + $groupId = (int) get_parameter('groupId', 0); $module_name = get_parameter('module_name', ''); $status = get_parameter('status', ''); $start = get_parameter('start', 0); @@ -1862,13 +1864,36 @@ if (check_login()) { $nodes = get_parameter('nodes', 0); $disabled_modules = (bool) get_parameter('disabled_modules', false); + $groups_array = []; + if ($groupId === 0) { + if (users_can_manage_group_all('AR') === false) { + $groups_array = users_get_groups(false, 'AR', false); + } + } else { + $groups_array = [$groupId]; + } + $where = '1=1'; $recordsTotal = 0; + if (empty($groups_array) === false) { + $where .= sprintf( + ' AND (tagente.id_grupo IN (%s) + OR tagent_secondary_group.id_group IN(%s))', + implode(',', $groups_array), + implode(',', $groups_array) + ); + } + + if (empty($search) === false) { $where .= ' AND tagente_modulo.nombre LIKE "%%'.$search.'%%"'; } + if (empty($search_agent) === false) { + $where .= ' AND tagente.alias LIKE "%%'.$search_agent.'%%"'; + } + if (str_contains($status, '6') === true) { $expl = explode(',', $status); $exist = array_search('6', $expl); @@ -1943,6 +1968,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s ORDER BY %s LIMIT %d, %d', @@ -1960,6 +1987,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s', $where ); @@ -1987,6 +2016,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s', $where ); @@ -2019,6 +2050,8 @@ if (check_login()) { ON tagente_modulo.id_agente = tagente.id_agente INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + LEFT JOIN tagent_secondary_group + ON tagente.id_agente = tagent_secondary_group.id_agent WHERE %s', $where ); diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index e490135734..86a6cde7ed 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -200,6 +200,14 @@ class ModulesByStatus extends Widget // Retrieve global - common inputs. $values = parent::decoders($decoder); + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['search_agent']) === true) { + $values['search_agent'] = $decoder['search_agent']; + } + if (isset($decoder['search']) === true) { $values['search'] = $decoder['search']; } @@ -240,9 +248,39 @@ class ModulesByStatus extends Widget // Retrieve global - common inputs. $inputs = parent::getFormInputs(); + $return_all_group = false; + if (users_can_manage_group_all('RM') || $values['groupId'] == 0) { + $return_all_group = true; + } + + // Groups. + $inputs[] = [ + 'label' => __('Group'), + 'arguments' => [ + 'type' => 'select_groups', + 'name' => 'groupId', + 'returnAllGroup' => $return_all_group, + 'privilege' => 'AR', + 'selected' => $values['groupId'], + 'return' => true, + ], + ]; + + // Search Agent. + $inputs[] = [ + 'label' => __('Search agent').ui_print_help_tip(__('Search filter by Agent name field content'), true), + 'arguments' => [ + 'name' => 'search_agent', + 'type' => 'text', + 'value' => $values['search_agent'], + 'return' => true, + 'size' => 0, + ], + ]; + // Search. $inputs[] = [ - 'label' => __('Free search').ui_print_help_tip(__('Search filter by Module name field content'), true), + 'label' => __('Search module').ui_print_help_tip(__('Search filter by Module name field content'), true), 'arguments' => [ 'name' => 'search', 'type' => 'text', @@ -373,7 +411,9 @@ class ModulesByStatus extends Widget // Retrieve global - common inputs. $values = parent::getPost(); + $values['groupId'] = \get_parameter('groupId', 0); $values['search'] = \get_parameter('search', ''); + $values['search_agent'] = \get_parameter('search_agent', ''); $values['status'] = \get_parameter('status', ''); $values['limit'] = \get_parameter('limit', ''); $values['nodes'] = \get_parameter('nodes', ''); @@ -386,173 +426,73 @@ class ModulesByStatus extends Widget /** * Draw widget. * - * @return string; + * @return void Html output; */ public function load() { - $this->size = parent::getSize(); + // Datatables list. + try { + $info_columns = $this->columns(); + $column_names = $info_columns['column_names']; + $columns = $info_columns['columns']; + $hash = get_parameter('auth_hash', ''); + $id_user = get_parameter('id_user', ''); - global $config; - - $output = ''; - - if (is_metaconsole() === true) { - $modules = []; - - $servers_ids = array_column(metaconsole_get_servers(), 'id'); - - foreach ($servers_ids as $server_id) { - try { - $node = new Node((int) $server_id); - - $node->connect(); - $modules_tmp = $this->getInfoModules( - $this->values['search'], - $this->values['status'], - $this->values['nodes'] - ); - $modules[$node->id()] = $modules_tmp[0]; - $node->disconnect(); - } catch (\Exception $e) { - // Unexistent modules. - $node->disconnect(); - } - } - } else { - $modules = $this->getInfoModules( - $this->values['search'], - $this->values['status'] + $tableId = 'ModuleByStatus_'.$this->dashboardId.'_'.$this->cellId; + // Load datatables user interface. + ui_print_datatable( + [ + 'id' => $tableId, + 'class' => 'info_table align-left-important', + 'style' => 'width: 100%', + 'columns' => $columns, + 'column_names' => $column_names, + 'ajax_url' => 'include/ajax/module', + 'ajax_data' => [ + 'get_data_ModulesByStatus' => 1, + 'table_id' => $tableId, + 'search_agent' => $this->values['search_agent'], + 'search' => $this->values['search'], + 'groupId' => $this->values['groupId'], + 'status' => $this->values['status'], + 'nodes' => $this->values['nodes'], + 'disabled_modules' => $this->values['disabled_modules'], + 'auth_hash' => $hash, + 'auth_class' => 'PandoraFMS\Dashboard\Manager', + 'id_user' => $id_user, + ], + 'default_pagination' => $this->values['limit'], + 'order' => [ + 'field' => 'last_status_change', + 'direction' => 'desc', + ], + 'csv' => 0, + 'pagination_options' => [ + [ + 5, + 10, + 25, + 100, + 200, + 500, + 1000, + ], + [ + 5, + 10, + 25, + 100, + 200, + 500, + 1000, + ], + ], + 'dom_elements' => 'frtilp', + ] ); + } catch (\Exception $e) { + echo $e->getMessage(); } - - if ($modules !== false && empty($modules) === false) { - // Datatables list. - try { - $info_columns = $this->columns(); - $column_names = $info_columns['column_names']; - $columns = $info_columns['columns']; - $hash = get_parameter('auth_hash', ''); - $id_user = get_parameter('id_user', ''); - - $tableId = 'ModuleByStatus_'.$this->dashboardId.'_'.$this->cellId; - // Load datatables user interface. - ui_print_datatable( - [ - 'id' => $tableId, - 'class' => 'info_table align-left-important', - 'style' => 'width: 100%', - 'columns' => $columns, - 'column_names' => $column_names, - 'ajax_url' => 'include/ajax/module', - 'ajax_data' => [ - 'get_data_ModulesByStatus' => 1, - 'table_id' => $tableId, - 'search' => $this->values['search'], - 'status' => $this->values['status'], - 'nodes' => $this->values['nodes'], - 'disabled_modules' => $this->values['disabled_modules'], - 'auth_hash' => $hash, - 'auth_class' => 'PandoraFMS\Dashboard\Manager', - 'id_user' => $id_user, - ], - 'default_pagination' => $this->values['limit'], - 'order' => [ - 'field' => 'last_status_change', - 'direction' => 'desc', - ], - 'csv' => 0, - 'pagination_options' => [ - [ - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - ], - [ - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - ], - ], - 'dom_elements' => 'frtilp', - ] - ); - } catch (\Exception $e) { - echo $e->getMessage(); - } - } else { - $output = ''; - $output .= '
'; - $output .= \ui_print_info_message( - __('Not found modules'), - '', - true - ); - $output .= '
'; - - return $output; - } - } - - - /** - * Get info modules. - * - * @param string $search Free search. - * @param string $status Modules status. - * - * @return array Data. - */ - private function getInfoModules(string $search, string $status): array - { - if (empty($search) === false) { - $where = 'tagente_modulo.nombre LIKE "%%'.$search.'%%" AND '; - } - - if (str_contains($status, '6') === true) { - $expl = explode(',', $status); - $exist = array_search('6', $expl); - if (isset($exist) === true) { - unset($expl[$exist]); - } - - array_push($expl, '1', '2'); - - $status = implode(',', $expl); - } - - $where .= sprintf( - 'tagente_estado.estado IN (%s) - AND tagente_modulo.delete_pending = 0', - $status - ); - - $sql = sprintf( - 'SELECT - COUNT(*) AS "modules" - FROM tagente_modulo - INNER JOIN tagente - ON tagente_modulo.id_agente = tagente.id_agente - INNER JOIN tagente_estado - ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - WHERE %s', - $where - ); - - $modules = db_get_all_rows_sql($sql); - - if ($modules === false) { - $modules = []; - } - - return $modules; } @@ -579,7 +519,10 @@ class ModulesByStatus extends Widget 'nombre', 'alias', 'server_name', - 'last_status_change', + [ + 'text' => 'last_status_change', + 'class' => 'flex-column', + ], 'estado', ]; } else { @@ -593,7 +536,10 @@ class ModulesByStatus extends Widget $columns = [ 'nombre', 'alias', - 'last_status_change', + [ + 'text' => 'last_status_change', + 'class' => 'flex-column', + ], 'estado', ]; } @@ -642,12 +588,12 @@ class ModulesByStatus extends Widget $height_counter = (((int) count($nodes_fields)) * 20); $size = [ - 'width' => 450, + 'width' => 470, 'height' => (520 + $height_counter), ]; } else { $size = [ - 'width' => 450, + 'width' => 470, 'height' => 480, ]; } From 6e68e04027e999cbd052e90e9d1349ba09b74b74 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 4 Dec 2023 16:34:03 +0100 Subject: [PATCH 09/62] quit pagebreak pandora_enterprise#11605 --- pandora_console/include/functions_reporting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index dce7dd9efc..72c6fbd642 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -15847,8 +15847,8 @@ 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 .= ''; $result_pdf .= '
'; $result_pdf .= $title; From 160514cfbe5acd41941de26f0ca5e31d2fa10a09 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 13 Dec 2023 10:08:13 +0100 Subject: [PATCH 10/62] fix filter bug --- pandora_console/include/functions_events.php | 7 ++++++- pandora_console/operation/events/events.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 747e5154ce..852d00f270 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6472,7 +6472,12 @@ function event_print_graph( $color[] = '#82b92f'; } } else { - $interval_length = (int) ($period / $num_intervals); + $interval_length = 0; + + if ($num_intervals > 0) { + $interval_length = (int) ($period / $num_intervals); + } + $intervals = []; $intervals[0] = $start_utimestamp; for ($i = 0; $i < $num_intervals; $i++) { diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index be5f6047e3..f47fc71f55 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1234,7 +1234,7 @@ if (is_ajax() === true) { $data = array_values( array_filter( - $data, + ($data ?? []), function ($item) { return (bool) (array) $item; } From 29260473fce207f10c842c99ce89c83fa9a5d8f2 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 13 Dec 2023 13:29:48 +0100 Subject: [PATCH 11/62] fix missing fields --- .../godmode/events/event_responses.editor.php | 20 +++++++++---------- pandora_console/include/styles/events.css | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/events/event_responses.editor.php b/pandora_console/godmode/events/event_responses.editor.php index ae31e10ad1..477aa70e85 100644 --- a/pandora_console/godmode/events/event_responses.editor.php +++ b/pandora_console/godmode/events/event_responses.editor.php @@ -285,7 +285,7 @@ if (enterprise_installed()) { $data = []; $data[0] = html_print_label_input_block( '', - '