From 3e90c362503a1b3a1c98d5fd581219651b80e9c4 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 28 Nov 2022 11:31:44 +0100 Subject: [PATCH 001/182] #9713 New button for real path in filemanager --- .../include/functions_filemanager.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 94e16e822b..cfa7ed143c 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -571,6 +571,40 @@ function filemanager_file_explorer( } }).show(); } + + function show_modal_real_path (path) { + $('#modal_real_path').addClass('file_table_modal_active'); + $('#real_path').empty(); + $('#real_path').html(path); + title_action = ""; + $('#modal_real_path') + .dialog({ + title: title_action, + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 448, + minWidth: 448, + minHeight: 213, + maxWidth: 800, + maxHeight: 300, + close: function () { + $('#modal_real_path').removeClass('file_table_modal_active'); + } + }).show(); + + $("#submit-submit").on("click",copyToClipboard); + } + + function copyToClipboard() { + navigator.clipboard.writeText($("#real_path").text()).then(function (){ + $('#modal_real_path').dialog('close'); + }); + } '; } + if (is_writable($fileinfo['realpath']) === true + && (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3) + && ($readOnly === false) + ) { + $data[4] .= ''.html_print_image('images/book_edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Real path'), 'class' => 'invert_filter']).''; + } + $data[4] .= ''; array_push($table->data, $data); @@ -925,6 +966,18 @@ function filemanager_file_explorer( ); echo ''; + // Show Modal Real Path + $modal_real_path = "
Real path to plugin execution is:
+
+
".html_print_submit_button(__('Copy'), 'submit', false, 'class="sub next"', true).'
'; + html_print_div( + [ + 'id' => 'modal_real_path', + 'class' => 'invisible', + 'content' => $modal_real_path, + ] + ); + echo ''; } else { echo "
"; From 9cf50d005cc1b34676de072b348f41c7c9847b7e Mon Sep 17 00:00:00 2001 From: KANAYAMA Akihiro Date: Tue, 20 Dec 2022 12:06:18 +0900 Subject: [PATCH 002/182] fixed typo --- pandora_server/util/plugin/pandora_snmp_bandwidth.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl index 9b28848b48..db38b8444d 100755 --- a/pandora_server/util/plugin/pandora_snmp_bandwidth.pl +++ b/pandora_server/util/plugin/pandora_snmp_bandwidth.pl @@ -563,7 +563,7 @@ foreach my $iface (keys %{$analysis_tree}) { $inUsage += $analysis_tree->{$iface}{'inUsage'}; $j++; } - if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) { + if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'outUsage'} == 0) { $outUsage += $analysis_tree->{$iface}{'outUsage'}; $k++; } From c503836634e995f7337db335fbe3c47c82604fe3 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Thu, 12 Jan 2023 12:28:40 +0100 Subject: [PATCH 003/182] Restrict access to collections with nms license --- .../godmode/agentes/configurar_agente.php | 8 +++++--- pandora_console/godmode/menu.php | 3 ++- pandora_console/include/constants.php | 1 + pandora_console/include/functions.php | 16 ++++++++++++++++ pandora_console/include/functions_api.php | 10 ++++++++++ pandora_console/operation/agentes/ver_agente.php | 8 +++++--- 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 4432fef1cd..62807fa7c9 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -485,10 +485,12 @@ if ($id_agente) { } // Collection. - $collectiontab = enterprise_hook('collection_tab'); + if ($config['license_nms'] !== 1) { + $collectiontab = enterprise_hook('collection_tab'); - if ($collectiontab == -1) { - $collectiontab = ''; + if ($collectiontab == -1) { + $collectiontab = ''; + } } // NetworkConfigManager tab. diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index fef71922e3..7e9a7964a3 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -26,7 +26,8 @@ * GNU General Public License for more details. * ============================================================================ */ - +$config['license_nms'] = 1; +// ! Eliminar! // Begin. require_once 'include/config.php'; require_once 'include/functions_menu.php'; diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 96fb1c216b..18b32b6de4 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -805,6 +805,7 @@ define('AUDIT_LOG_DASHBOARD_MANAGEMENT', 'Dashboard management'); define('AUDIT_LOG_SERVICE_MANAGEMENT', 'Service management'); define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management'); define('AUDIT_LOG_UMC', 'Warp Manager'); +define('AUDIT_LOG_NMS_VIOLATION', 'NMS Violation'); // MIMEs. define( diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7c2df5603b..a333006da8 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -6342,3 +6342,19 @@ function setDownloadCookieToken() ); } } + + +/** + * Check nms license on api. + * + * @return boolean + */ +function nms_check_api() +{ + global $config; + + if ($config['license_nms'] === 1) { + returnError('license_error'); + return true; + } +} diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index db79ed3c86..f322f5c2de 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -198,6 +198,16 @@ function returnError($typeError, $returnType='string') ); break; + case 'license_error': + returnData( + $returnType, + [ + 'type' => 'string', + 'data' => __('License not allowed for this operation.'), + ] + ); + break; + default: returnData( $returnType, diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 2ee6781f00..89c7c70d8e 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -1461,9 +1461,11 @@ if ($inventorytab == -1 || $inventoryCount === 0) { } // Collection. -$collectiontab = enterprise_hook('collection_tab'); -if ($collectiontab == -1) { - $collectiontab = ''; +if ($config['license_nms'] !== 1) { + $collectiontab = enterprise_hook('collection_tab'); + if ($collectiontab == -1) { + $collectiontab = ''; + } } From 4392bd7fa8b7f96ff74aa5e1f84cefd1b94d30d7 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Fri, 13 Jan 2023 12:09:15 +0100 Subject: [PATCH 004/182] 9220 Restrict access to collections with nms license --- pandora_console/godmode/menu.php | 3 +-- pandora_console/godmode/servers/modificar_server.php | 10 ++++++---- .../include/class/SatelliteCollection.class.php | 9 +++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 7e9a7964a3..fef71922e3 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -26,8 +26,7 @@ * GNU General Public License for more details. * ============================================================================ */ -$config['license_nms'] = 1; -// ! Eliminar! + // Begin. require_once 'include/config.php'; require_once 'include/functions_menu.php'; diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index 17f2020d13..748c707227 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -141,11 +141,13 @@ if (isset($_GET['server'])) { ]; - $buttons['collections'] = [ - 'active' => false, - 'text' => ''.html_print_image('images/collection.png', true, ['title' => __('Collections')]).'', + if ($config['license_nms'] !== 1) { + $buttons['collections'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/collection.png', true, ['title' => __('Collections')]).'', - ]; + ]; + } } $buttons[$tab]['active'] = true; diff --git a/pandora_console/include/class/SatelliteCollection.class.php b/pandora_console/include/class/SatelliteCollection.class.php index 34348fdc7a..b8535f5cc6 100644 --- a/pandora_console/include/class/SatelliteCollection.class.php +++ b/pandora_console/include/class/SatelliteCollection.class.php @@ -84,6 +84,15 @@ class SatelliteCollection extends HTML return; } + if ($config['license_nms'] === 1) { + db_pandora_audit( + AUDIT_LOG_NMS_VIOLATION, + 'Trying to access satellite collections' + ); + include $config['homedir'].'/general/noaccess.php'; + return; + } + // Set the ajax controller. $this->ajaxController = $ajaxController; // Capture all parameters before start. From 67b7234e583a2094926799f3dfeb90d2942b958c Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 19 Jan 2023 10:49:48 +0100 Subject: [PATCH 005/182] implement filter save and load feature in monitor view --- pandora_console/extras/mr/62.sql | 23 + pandora_console/include/ajax/module.php | 536 ++++++++++++++++++ .../operation/agentes/status_monitor.php | 202 ++++++- pandora_console/pandoradb.sql | 23 + 4 files changed, 756 insertions(+), 28 deletions(-) create mode 100644 pandora_console/extras/mr/62.sql diff --git a/pandora_console/extras/mr/62.sql b/pandora_console/extras/mr/62.sql new file mode 100644 index 0000000000..c2a309eb32 --- /dev/null +++ b/pandora_console/extras/mr/62.sql @@ -0,0 +1,23 @@ +START TRANSACTION; + +CREATE TABLE IF NOT EXISTS `tmonitor_filter` ( + `id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_name` VARCHAR(600) NOT NULL, + `id_group_filter` INT NOT NULL DEFAULT 0, + `ag_group` INT NOT NULL DEFAULT 0, + `recursion` TEXT, + `status` INT NOT NULL DEFAULT -1, + `ag_modulename` TEXT, + `ag_freestring` TEXT, + `tag_filter` TEXT, + `moduletype` TEXT, + `module_option` INT DEFAULT 1, + `modulegroup` INT NOT NULL DEFAULT -1, + `min_hours_status` TEXT, + `datatype` TEXT, + `not_condition` TEXT, + `ag_custom_fields` TEXT, + PRIMARY KEY (`id_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +COMMIT; diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 61720a99a4..03eb150573 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -66,6 +66,12 @@ if (check_login()) { 0 ); + $load_filter_modal = get_parameter('load_filter_modal', 0); + $save_filter_modal = get_parameter('save_filter_modal', 0); + $get_monitor_filters = get_parameter('get_monitor_filters', 0); + $save_monitor_filter = get_parameter('save_monitor_filter', 0); + $update_monitor_filter = get_parameter('update_monitor_filter', 0); + if ($get_agent_modules_json_by_name === true) { $agent_name = get_parameter('agent_name'); @@ -1629,4 +1635,534 @@ if (check_login()) { return; } + + // Saves an event filter. + if ($save_monitor_filter) { + $values = []; + $values['id_name'] = get_parameter('id_name'); + $values['id_group_filter'] = get_parameter('id_group_filter'); + $values['ag_group'] = get_parameter('ag_group'); + $values['modulegroup'] = get_parameter('modulegroup'); + $values['recursion'] = get_parameter('recursion'); + $values['status'] = get_parameter('status'); + $values['ag_modulename'] = get_parameter('ag_modulename'); + $values['ag_freestring'] = get_parameter('ag_freestring'); + $values['tag_filter'] = json_encode(get_parameter('tag_filter')); + $values['moduletype'] = get_parameter('moduletype'); + $values['module_option'] = get_parameter('module_option'); + $values['min_hours_status'] = get_parameter('min_hours_status'); + $values['datatype'] = get_parameter('datatype'); + $values['not_condition'] = get_parameter('not_condition'); + $values['ag_custom_fields'] = get_parameter('ag_custom_fields'); + + $exists = (bool) db_get_value_filter( + 'id_filter', + 'tmonitor_filter', + $values + ); + + if ($exists === true) { + echo 'duplicate'; + } else { + $result = db_process_sql_insert('tmonitor_filter', $values); + + if ($result === false) { + echo 'error'; + } else { + echo $result; + } + } + } + + if ($update_monitor_filter) { + $values = []; + $id = get_parameter('id'); + + $values['ag_group'] = get_parameter('ag_group'); + $values['modulegroup'] = get_parameter('modulegroup'); + $values['recursion'] = get_parameter('recursion'); + $values['status'] = get_parameter('status'); + $values['ag_modulename'] = get_parameter('ag_modulename'); + $values['ag_freestring'] = get_parameter('ag_freestring'); + $values['tag_filter'] = json_encode(get_parameter('tag_filter')); + $values['moduletype'] = get_parameter('moduletype'); + $values['module_option'] = get_parameter('module_option'); + $values['min_hours_status'] = get_parameter('min_hours_status'); + $values['datatype'] = get_parameter('datatype'); + $values['not_condition'] = get_parameter('not_condition'); + $values['ag_custom_fields'] = get_parameter('ag_custom_fields'); + + $result = db_process_sql_update( + 'tmonitor_filter', + $values, + ['id_filter' => $id] + ); + + if ($result === false) { + echo 'error'; + } else { + echo 'ok'; + } + } + + if ($get_monitor_filters) { + $sql = 'SELECT id_filter, id_name FROM tmonitor_filter'; + + $monitor_filters = db_get_all_rows_sql($sql); + + $result = []; + + if ($monitor_filters !== false) { + foreach ($monitor_filters as $monitor_filter) { + $result[$monitor_filter['id_filter']] = $monitor_filter['id_name']; + } + } + + echo io_json_mb_encode($result); + } + + if ((int) $load_filter_modal === 1) { + $user_groups = users_get_groups( + $config['id_user'], + 'AR', + users_can_manage_group_all(), + true + ); + + $sql = 'SELECT id_filter, id_name + FROM tmonitor_filter + WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')'; + + $event_filters = db_get_all_rows_sql($sql); + + $filters = []; + foreach ($event_filters as $event_filter) { + $filters[$event_filter['id_filter']] = $event_filter['id_name']; + } + + echo '
'; + echo '
'; + + $table = new StdClass; + $table->id = 'load_filter_form'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'databox'; + if (is_metaconsole()) { + $table->cellspacing = 0; + $table->cellpadding = 0; + $table->class = 'databox filters'; + } + + $table->styleTable = 'font-weight: bold; color: #555; text-align:left;'; + $filter_id_width = '200px'; + if (is_metaconsole()) { + $filter_id_width = '150px'; + } + + $data = []; + $table->rowid[3] = 'update_filter_row1'; + $data[0] = __('Load filter').$jump; + $data[0] .= html_print_select( + $filters, + 'filter_id', + $current, + '', + __('None'), + 0, + true, + false, + true, + '', + false, + 'margin-left:5px; width:'.$filter_id_width.';' + ); + $data[1] = html_print_submit_button( + __('Load filter'), + 'load_filter', + false, + 'class="sub upd"', + true + ); + $data[1] .= html_print_input_hidden('load_filter', 1, true); + $table->data[] = $data; + $table->rowclass[] = ''; + + html_print_table($table); + echo '
'; + echo '
'; + ?> + + + '; + if (check_acl($config['id_user'], 0, 'EW') + || check_acl($config['id_user'], 0, 'EM') + ) { + echo '
'; + $table = new StdClass; + $table->id = 'save_filter_form'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'databox'; + if (is_metaconsole()) { + $table->class = 'databox filters'; + $table->cellspacing = 0; + $table->cellpadding = 0; + } + + $table->styleTable = 'font-weight: bold; text-align:left;'; + if (!is_metaconsole()) { + $table->style[0] = 'width: 50%; width:50%;'; + } + + $data = []; + $table->rowid[0] = 'update_save_selector'; + $data[0] = html_print_radio_button( + 'filter_mode', + 'new', + '', + true, + true + ).__('New filter').''; + + $data[1] = html_print_radio_button( + 'filter_mode', + 'update', + '', + false, + true + ).__('Update filter').''; + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[1] = 'save_filter_row1'; + $data[0] = __('Filter name').$jump; + $data[0] .= html_print_input_text('id_name', '', '', 15, 255, true); + if (is_metaconsole()) { + $data[1] = __('Save in Group').$jump; + } else { + $data[1] = __('Filter group').$jump; + } + + $user_groups_array = users_get_groups_for_select( + $config['id_user'], + 'EW', + users_can_manage_group_all(), + true + ); + + $data[1] .= html_print_select( + $user_groups_array, + 'id_group_filter_dialog', + $id_group_filter, + '', + '', + 0, + true, + false, + false, + 'w130' + ); + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[2] = 'save_filter_row2'; + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[3] = 'update_filter_row1'; + $data[0] = __('Overwrite filter').$jump; + + $sql = 'SELECT id_filter, id_name FROM tmonitor_filter'; + $monitor_filters = db_get_all_rows_sql($sql); + + $_filters_update = []; + + if ($monitor_filters !== false) { + foreach ($monitor_filters as $monitor_filter) { + $_filters_update[$monitor_filter['id_filter']] = $monitor_filter['id_name']; + } + } + + $data[0] .= html_print_select( + $_filters_update, + 'overwrite_filter', + '', + '', + '', + 0, + true + ); + $data[1] = html_print_submit_button( + __('Update filter'), + 'update_filter', + false, + 'class="sub upd" onclick="save_update_filter();"', + true + ); + + $table->data[] = $data; + $table->rowclass[] = ''; + + html_print_table($table); + echo '
'; + echo html_print_submit_button( + __('Save filter'), + 'save_filter', + false, + 'class="sub upd float-right" onclick="save_new_filter();"', + true + ); + echo '
'; + } else { + include 'general/noaccess.php'; + } + + echo '
'; + ?> + + 0) { + $user_groups_fl = users_get_groups( + $config['id_user'], + 'AR', + users_can_manage_group_all(), + true + ); + + $sql = sprintf( + 'SELECT id_filter, id_name + FROM tmonitor_filter + WHERE id_filter = %d AND id_group_filter IN (%s)', + $load_filter_id, + implode(',', array_keys($user_groups_fl)) + ); + + $loaded_filter = db_get_row_sql($sql); +} + +if ($loaded_filter['id_filter'] > 0) { + $query_filter['id_filter'] = $load_filter_id; + $filter = db_get_row_filter('tmonitor_filter', $query_filter, false); + if ($filter !== false) { + $ag_group = $filter['ag_group']; + $recursion = $filter['recursion']; + $status = $filter['status']; + $modulegroup = $filter['modulegroup']; + $ag_modulename = $filter['ag_modulename']; + $ag_freestring = $filter['ag_freestring']; + $tag_filter = $filter['tag_filter']; + $moduletype = $filter['moduletype']; + $module_option = $filter['module_option']; + $min_hours_status = $filter['min_hours_status']; + $datatype = $filter['datatype']; + $not_condition = $filter['not_condition']; + $ag_custom_fields = $filter['ag_custom_fields']; + + if ($not_condition === 'false') { + $not_condition = ''; + } + + if ($not_condition !== '') { + $is_none = 'None'; + $not_condition = 'NOT'; + } + + if ($not_condition !== '') { + $condition_query = '!='; + } + + if (is_array($tag_filter) === false) { + $tag_filter = json_decode($tag_filter, true); + } + if ($tag_filter === '') { + $tag_filter = [0 => 0]; + } + + if (is_array($ag_custom_fields) === false) { + $ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true); + } + } +} + // Agent group selector. if (!$is_metaconsole) { if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) { @@ -370,19 +436,21 @@ if (!empty($ag_custom_fields)) { } } +$all_tags = in_array(0, $tag_filter); + // Filter by tag. -if ($tag_filter !== 0) { - if ($is_metaconsole) { - $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( - SELECT ttag_module.id_agente_modulo - FROM ttag_module - WHERE ttag_module.id_tag '.$not_condition.' IN ('.$tag_filter.'))'; - } else { - $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( - SELECT ttag_module.id_agente_modulo - FROM ttag_module - WHERE ttag_module.id_tag '.$condition_query.' '.$tag_filter.')'; +if ($all_tags === false) { + $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( + SELECT ttag_module.id_agente_modulo + FROM ttag_module + WHERE 1=1'; + + if ($all_tags === false) { + $sql_conditions .= ' AND ttag_module.id_tag '.$not_condition.' IN ('.implode(',', $tag_filter).'))'; } +} else if ($not_condition === 'NOT') { + // Match nothing if not condition has been selected along with all tags selected (none). + $sql_conditions .= ' AND 0=0'; } @@ -475,13 +543,14 @@ $table->data[0][1] .= html_print_select_groups( false, $not_condition ); + $table->data[0][1] .= '
'; $table->data[0][1] .= html_print_input( [ 'type' => 'checkbox', 'name' => 'recursion', 'return' => true, - 'checked' => $recursion, + 'checked' => ($recursion === true || $recursion === 'true' || $recursion === '1') ? 'checked' : false, 'value' => 1, ] ); @@ -556,13 +625,13 @@ if (empty($tags)) { } else { $table->data[1][5] = html_print_select( $tags, - 'tag_filter', + 'tag_filter[]', $tag_filter, '', - __($is_none), - '', + __('All'), + 0, + true, true, - false, true, '', false, @@ -666,7 +735,6 @@ $table2->data[1][0] = 'data[1][0] .= '>'.__('Data type').''; $table2->data[1][1] .= '
'; - switch ($moduletype) { case 1: $sql = sprintf( @@ -771,7 +839,7 @@ $table2->data[1][3] = html_print_div( 'type' => 'switch', 'name' => 'not_condition', 'return' => false, - 'checked' => $check_not_condition, + 'checked' => ($check_not_condition === true || $check_not_condition === 'true' || $check_not_condition === '1') ? 'checked' : false, 'value' => 'NOT', 'id' => 'not_condition_switch', 'onclick' => 'changeNotConditionStatus(this)', @@ -855,9 +923,30 @@ $table->data[3][0] = ui_toggle( 'white_table_graph' ); -$table->colspan[4][0] = 7; +$table->colspan[4][0] = 2; $table->cellstyle[4][0] = 'padding-top: 0px;'; -$table->data[4][0] = html_print_submit_button( +$table->data[4][0] = html_print_button( + __('Load filter'), + 'load-filter', + false, + '', + 'class="float-left margin-right-2 sub config"', + true +); + +$table->cellstyle[4][0] .= 'padding-top: 0px;'; +$table->data[4][0] .= html_print_button( + __('Save filter'), + 'save-filter', + false, + '', + 'class="float-left margin-right-2 sub wand"', + true +); + +$table->colspan[4][2] = 5; +$table->cellstyle[4][2] = 'padding-top: 0px;'; +$table->data[4][2] = html_print_submit_button( __('Show'), 'uptbutton', false, @@ -2017,16 +2106,76 @@ if (!empty($result)) { } - // End Build List Result. - echo "
"; +// End Build List Result. +echo "
"; - enterprise_hook('close_meta_frame'); +// Load filter div for dialog. +echo ''; +echo ''; - ui_require_javascript_file('pandora_modules'); +enterprise_hook('close_meta_frame'); + +ui_require_javascript_file('pandora_modules'); ?> + '; + if (check_acl($config['id_user'], 0, 'AW')) { + echo '
'; + + $table = new StdClass; + $table->id = 'save_filter_form'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'databox'; + + if (is_metaconsole() === true) { + $table->class = 'databox filters'; + $table->cellspacing = 0; + $table->cellpadding = 0; + } + + $table->styleTable = 'font-weight: bold; text-align:left;'; + + if (is_metaconsole() === true) { + $table->style[0] = 'width: 50%; width:50%;'; + } + + $data = []; + $table->rowid[0] = 'update_save_selector'; + $data[0] = html_print_radio_button( + 'filter_mode', + 'new', + '', + true, + true + ).__('New filter').''; + + $data[1] = html_print_radio_button( + 'filter_mode', + 'update', + '', + false, + true + ).__('Update filter').''; + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[1] = 'save_filter_row1'; + $data[0] = __('Filter name').$jump; + $data[0] .= html_print_input_text('id_name', '', '', 15, 255, true); + + if (is_metaconsole() === true) { + $data[1] = __('Save in Group').$jump; + } else { + $data[1] = __('Filter group').$jump; + } + + $user_groups_array = users_get_groups_for_select( + $config['id_user'], + 'EW', + users_can_manage_group_all(), + true + ); + + $data[1] .= html_print_select( + $user_groups_array, + 'id_group_filter_dialog', + $id_group_filter, + '', + '', + 0, + true, + false, + false, + 'w130' + ); + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[2] = 'save_filter_row2'; + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[3] = 'update_filter_row1'; + $data[0] = __('Overwrite filter').$jump; + + $sql = 'SELECT id_filter, id_name FROM tagent_filter'; + $agent_filters = db_get_all_rows_sql($sql); + + $_filters_update = []; + + if ($agent_filters !== false) { + foreach ($agent_filters as $agent_filter) { + $_filters_update[$agent_filter['id_filter']] = $agent_filter['id_name']; + } + } + + $data[0] .= html_print_select( + $_filters_update, + 'overwrite_filter', + '', + '', + '', + 0, + true + ); + $data[1] = html_print_submit_button( + __('Update filter'), + 'update_filter', + false, + 'class="sub upd" onclick="save_update_filter();"', + true + ); + + $table->data[] = $data; + $table->rowclass[] = ''; + + html_print_table($table); + echo '
'; + echo html_print_submit_button( + __('Save filter'), + 'save_filter', + false, + 'class="sub upd float-right" onclick="save_new_filter();"', + true + ); + echo '
'; + } else { + include 'general/noaccess.php'; + } + + echo '
'; + ?> + + 0) { + $user_groups_fl = users_get_groups( + $config['id_user'], + 'AR', + users_can_manage_group_all(), + true + ); + + $sql = sprintf( + 'SELECT id_filter, id_name + FROM tagent_filter + WHERE id_filter = %d AND id_group_filter IN (%s)', + $load_filter_id, + implode(',', array_keys($user_groups_fl)) + ); + + $loaded_filter = db_get_row_sql($sql); +} + +if ($loaded_filter['id_filter'] > 0) { + $query_filter['id_filter'] = $load_filter_id; + $filter = db_get_row_filter('tagent_filter', $query_filter, false); + + if ($filter !== false) { + $group_id = (int) $filter['group_id']; + $recursion = $filter['recursion']; + $status = $filter['status']; + $search = $filter['search']; + $os = $filter['id_os']; + $policies = json_decode($filter['policies'], true); + $search_custom = $filter['search_custom']; + $ag_custom_fields = $filter['ag_custom_fields']; + } + + + if (is_array($ag_custom_fields) === false) { + $ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true); + } + + if (is_array($policies) === false) { + $policies = json_decode(io_safe_output($policies), true); + } +} + if (check_acl($config['id_user'], 0, 'AW')) { // Prepare the tab system to the future. $tab = 'setup'; @@ -247,22 +297,47 @@ if (isset($result_delete)) { echo '
'; -echo ''; +//echo '
'; -echo ''; +html_print_table($table); -echo '
'; +//echo '
'; -echo __('Group').' '.' '.' '; +// Start Build Search Form. +// +$table = new StdClass(); +$table->width = '100%'; +$table->cellspacing = 0; +$table->cellpadding = 0; +$table->class = 'databox filters'; +$table->style[0] = 'font-weight: bold;'; +$table->style[1] = 'font-weight: bold;'; +$table->style[2] = 'font-weight: bold;'; +$table->style[3] = 'font-weight: bold;'; +$table->style[4] = 'font-weight: bold;'; + +$table->data[0][0] = __('Group'); +$table->data[0][0] .= '
'; $groups = users_get_groups(false, $access); -html_print_select_groups(false, $access, true, 'group_id', $group_id, 'this.form.submit()', '', '', false, false, true, '', false); +$table->data[0][0] .= html_print_select_groups(false, $access, true, 'group_id', $group_id, 'this.form.submit()', '', '', true, false, true, '', false); -echo '
'.' '.' '.' '.' '.' '; +//$table->data[0][1] .= '  '; -echo __('Recursion').' '.' '.' '; -html_print_checkbox('recursion', 1, $recursion, false, false, 'this.form.submit()'); +$table->data[0][0] .= __('Recursion').' '.' '.' '; +$table->data[0][0] .= html_print_input( + [ + 'type' => 'checkbox', + 'name' => 'recursion', + 'return' => true, + 'checked' => $recursion, + 'checked' => ($recursion === true || $recursion === 'true' || $recursion === '1') ? 'checked' : false, + 'value' => 1, + ] +); -echo ''; + + +//echo ''; $fields = []; $fields[AGENT_STATUS_NORMAL] = __('Normal'); @@ -272,31 +347,125 @@ $fields[AGENT_STATUS_UNKNOWN] = __('Unknown'); $fields[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $fields[AGENT_STATUS_NOT_INIT] = __('Not init'); -echo __('Status').' '.' '.' '; -html_print_select($fields, 'status', $status, 'this.form.submit()', __('All'), AGENT_STATUS_ALL, false, false, true, '', false, 'width: 90px;'); +$table->data[0][1] = __('Status').' '.' '.' '; +$table->data[0][1] .= html_print_select($fields, 'status', $status, 'this.form.submit()', __('All'), AGENT_STATUS_ALL, true, false, true, '', false, 'width: 90px;'); -echo ''; +$table->data[0][2] = __('Search').' '.' '.' '; +$table->data[0][2] .= html_print_input_text('search', $search, '', 15, 255, true); -echo __('Search').' '.' '.' '; -html_print_input_text('search', $search, '', 15); +$table->data[1][0] = __('Operating System').' '; -echo ''; +$pre_fields = db_get_all_rows_sql( + 'select distinct(tagente.id_os),tconfig_os.name from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os' +); +$fields = []; -echo __('Search in custom fields').' '.' '.' '; -html_print_input_text('search_custom', $search_custom, '', 15); +foreach ($pre_fields as $key => $value) { + $fields[$value['id_os']] = $value['name']; +} -echo ''; +$table->data[1][0] .= html_print_select($fields, 'os', $os, 'this.form.submit()', 'All', 0, true); -html_print_submit_button( +$table->data[1][1] = __('Policies').' '; + +$pre_fields = policies_get_policies(false, ['id', 'name']); +$fields = []; + +foreach ($pre_fields as $value) { + $fields[$value['id']] = $value['name']; +} + +$table->data[1][1] .= html_print_select($fields, 'policies[]', $policies, '', 'All', 0, true, true); + +$table->data[1][2] = __('Search in custom fields').' '.' '.' '; +$table->data[1][2] .= html_print_input_text('search_custom', $search_custom, '', 15, 255, true); + + +$custom_fields = db_get_all_fields_in_table('tagent_custom_fields'); +if ($custom_fields === false) { + $custom_fields = []; +} + +$div_custom_fields = '
'; +foreach ($custom_fields as $custom_field) { + $custom_field_value = ''; + if (empty($ag_custom_fields) === false) { + $custom_field_value = $ag_custom_fields[$custom_field['id_field']]; + if (empty($custom_field_value) === true) { + $custom_field_value = ''; + } + } + + $div_custom_fields .= '
'; + + $div_custom_fields .= '
'; + $div_custom_fields .= ''.$custom_field['name'].''; + $div_custom_fields .= '
'; + + $div_custom_fields .= '
'; + $div_custom_fields .= html_print_input_text( + 'ag_custom_fields['.$custom_field['id_field'].']', + $custom_field_value, + '', + 0, + 300, + true, + false, + false, + '', + 'div-input' + ); + $div_custom_fields .= '
'; +} + +$table->colspan[2][0] = 7; +$table->cellstyle[2][0] = 'padding-left: 10px;'; +$table->data[2][0] = ui_toggle( + $div_custom_fields, + __('Agent custom fields'), + '', + '', + true, + true, + '', + 'white-box-content', + 'white_table_graph' +); + + +$table->colspan[4][0] = 4; +$table->cellstyle[4][0] = 'padding-top: 0px;'; +$table->data[4][0] = html_print_button( + __('Load filter'), + 'load-filter', + false, + '', + 'class="float-left margin-right-2 sub config"', + true +); + +$table->cellstyle[4][0] .= 'padding-top: 0px;'; +$table->data[4][0] .= html_print_button( + __('Save filter'), + 'save-filter', + false, + '', + 'class="float-left margin-right-2 sub wand"', + true +); + +$table->cellstyle[4][2] = 'padding-top: 0px;'; +$table->data[4][2] = html_print_submit_button( __('Search'), 'srcbutton', '', - ['class' => 'sub search'] + ['class' => 'sub search'], + true ); -echo '
'; +''; if ($search != '') { $filter = ['string' => '%'.$search.'%']; @@ -320,6 +489,8 @@ $selectDescriptionUp = false; $selectDescriptionDown = false; $selectLastContactUp = false; $selectLastContactDown = false; +$selectLastStatusChangeUp = false; +$selectLastStatusChangeDown = false; $order = null; switch ($sortField) { @@ -479,6 +650,32 @@ switch ($sortField) { } break; + case 'last_status_change': + switch ($sort) { + case 'up': + $selectLastStatusChangeUp = $selected; + $order = [ + 'field' => 'last_status_change', + 'field2' => 'alias', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectLastStatusChangeDown = $selected; + $order = [ + 'field' => 'last_status_change', + 'field2' => 'alias', + 'order' => 'DESC', + ]; + break; + + default: + // Default. + break; + } + break; + case 'description': switch ($sort) { case 'up': @@ -518,6 +715,8 @@ switch ($sortField) { $selectDescriptionDown = false; $selectLastContactUp = false; $selectLastContactDown = false; + $selectLastStatusChangeUp = false; + $selectLastStatusChangeDown = false; $order = [ 'field' => 'alias', 'field2' => 'alias', @@ -577,6 +776,24 @@ if (!empty($search_custom)) { $search_sql_custom = ''; } +// Filter by agent custom fields. +$sql_conditions_custom_fields = ''; +if (empty($ag_custom_fields) === false) { + $cf_filter = []; + foreach ($ag_custom_fields as $field_id => $value) { + if (empty($value) === false) { + $cf_filter[] = '(tagent_custom_data.id_field = '.$field_id.' AND tagent_custom_data.description LIKE \'%'.$value.'%\')'; + } + } + + if (empty($cf_filter) === false) { + $sql_conditions_custom_fields = ' AND tagente.id_agente IN ( + SELECT tagent_custom_data.id_agent + FROM tagent_custom_data + WHERE '.implode(' AND ', $cf_filter).')'; + } +} + // Show only selected groups. if ($group_id > 0) { $groups = [$group_id]; @@ -589,23 +806,41 @@ if ($group_id > 0) { $groups = array_keys($user_groups); } +$all_policies = in_array(0, $policies ?? []); + +$id_os_sql = ''; +$policies_sql = ''; + +if ($os > 0) { + $id_os_sql = ' AND id_os = '.$os; +} + +if ($all_policies === false && is_array($policies) && count($policies) > 0) { + $policies_sql = ' AND tpolicy_agents.id_policy IN ('.implode(',', $policies).')'; +} if ($strict_user) { $count_filter = [ // 'order' => 'tagente.nombre ASC', - 'order' => 'tagente.nombre ASC', - 'disabled' => 0, - 'status' => $status, - 'search' => $search, + 'order' => 'tagente.nombre ASC', + 'disabled' => 0, + 'status' => $status, + 'search' => $search, + 'id_os' => $id_os_sql, + 'policies' => $policies_sql, + 'other_condition' => $sql_conditions_custom_fields, ]; $filter = [ // 'order' => 'tagente.nombre ASC', - 'order' => 'tagente.nombre ASC', - 'disabled' => 0, - 'status' => $status, - 'search' => $search, - 'offset' => (int) get_parameter('offset'), - 'limit' => (int) $config['block_size'], + 'order' => 'tagente.nombre ASC', + 'disabled' => 0, + 'status' => $status, + 'search' => $search, + 'offset' => (int) get_parameter('offset'), + 'limit' => (int) $config['block_size'], + 'id_os' => $id_os_sql, + 'policies' => $policies_sql, + 'other_condition' => $sql_conditions_custom_fields, ]; if ($group_id > 0) { @@ -644,28 +879,48 @@ if ($strict_user) { $agents = tags_get_all_user_agents(false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true); } else { + $count_filter = [ + 'disabled' => 0, + 'id_grupo' => $groups, + 'search' => $search_sql, + 'search_custom' => $search_sql_custom, + 'status' => $status, + 'id_os' => $id_os_sql, + 'policies' => $policies_sql, + 'other_condition' => $sql_conditions_custom_fields, + ]; + + $filter = [ + 'order' => 'nombre ASC', + 'id_grupo' => $groups, + 'disabled' => 0, + 'status' => $status, + 'search_custom' => $search_sql_custom, + 'search' => $search_sql, + 'offset' => (int) get_parameter('offset'), + 'limit' => (int) $config['block_size'], + 'id_os' => $id_os_sql, + 'policies' => $policies_sql, + 'other_condition' => $sql_conditions_custom_fields, + ]; + $total_agents = agents_count_agents_filter( - [ - 'disabled' => 0, - 'id_grupo' => $groups, - 'search' => $search_sql, - 'search_custom' => $search_sql_custom, - 'status' => $status, - ], + $count_filter, $access ); + $query_order = $order; + + if ($order['field'] === 'last_status_change') { + $query_order = [ + 'field' => 'alias', + 'field2' => 'alias', + 'order' => 'ASC', + ]; + } + $agents = agents_get_agents( - [ - 'order' => 'nombre '.' ASC', - 'id_grupo' => $groups, - 'disabled' => 0, - 'status' => $status, - 'search_custom' => $search_sql_custom, - 'search' => $search_sql, - 'offset' => (int) get_parameter('offset'), - 'limit' => (int) $config['block_size'], - ], + $filter, [ 'id_agente', 'id_grupo', @@ -688,7 +943,7 @@ if ($strict_user) { 'agent_version', ], $access, - $order + $query_order ); } @@ -720,7 +975,8 @@ $url_up_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente& $url_down_group = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=group&sort=down'; $url_up_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_contact&sort=up'; $url_down_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_contact&sort=down'; - +$url_up_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_status_change&sort=up'; +$url_down_last_status_change = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_status_change&sort=down'; // Prepare pagination. ui_pagination( @@ -740,16 +996,16 @@ $table->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_ag $table->size[0] = '12%'; $table->head[1] = __('Description').ui_get_sorting_arrows($url_up_description, $url_down_description, $selectDescriptionUp, $selectDescriptionDown); -$table->size[1] = '16%'; +$table->size[1] = '14%'; -$table->head[10] = __('Remote').ui_get_sorting_arrows($url_up_remote, $url_down_remote, $selectRemoteUp, $selectRemoteDown); -$table->size[10] = '9%'; +$table->head[12] = __('Remote').ui_get_sorting_arrows($url_up_remote, $url_down_remote, $selectRemoteUp, $selectRemoteDown); +$table->size[12] = '9%'; $table->head[2] = __('OS').ui_get_sorting_arrows($url_up_os, $url_down_os, $selectOsUp, $selectOsDown); $table->size[2] = '8%'; $table->head[3] = __('Interval').ui_get_sorting_arrows($url_up_interval, $url_down_interval, $selectIntervalUp, $selectIntervalDown); -$table->size[3] = '10%'; +$table->size[3] = '8%'; $table->head[4] = __('Group').ui_get_sorting_arrows($url_up_group, $url_down_group, $selectGroupUp, $selectGroupDown); $table->size[4] = '8%'; @@ -767,7 +1023,13 @@ $table->head[8] = __('Alerts'); $table->size[8] = '4%'; $table->head[9] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown); -$table->size[9] = '15%'; +$table->size[9] = '8%'; + +$table->head[10] = __('Last status change').ui_get_sorting_arrows($url_up_last_status_change, $url_down_last_status_change, $selectLastStatusChangeUp, $selectLastStatusChangeDown); +$table->size[10] = '10%'; + +$table->head[11] = __('Agent events'); +$table->size[11] = '4%'; $table->align = []; @@ -779,6 +1041,8 @@ $table->align[6] = 'left'; $table->align[7] = 'left'; $table->align[8] = 'left'; $table->align[9] = 'left'; +$table->align[10] = 'left'; +$table->align[11] = 'left'; $table->style = []; @@ -881,12 +1145,12 @@ foreach ($agents as $agent) { $data[1] = ''.ui_print_truncate_text($agent['description'], 'description', false, true, true, '[…]').''; - $data[10] = ''; + $data[12] = ''; if (enterprise_installed()) { enterprise_include_once('include/functions_config_agents.php'); if (enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']])) { - $data[10] = ''.html_print_image( + $data[12] = ''.html_print_image( 'images/application_edit.png', true, [ @@ -930,6 +1194,27 @@ foreach ($agents as $agent) { $data[9] = agents_get_interval_status($agent); + $last_status_change_agent = agents_get_last_status_change($agent['id_agente']); + $time_elapsed = !empty($last_status_change_agent) ? human_time_comparation($last_status_change_agent) : ''.__('N/A').''; + $data[10] = $time_elapsed; + + $agent_event_filter = [ + 'id_agent' => $agent['id_agente'], + 'event_view_hr' => 48, + 'status' => -1, + ]; + + $fb64 = base64_encode(json_encode($agent_event_filter)); + $data[11] = ''.html_print_image( + 'images/lightning.png', + true, + [ + 'align' => 'middle', + 'title' => __('Agent events'), + 'class' => 'invert_filter', + ] + ).''; + // This old code was returning "never" on agents without modules, BAD !! // And does not print outdated agents in red. WRONG !!!! // $data[7] = ui_print_timestamp ($agent_info["last_contact"], true); @@ -937,6 +1222,20 @@ foreach ($agents as $agent) { } if (!empty($table->data)) { + if ($order['field'] === 'last_status_change') { + $order_direction = $order['order']; + usort( + $table->data, + function ($a, $b) use ($order_direction) { + if ($order_direction === 'ASC') { + return strtotime($a[10]) > strtotime($b[10]); + } else { + return strtotime($a[10]) < strtotime($b[10]); + } + } + ); + } + html_print_table($table); ui_pagination( @@ -975,10 +1274,69 @@ if (!empty($table->data)) { echo ''; echo '
'; } + +// Load filter div for dialog. +echo ''; +echo ''; + ?> + 'StarTrek emergency simulation', ]; +$eventsounds = mysql_db_get_row_sql('SELECT * FROM tevent_sound WHERE active = 1'); +foreach ($eventsounds as $key => $row) { + $sounds[$row['sound']] = $row['name']; +} + $inputs[] = [ 'label' => \__('Sounds'), 'class' => 'flex-row', diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index bb0802a567..fd681495be 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -477,6 +477,10 @@ if ($access_console_node === true) { } Date: Fri, 27 Jan 2023 12:44:15 +0100 Subject: [PATCH 026/182] blink button test sound events pandora_enterprise#10189 --- .../include/javascript/pandora_events.js | 2 + .../include/styles/sound_events.css | 56 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index c2ee675f0d..92eadf14fe 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1030,8 +1030,10 @@ function openSoundEventModal(settings) { function test_sound_button(test_sound, urlSound) { if (test_sound === true) { + $("#button-melody_sound").addClass("blink-image"); add_audio(urlSound); } else { + $("#button-melody_sound").removeClass("blink-image"); remove_audio(); } } diff --git a/pandora_console/include/styles/sound_events.css b/pandora_console/include/styles/sound_events.css index 667446b1e8..9990550fda 100644 --- a/pandora_console/include/styles/sound_events.css +++ b/pandora_console/include/styles/sound_events.css @@ -301,3 +301,59 @@ background: #e63c52; } } + +/* Firefox old*/ +@-moz-keyframes blink { + 0% { + opacity: 1; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +@-webkit-keyframes blink { + 0% { + opacity: 1; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +/* IE */ +@-ms-keyframes blink { + 0% { + opacity: 1; + } + 50% { + opacity: 0.5; + } + 100% { + opacity: 1; + } +} +/* Opera and prob css3 final iteration */ +@keyframes blink { + 0% { + opacity: 1; + } + 50% { + opacity: 0.5; + } + 100% { + opacity: 1; + } +} +.blink-image { + -moz-animation: blink normal 2s infinite ease-in-out; /* Firefox */ + -webkit-animation: blink normal 2s infinite ease-in-out; /* Webkit */ + -ms-animation: blink normal 2s infinite ease-in-out; /* IE */ + animation: blink normal 2s infinite ease-in-out; /* Opera and prob css3 final iteration */ + filter: hue-rotate(120deg); +} From 27b42d313702174374b4e7b94592f49a2478285f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 27 Jan 2023 13:23:48 +0100 Subject: [PATCH 027/182] #10076 add easy acces on directorys --- pandora_console/godmode/servers/plugin.php | 114 ++++++++++----------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 82049defca..94ab20aebf 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -225,67 +225,67 @@ if ($filemanager) { $directory = (string) get_parameter('directory'); if (empty($directory) === true) { $directory = $fallback_directory; - $base_url = 'index.php?sec=gservers&sec2=godmode/servers/plugin'; - $setup_url = $base_url.'&filemanager=1&tab=Attachments'; - $tab = get_parameter('tab', null); - $tabs = [ - 'list' => [ - 'text' => ''.html_print_image( - 'images/eye_show.png', - true, - [ - 'title' => __('Plugins'), - 'class' => 'invert_filter', - ] - ).'', - 'active' => (bool) ($tab != 'Attachments'), - ], - 'options' => [ - 'text' => ''.html_print_image( - 'images/collection.png', - true, - [ - 'title' => __('Attachments'), - 'class' => 'invert_filter', - ] - ).'', - 'active' => (bool) ($tab == 'Attachments'), - ], - ]; - - if ($tab === 'Attachments') { - $helpHeader = ''; - $titleHeader = __('Index of attachment/plugin'); - } else { - $helpHeader = 'servers_ha_clusters_tab'; - $titleHeader = __('Plug-ins registered on %s', get_product_name()); - } - - // Header. - ui_print_standard_header( - $titleHeader, - 'images/gm_servers.png', - false, - $helpHeader, - false, - $tabs, - [ - [ - 'link' => '', - 'label' => __('Servers'), - ], - [ - 'link' => '', - 'label' => __('Plugins'), - ], - ] - ); } else { $directory = str_replace('\\', '/', $directory); $directory = filemanager_safe_directory($directory, $fallback_directory); - echo '

'.__('Index of %s', $directory).'

'; } + $base_url = 'index.php?sec=gservers&sec2=godmode/servers/plugin'; + $setup_url = $base_url.'&filemanager=1&tab=Attachments'; + $tab = get_parameter('tab', null); + $tabs = [ + 'list' => [ + 'text' => ''.html_print_image( + 'images/eye_show.png', + true, + [ + 'title' => __('Plugins'), + 'class' => 'invert_filter', + ] + ).'', + 'active' => (bool) ($tab != 'Attachments'), + ], + 'options' => [ + 'text' => ''.html_print_image( + 'images/collection.png', + true, + [ + 'title' => __('Attachments'), + 'class' => 'invert_filter', + ] + ).'', + 'active' => (bool) ($tab == 'Attachments'), + ], + ]; + + if ($tab === 'Attachments') { + $helpHeader = ''; + $titleHeader = __('Index of attachment/plugin'); + } else { + $helpHeader = 'servers_ha_clusters_tab'; + $titleHeader = __('Plug-ins registered on %s', get_product_name()); + } + + // Header. + ui_print_standard_header( + $titleHeader, + 'images/gm_servers.png', + false, + $helpHeader, + false, + $tabs, + [ + [ + 'link' => '', + 'label' => __('Servers'), + ], + [ + 'link' => '', + 'label' => __('Plugins'), + ], + ] + ); + $real_directory = realpath($config['homedir'].'/'.$directory); @@ -310,7 +310,7 @@ if ($filemanager) { filemanager_file_explorer( $real_directory, $directory, - 'index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin='.$id_plugin, + 'index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin='.$id_plugin.'&tab=Attachments', $fallback_directory, true, false, From 7111fd66e2fc23008fb7080dad788d9325d4f95f Mon Sep 17 00:00:00 2001 From: Calvo Date: Fri, 27 Jan 2023 13:43:23 +0100 Subject: [PATCH 028/182] Fix empty module data list view --- pandora_console/operation/agentes/status_monitor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 8da3b9b2ba..82ba6fcfee 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1939,7 +1939,7 @@ if (!empty($result)) { } else { $sub_string = substr(io_safe_output($row['datos']), 0, 12); if ($module_value == $sub_string) { - if ($module_value == 0 && !$sub_string) { + if ((empty($module_value) === true || $module_value == 0) && !$sub_string) { $salida = 0; } else { $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); From 624463d5739ec26dff469ddede86dc8b31e85d7d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 30 Jan 2023 08:27:03 +0100 Subject: [PATCH 029/182] #9819 change setcion menu configuration sound --- pandora_console/godmode/menu.php | 4 ++++ pandora_console/operation/menu.php | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index d98eb9d3c6..9dc13b6abb 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -435,6 +435,10 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($ } } + $sub['godmode/events/configuration_sounds']['text'] = __('Configuration Sounds'); + $sub['godmode/events/configuration_sounds']['id'] = 'Configuration Sounds'; + $sub['godmode/events/configuration_sounds']['pages'] = ['godmode/events/configuration_sounds']; + $menu_godmode['gextensions']['sub'] = $sub; } diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index fd681495be..c777e1d97b 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -477,10 +477,6 @@ if ($access_console_node === true) { } Date: Mon, 30 Jan 2023 15:31:58 +0100 Subject: [PATCH 030/182] update google sheet plugin --- .../google_sheets/pandora_googlesheet.py | 72 ++++++++++++++----- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/pandora_plugins/google_sheets/pandora_googlesheet.py b/pandora_plugins/google_sheets/pandora_googlesheet.py index a6e599b429..d02fc4cd3b 100644 --- a/pandora_plugins/google_sheets/pandora_googlesheet.py +++ b/pandora_plugins/google_sheets/pandora_googlesheet.py @@ -1,7 +1,13 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + import gspread -import argparse +import argparse,json,sys from oauth2client.service_account import ServiceAccountCredentials from pprint import pprint +from os import remove + +import base64 __author__ = "Alejandro Sánchez Carrion" __copyright__ = "Copyright 2022, PandoraFMS" @@ -15,33 +21,63 @@ Version = {__version__} Manual execution -python3 pandora_googlesheets.py --cred --row --column +python3 pandora_googlesheets.py --creds_json/creds_base64 --row --column """ parser = argparse.ArgumentParser(description= info, formatter_class=argparse.RawTextHelpFormatter) -parser.add_argument('--cred', help='') -parser.add_argument('--name', help='') -parser.add_argument('--row', help='',type=int) -parser.add_argument('--column', help='',type=int) +parser.add_argument('--creds_json', help='To authenticate with a json file.') +parser.add_argument('--creds_base64', help='To authenticate with a file that includes the credentials for base64 authentication.') +parser.add_argument('--name', help='Name of the google sheets document.') +parser.add_argument('--cell', help='To collect the value of a cell.') +parser.add_argument('--row', help='To collect the value of a row.',type=int) +parser.add_argument('--column', help='To collect the value of a column.',type=int) +parser.add_argument('--sheet', help='To indicate the name of the document sheet, put it in quotation marks and count spaces and capital letters.',type=str) args = parser.parse_args() scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"] -creds = ServiceAccountCredentials.from_json_keyfile_name(args.cred, scope) + + + + +## authenticate with file json input +if args.creds_json is not None and args.creds_base64 == None: + creds = ServiceAccountCredentials.from_json_keyfile_name(args.creds_json, scope) +## authenticate with base64 input +elif args.creds_base64 is not None and args.creds_json== None: + ## base64 to json + with open(args.creds_base64, 'r') as file: + data = file.read().replace('\n', '') + text=base64.b64decode(data).decode('utf-8') + with open("cred.json", "w") as outfile: + outfile.write(text) + creds = ServiceAccountCredentials.from_json_keyfile_name("cred.json", scope) + remove("cred.json") +else: + print("You need to use the --creds_json or creds_base 64 parameter to authenticate. You can only select one.") + sys.exit() client = gspread.authorize(creds) -sheet = client.open(args.name).sheet1 # Open the spreadhseet +sheet = client.open(args.name) # Open the spreadhseet +worksheet = sheet.worksheet(args.sheet) # Open worksheet -data = sheet.get_all_records() # Get a list of all records +if args.cell is not None and args.row==None and args.column==None : -if args.row is not None and args.column==None: - row = sheet.row_values(args.row) # Get a specific row - print(row) -elif args.row ==None and args.column is not None: - col = sheet.col_values(args.column) # Get a specific column - print(col) -elif args.row is not None and args.column is not None: - cell = sheet.cell(args.row,args.column).value # Get the value of a specific cell - print(cell) + val = worksheet.acell(args.cell).value + +elif args.row is not None and args.column==None and args.cell == None: + + val = worksheet.row_values(args.row) # Get a specific row + +elif args.column is not None and args.row== None and args.cell == None: + + val = worksheet.col_values(args.column) # Get a specific column + +else: + print("To search for data in a cell use the --cell parameter, for data in a column --column and in a row --row, only one of these parameters can be used at a time.") + sys.exit() + + +print(val) From 9305fd17babafe6ef2cb69444cb44bc224be981f Mon Sep 17 00:00:00 2001 From: Calvo Date: Mon, 30 Jan 2023 17:16:20 +0100 Subject: [PATCH 031/182] Fix get agent status on unknown modules --- pandora_server/lib/PandoraFMS/DB.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 338a914ab4..4a42019023 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -618,8 +618,13 @@ sub get_agent_status ($$$) { $module_status = 2; } elsif ($module_status != 2) { - if ($m_status == 0) { - $module_status = 0; + if ($m_status == 3) { + $module_status = 3; + } + elsif ($module_status != 3) { + if ($m_status == 3) { + $module_status = 3; + } } } } @@ -647,6 +652,8 @@ sub get_agent_status ($$$) { return 3; } } + + print "MS ::::::::::::::".Dumper($module_status); return $module_status; } From 825137d18bdfdbbd5de0ffb38619ef5fc0df6d39 Mon Sep 17 00:00:00 2001 From: Calvo Date: Mon, 30 Jan 2023 17:17:48 +0100 Subject: [PATCH 032/182] Fix get agent status on unknown modules --- pandora_server/lib/PandoraFMS/DB.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 4a42019023..993f4e1fe8 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -622,8 +622,8 @@ sub get_agent_status ($$$) { $module_status = 3; } elsif ($module_status != 3) { - if ($m_status == 3) { - $module_status = 3; + if ($m_status == 0) { + $module_status = 0; } } } From 8475e5fbf68255bfc7810692b36f7e51fb2e34fb Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 30 Jan 2023 17:21:20 +0100 Subject: [PATCH 033/182] #10162 fixed entities in special days --- pandora_console/views/calendar/special_days_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/views/calendar/special_days_edit.php b/pandora_console/views/calendar/special_days_edit.php index 23f72dc38f..74197e57bd 100644 --- a/pandora_console/views/calendar/special_days_edit.php +++ b/pandora_console/views/calendar/special_days_edit.php @@ -140,7 +140,7 @@ $inputs[] = [ 'type' => 'textarea', 'name' => 'description', 'required' => false, - 'value' => $specialDay->description(), + 'value' => io_safe_output($specialDay->description()), 'rows' => 50, 'columns' => 30, ], From cb6e523e337e4b4f9e67d912f91e64a5404e2db0 Mon Sep 17 00:00:00 2001 From: Calvo Date: Mon, 30 Jan 2023 17:27:00 +0100 Subject: [PATCH 034/182] Fix style --- pandora_server/lib/PandoraFMS/DB.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 993f4e1fe8..7795ffbcea 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -623,7 +623,7 @@ sub get_agent_status ($$$) { } elsif ($module_status != 3) { if ($m_status == 0) { - $module_status = 0; + $module_status = 0; } } } From a0c311c1105590db35161cd7a9c055749e9a8df3 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 30 Jan 2023 19:47:02 +0100 Subject: [PATCH 035/182] fixed vulnerability --- .../godmode/setup/file_manager.php | 16 ++++++++++++++++ .../include/functions_filemanager.php | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/setup/file_manager.php b/pandora_console/godmode/setup/file_manager.php index 6f54f2f0a8..272eab74f0 100644 --- a/pandora_console/godmode/setup/file_manager.php +++ b/pandora_console/godmode/setup/file_manager.php @@ -87,6 +87,22 @@ $create_text_file = (bool) get_parameter('create_text_file'); $default_real_directory = realpath($config['homedir'].'/'); +$_FILES['file']['name'] = '../test3.jpeg'; + +// Remove double dot in filename path. +$file_name = $_FILES['file']['name']; +$path_parts = explode('/', $file_name); + +$stripped_parts = array_filter( + $path_parts, + function ($value) { + return $value !== '..'; + } +); + +$stripped_path = implode('/', $stripped_parts); +$_FILES['file']['name'] = $stripped_path; + if ($upload_file === true) { upload_file( $upload_file, diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 94e16e822b..3242fadcb0 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -139,8 +139,25 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_ $nombre_archivo = sprintf('%s/%s', $real_directory, $filename); try { $mimeContentType = mime_content_type($_FILES['file']['tmp_name']); + $fileExtension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); - if (empty($filterFilesType) === true || in_array($mimeContentType, $filterFilesType) === true) { + $validFileExtension = true; + + if (empty($fileExtension) === false) { + $filtered_types = array_filter( + $filterFilesType, + function ($value) use ($fileExtension) { + $mimeTypeExtensionName = explode('/', $value)[1]; + return $mimeTypeExtensionName === $fileExtension; + } + ); + + if (empty($filtered_types) === true) { + $validFileExtension = false; + } + } + + if ($validFileExtension === true && (empty($filterFilesType) === true || in_array($mimeContentType, $filterFilesType) === true)) { $result = copy($_FILES['file']['tmp_name'], $nombre_archivo); } else { $error_message = 'The uploaded file is not allowed. Only gif, png or jpg files can be uploaded.'; From b88f26500b66ac5b2752865ef8a2994535de4bf7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 31 Jan 2023 08:35:47 +0100 Subject: [PATCH 036/182] #9819 Change labels Accoustic console --- pandora_console/godmode/menu.php | 4 ++-- pandora_console/include/class/EventSound.class.php | 6 +++--- pandora_console/operation/events/events.php | 6 +++--- pandora_console/operation/events/sound_events.php | 4 ++-- pandora_console/operation/menu.php | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 9dc13b6abb..d4f903290e 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -435,8 +435,8 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($ } } - $sub['godmode/events/configuration_sounds']['text'] = __('Configuration Sounds'); - $sub['godmode/events/configuration_sounds']['id'] = 'Configuration Sounds'; + $sub['godmode/events/configuration_sounds']['text'] = __('Accoustic console setup'); + $sub['godmode/events/configuration_sounds']['id'] = 'Accoustic console setup'; $sub['godmode/events/configuration_sounds']['pages'] = ['godmode/events/configuration_sounds']; $menu_godmode['gextensions']['sub'] = $sub; diff --git a/pandora_console/include/class/EventSound.class.php b/pandora_console/include/class/EventSound.class.php index 93f42ec7c4..b943e9cce1 100644 --- a/pandora_console/include/class/EventSound.class.php +++ b/pandora_console/include/class/EventSound.class.php @@ -209,7 +209,7 @@ class EventSound extends HTML $titleHeader = __('Add new sound'); } else { $helpHeader = 'servers_ha_clusters_tab'; - $titleHeader = __('Events sound list'); + $titleHeader = __('Accoustic console sound list'); } // Header. @@ -223,11 +223,11 @@ class EventSound extends HTML [ [ 'link' => '', - 'label' => __('Events'), + 'label' => __('Admin tools'), ], [ 'link' => '', - 'label' => __('Configuration Sounds'), + 'label' => __('Accoustic console setup'), ], ] ); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 648581a3a6..eb885bf479 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1473,13 +1473,13 @@ if ($pure) { ] ).''; - // Sound events. + // Accoustic console. $sound_event['active'] = false; $sound_event['text'] = ''.html_print_image( 'images/sound.png', true, [ - 'title' => __('Sound events'), + 'title' => __('Accoustic console'), 'class' => 'invert_filter', ] ).''; @@ -1529,7 +1529,7 @@ if ($pure) { switch ($section) { case 'sound_event': $onheader['sound_event']['active'] = true; - $section_string = __('Sound events'); + $section_string = __('Accoustic console'); break; case 'history': diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index 2f2b11e065..6ce7a31c3a 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -60,7 +60,7 @@ ob_start(); echo ''; echo ''; -echo ''.__('Sound Events').''; +echo ''.__('Accoustic console').''; ui_require_css_file('wizard'); ui_require_css_file('discovery'); ?> @@ -161,7 +161,7 @@ if ($config['style'] === 'pandora_black' && !is_metaconsole()) { echo ''; echo ""; -echo "

".__('Sound console').'

'; +echo "

".__('Accoustic console').'

'; // Connection lost alert. ui_require_css_file('register', 'include/styles/', true); diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index c777e1d97b..eed84a4d48 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -432,11 +432,11 @@ if ($access_console_node === true) { $sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&fb64='.$fb64]['type'] = 'direct'; } - // Sound Events. + // Accoustic console. $data_sound = base64_encode( json_encode( [ - 'title' => __('Sound Console'), + 'title' => __('Accoustic console'), 'start' => __('Start'), 'stop' => __('Stop'), 'noAlert' => __('No alert'), @@ -449,8 +449,8 @@ if ($access_console_node === true) { ); $javascript = 'javascript: openSoundEventModal(`'.$data_sound.'`);'; - $sub[$javascript]['text'] = __('Sound Events'); - $sub[$javascript]['id'] = 'Sound Events Modal'; + $sub[$javascript]['text'] = __('Accoustic console'); + $sub[$javascript]['id'] = 'Accoustic console Modal'; $sub[$javascript]['type'] = 'direct'; echo ''; From 6f55707e731003414edb4aa97b8ec292c4f849c2 Mon Sep 17 00:00:00 2001 From: Calvo Date: Tue, 31 Jan 2023 09:11:03 +0100 Subject: [PATCH 037/182] Fix style --- pandora_server/lib/PandoraFMS/DB.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 7795ffbcea..91f838dfd9 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -653,8 +653,6 @@ sub get_agent_status ($$$) { } } - print "MS ::::::::::::::".Dumper($module_status); - return $module_status; } From a200362ffe4223e3bae63692b36a4964b28d7205 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 31 Jan 2023 09:54:31 +0100 Subject: [PATCH 038/182] Make sure producers always release agent locks. A MySQL error that didn't bring the server down could result in a consumer returning without releasing its agent lock. --- pandora_server/lib/PandoraFMS/DataServer.pm | 38 ++++++++------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 6f16bd4281..ac4364dca1 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -304,21 +304,22 @@ sub data_consumer ($$) { agent_unlock($pa_config, $agent_name); return; } - unlink ($file_name); - if (defined($xml_data->{'server_name'})) { - process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ()); - } elsif (defined($xml_data->{'connection_source'})) { - enterprise_hook('process_xml_connections', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]); - } elsif (defined($xml_data->{'ipam_source'})) { - enterprise_hook('process_xml_ipam', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]); - } elsif (defined($xml_data->{'network_matrix'})){ - process_xml_matrix_network( - $self->getConfig(), $xml_data, $self->getDBH() - ); - } else { - process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ()); - } + + eval { + if (defined($xml_data->{'server_name'})) { + process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ()); + } elsif (defined($xml_data->{'connection_source'})) { + enterprise_hook('process_xml_connections', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]); + } elsif (defined($xml_data->{'ipam_source'})) { + enterprise_hook('process_xml_ipam', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]); + } elsif (defined($xml_data->{'network_matrix'})){ + process_xml_matrix_network( $self->getConfig(), $xml_data, $self->getDBH()); + } else { + process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ()); + } + }; + agent_unlock($pa_config, $agent_name); return; } @@ -1174,15 +1175,6 @@ sub process_xml_matrix_network { sub agent_lock { my ($pa_config, $dbh, $agent_name) = @_; - # Do not lock on LIFO mode if the agent already exist. - # get_agent_id will be called again from process_xml_data, - # so the should be no race conditions if the agent does - # not exist. - if ($pa_config->{'dataserver_lifo'} == 1 && - get_agent_id ($dbh, $agent_name) > 0) { - return 1; - } - $AgentSem->down (); if (defined ($Agents{$agent_name})) { $AgentSem->up (); From 6437460e8381781ad75d8368e3e6f6d004a1e497 Mon Sep 17 00:00:00 2001 From: Calvo Date: Tue, 31 Jan 2023 09:57:55 +0100 Subject: [PATCH 039/182] Fix style --- pandora_server/lib/PandoraFMS/DB.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 91f838dfd9..27ea483870 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -620,11 +620,11 @@ sub get_agent_status ($$$) { elsif ($module_status != 2) { if ($m_status == 3) { $module_status = 3; - } + } elsif ($module_status != 3) { - if ($m_status == 0) { - $module_status = 0; - } + if ($m_status == 0) { + $module_status = 0; + } } } } From c8b1d22c5d28b035c90f8bc9df34434539172a3e Mon Sep 17 00:00:00 2001 From: alejandro Date: Tue, 31 Jan 2023 10:23:42 +0100 Subject: [PATCH 040/182] change parameter --creds_Base64 --- pandora_plugins/google_sheets/pandora_googlesheet.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandora_plugins/google_sheets/pandora_googlesheet.py b/pandora_plugins/google_sheets/pandora_googlesheet.py index d02fc4cd3b..bfa346aa40 100644 --- a/pandora_plugins/google_sheets/pandora_googlesheet.py +++ b/pandora_plugins/google_sheets/pandora_googlesheet.py @@ -21,7 +21,7 @@ Version = {__version__} Manual execution -python3 pandora_googlesheets.py --creds_json/creds_base64 --row --column +python3 pandora_googlesheets.py --creds_json/creds_base64 --name --sheet --cell --row --column """ @@ -47,9 +47,7 @@ if args.creds_json is not None and args.creds_base64 == None: ## authenticate with base64 input elif args.creds_base64 is not None and args.creds_json== None: ## base64 to json - with open(args.creds_base64, 'r') as file: - data = file.read().replace('\n', '') - text=base64.b64decode(data).decode('utf-8') + text=base64.b64decode(args.creds_base64).decode('utf-8') with open("cred.json", "w") as outfile: outfile.write(text) creds = ServiceAccountCredentials.from_json_keyfile_name("cred.json", scope) From d49f1320f53474739a82e711fa07c04fe36a0385 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 31 Jan 2023 12:37:55 +0100 Subject: [PATCH 041/182] #10127 added param 'id_node' in set_validate_events for update from metaconsole --- pandora_console/include/functions_api.php | 47 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 89e764aaaa..11149e86f8 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -11061,20 +11061,55 @@ function api_set_event_validate_filter($trash1, $trash2, $other, $trash3) function api_set_validate_events($id_event, $trash1, $other, $return_type, $user_in_db) { - $text = $other['data']; + $node_int = 0; + if ($other['type'] == 'string') { + returnError('Parameter error.'); + return; + } else if ($other['type'] == 'array') { + $text = $other['data'][0]; + if (is_metaconsole() === true) { + if (isset($other['data'][1]) === true + && empty($other['data'][1]) === false + ) { + $node_int = $other['data'][1]; + } + } + } - // Set off the standby mode when close an event - $event = events_get_event($id_event); - alerts_agent_module_standby($event['id_alert_am'], 0); + try { + if (is_metaconsole() === true + && (int) $node_int > 0 + ) { + $node = new Node($node_int); + $node->connect(); + } - $result = events_change_status($id_event, EVENT_VALIDATE); + // Set off the standby mode when close an event + $event = events_get_event($id_event); + alerts_agent_module_standby($event['id_alert_am'], 0); + $result = events_change_status($id_event, EVENT_VALIDATE); - if ($result) { if (!empty($text)) { // Set the comment for the validation events_comment($id_event, $text); } + } catch (\Exception $e) { + if (is_metaconsole() === true + && $node_int > 0 + ) { + $node->disconnect(); + } + $result = false; + } finally { + if (is_metaconsole() === true + && $node_int > 0 + ) { + $node->disconnect(); + } + } + + if ($result) { returnData( 'string', [ From 407ce7baa0156ee15ab18dbbd743a1330200ffe6 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 31 Jan 2023 13:33:02 +0100 Subject: [PATCH 042/182] #9003 changed command center name to Merging tool --- pandora_console/general/node_deactivated.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/node_deactivated.php b/pandora_console/general/node_deactivated.php index c88f4f599e..ae0e3b8f24 100644 --- a/pandora_console/general/node_deactivated.php +++ b/pandora_console/general/node_deactivated.php @@ -56,7 +56,7 @@ ui_require_css_file('maintenance'); 'Please navigate to %s to unify system', ''.__('command center').'' + ).'" target="_new">'.__('merging tool').'' ); ?>

From a69f3eb0dcc1160ed3a55622d1aeeaf527fddf18 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 1 Feb 2023 10:24:35 +0100 Subject: [PATCH 043/182] minor change --- pandora_console/godmode/setup/file_manager.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandora_console/godmode/setup/file_manager.php b/pandora_console/godmode/setup/file_manager.php index 272eab74f0..f54cf7f7f6 100644 --- a/pandora_console/godmode/setup/file_manager.php +++ b/pandora_console/godmode/setup/file_manager.php @@ -87,8 +87,6 @@ $create_text_file = (bool) get_parameter('create_text_file'); $default_real_directory = realpath($config['homedir'].'/'); -$_FILES['file']['name'] = '../test3.jpeg'; - // Remove double dot in filename path. $file_name = $_FILES['file']['name']; $path_parts = explode('/', $file_name); From f476538170d3d0f52cb66aadbdb8570b80ee5d8c Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 1 Feb 2023 10:27:11 +0100 Subject: [PATCH 044/182] #10282 disable button edit trap in open version --- pandora_console/include/class/SnmpConsole.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php index 9aae307bc5..843973152a 100644 --- a/pandora_console/include/class/SnmpConsole.class.php +++ b/pandora_console/include/class/SnmpConsole.class.php @@ -926,7 +926,10 @@ class SnmpConsole extends HTML 'class' => 'invert_filter', ] ).''; - $tmp->action .= ''.html_print_image('images/edit.png', true, ['alt' => __('SNMP trap editor'), 'title' => __('SNMP trap editor')]).''; + + if ($config['enterprise_installed']) { + $tmp->action .= ''.html_print_image('images/edit.png', true, ['alt' => __('SNMP trap editor'), 'title' => __('SNMP trap editor')]).''; + } $tmp->m = html_print_checkbox_extended('snmptrapid[]', $tmp->id_trap, false, false, '', 'class="chk"', true); From 2b9f7f9b09a3b76310c1bc30a0fa7a5c6458cb99 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 1 Feb 2023 10:47:36 +0100 Subject: [PATCH 045/182] #10267 limit entries in events list --- pandora_console/operation/events/events.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 18c928727a..ba27a38a6e 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2413,8 +2413,6 @@ try { 100, 200, 500, - 1000, - -1, ], [ $config['block_size'], @@ -2423,8 +2421,6 @@ try { 100, 200, 500, - 1000, - 'All', ], ], 'order' => [ From 5a2c5dc0b1ac1c7fc8d59c75993128b03e367224 Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 1 Feb 2023 13:11:38 +0100 Subject: [PATCH 046/182] 10100 deleting if congition and add the exec to update section where config php exist --- pandora_console/pandora_console.rhel7.spec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index e00e498f8b..163613b9d8 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -57,11 +57,6 @@ install -m 0644 pandora_console_logrotate_centos $RPM_BUILD_ROOT%{_sysconfdir}/l rm -rf $RPM_BUILD_ROOT %post -# Upgrading. -if [ "$1" -eq "1" ]; then - echo "Updating the database schema." - /usr/bin/php %{prefix}/pandora_console/godmode/um_client/updateMR.php 2>/dev/null -fi # Install pandora_websocket_engine service. cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/ @@ -76,6 +71,11 @@ echo " /etc/init.d/pandora_websocket_engine start" # if [ -f %{prefix}/pandora_console/include/config.php ] ; then mv %{prefix}/pandora_console/install.php %{prefix}/pandora_console/install.done + + # Upgrading MR. + echo "Updating the database schema." + /usr/bin/php %{prefix}/pandora_console/godmode/um_client/updateMR.php 2>/dev/null + else echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it." fi From c49d021842f607bab3c93d0e7b4784732d330048 Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 1 Feb 2023 16:26:03 +0100 Subject: [PATCH 047/182] 10100 deleting if congition and add the exec to update section where config php exist --- extras/docker/centos8/docker-compose.yml | 2 +- pandora_console/pandora_console.redhat.spec | 5 +++++ pandora_console/pandora_console.spec | 10 +++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/extras/docker/centos8/docker-compose.yml b/extras/docker/centos8/docker-compose.yml index 5ac5385133..887919387c 100644 --- a/extras/docker/centos8/docker-compose.yml +++ b/extras/docker/centos8/docker-compose.yml @@ -17,7 +17,7 @@ services: - pandora pandora: - image: pandorafms/pandorafms-open-stack-el8:latest + image: pandorafms/pandorafms-open-stack-el8:765 restart: always depends_on: - db diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 198054a1b3..ffd33229aa 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -77,6 +77,11 @@ echo " /etc/init.d/pandora_websocket_engine start" # if [ -f %{prefix}/pandora_console/include/config.php ] ; then mv %{prefix}/pandora_console/install.php %{prefix}/pandora_console/install.done + + # Upgrading MR. + echo "Updating the database schema." + /usr/bin/php %{prefix}/pandora_console/godmode/um_client/updateMR.php 2>/dev/null + else echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it." fi diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 932172bce7..707c9a90bd 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -58,11 +58,6 @@ fi rm -rf $RPM_BUILD_ROOT %post -# Upgrading. -if [ "$1" -eq "1" ]; then - echo "Updating the database schema." - /usr/bin/php %{prefix}/pandora_console/godmode/um_client/updateMR.php 2>/dev/null -fi # Install pandora_websocket_engine service. cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/ @@ -77,6 +72,11 @@ echo " /etc/init.d/pandora_websocket_engine start" # if [ -f %{prefix}/pandora_console/include/config.php ] ; then mv %{prefix}/pandora_console/install.php %{prefix}/pandora_console/install.done + + # Upgrading MR. + echo "Updating the database schema." + /usr/bin/php %{prefix}/pandora_console/godmode/um_client/updateMR.php 2>/dev/null + else echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it." fi From 2d938c0b310e43f4d80eeef9df139878621f30c1 Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 1 Feb 2023 17:06:12 +0100 Subject: [PATCH 048/182] 10100 adding dependencie php8 --- extras/docker/centos8/docker-compose.yml | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extras/docker/centos8/docker-compose.yml b/extras/docker/centos8/docker-compose.yml index 887919387c..5ac5385133 100644 --- a/extras/docker/centos8/docker-compose.yml +++ b/extras/docker/centos8/docker-compose.yml @@ -17,7 +17,7 @@ services: - pandora pandora: - image: pandorafms/pandorafms-open-stack-el8:765 + image: pandorafms/pandorafms-open-stack-el8:latest restart: always depends_on: - db diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index ffd33229aa..888063115f 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -26,7 +26,7 @@ BuildRoot: %{_tmppath}/%{name} BuildArch: noarch AutoReq: 0 Requires: %{httpd_name} >= 2.0.0 -Requires: mod_php >= 7.0 +Requires: mod_php >= 8.0 Requires: php-gd, php-ldap, php-snmp, php-session, php-gettext Requires: php-mysqlnd, php-mbstring, php-zip, php-zlib, php-curl Requires: xorg-x11-fonts-75dpi, xorg-x11-fonts-misc, php-pecl-zip diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 707c9a90bd..48491335de 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -29,7 +29,7 @@ BuildArch: noarch AutoReq: 0 Requires: apache2 Requires: apache2-mod_php7 -Requires: php >= 7.0 +Requires: php >= 8.0 Requires: php-gd, php-snmp, php-json, php-gettext Requires: php-mysqlnd, php-ldap, php-mbstring, php Requires: graphviz, xorg-x11-fonts-core, graphviz-gd From e465fb67596758b1c039f34a91f3d70c71574688 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 1 Feb 2023 17:35:56 +0100 Subject: [PATCH 049/182] #9003 changed merging tool for command center in warning --- pandora_console/general/node_deactivated.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/node_deactivated.php b/pandora_console/general/node_deactivated.php index ae0e3b8f24..c88f4f599e 100644 --- a/pandora_console/general/node_deactivated.php +++ b/pandora_console/general/node_deactivated.php @@ -56,7 +56,7 @@ ui_require_css_file('maintenance'); 'Please navigate to %s to unify system', ''.__('merging tool').'' + ).'" target="_new">'.__('command center').'' ); ?>

From 427ab4d058724b83d1ff7e832cc2bea507740773 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 1 Feb 2023 17:51:31 +0100 Subject: [PATCH 050/182] #10277 remove db size in about popup --- pandora_console/include/class/Diagnostics.class.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index a60cb7cf77..b0f698252b 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -659,15 +659,6 @@ class Diagnostics extends Wizard { global $config; - // Size BBDD. - $dbSizeSql = db_get_value_sql( - 'SELECT ROUND(SUM(data_length+index_length)/1024/1024,3) - FROM information_schema.TABLES' - ); - - // Add unit size. - $dbSize = $dbSizeSql.' M'; - $result = [ 'error' => false, 'data' => [ @@ -683,10 +674,6 @@ class Diagnostics extends Wizard 'name' => __('DB Schema Build'), 'value' => $config['db_scheme_build'], ], - 'dbSize' => [ - 'name' => __('DB Size'), - 'value' => $dbSize, - ], ], ]; From b6745696132082d511f8d45175d30f9b6204828c Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 2 Feb 2023 01:01:52 +0100 Subject: [PATCH 051/182] 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 afc54471c1..0c48cf6cc3 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230201 +Version: 7.0NG.768-230202 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 9df0081520..6c8a798ef3 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.768-230201" +pandora_version="7.0NG.768-230202" 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 1e5d84a983..f6c587dc22 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230201'; +use constant AGENT_BUILD => '230202'; # 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 96828c37ca..380839216f 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_linux %define version 7.0NG.768 -%define release 230201 +%define release 230202 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 9962d1576f..2fddf75161 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230201 +%define release 230202 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 452c313796..ad6e29d2a2 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230201" +PI_BUILD="230202" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index cc492132d2..af3fa12867 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230201} +{230202} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index c1e3246ddd..ea47f47d52 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.768 Build 230201") +#define PANDORA_VERSION ("7.0NG.768 Build 230202") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 1992da4f68..3e8e853947 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.768(Build 230201))" + VALUE "ProductVersion", "(7.0NG.768(Build 230202))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 37ab3243c8..a433d8e8ae 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230201 +Version: 7.0NG.768-230202 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 5045deaedf..7a0c09cd88 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.768-230201" +pandora_version="7.0NG.768-230202" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index e2813badfe..b327c883ee 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 = 'PC230201'; +$build_version = 'PC230202'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 3d2b1aba3d..2bd2ffef03 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index ae87851c3b..dde1cc0de3 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.768 -%define release 230201 +%define release 230202 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c699e6db1c..0a434f2607 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.768 -%define release 230201 +%define release 230202 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index b7b7a9b348..ba1f58d122 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230201" +PI_BUILD="230202" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 8719a2cf50..f0437a5bfb 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230201"; +my $version = "7.0NG.768 Build 230202"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 687ff7dff9..6af8cbfe5e 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.768 Build 230201"; +my $version = "7.0NG.768 Build 230202"; # save program name for logging my $progname = basename($0); From 73feccad14887abb22a2c3cf6a7da6f733067df4 Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 2 Feb 2023 09:54:43 +0100 Subject: [PATCH 052/182] fixed help in plugin, and added check for all dependencys --- tentacle/tentacle_server_installer | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tentacle/tentacle_server_installer b/tentacle/tentacle_server_installer index 176a4743e5..562c4eea88 100755 --- a/tentacle/tentacle_server_installer +++ b/tentacle/tentacle_server_installer @@ -188,6 +188,16 @@ install () { execute_cmd "ps --version" 'Checking dependencies: ps' "Error ps not found, please install procps" execute_cmd "sudo --version" 'Checking dependencies: sudo' "Error sudo not found, please install sudo" execute_cmd "perl -MIO::Compress::Zip -le 'pass'" 'Checking dependencies: perl IO::Compress' "Error perl IO::Compress not found, please install perl IO::Compress" + + execute_cmd "perl -MGetopt::Std -le 'pass'" 'Checking dependencies: perl Getopt::Std' "Error perl IO::Compress not found, please install perl Getopt::Std" + execute_cmd "perl -MIO::Select -le 'pass'" 'Checking dependencies: perl IO::Select' "Error perl IO::Select not found, please install perl IO::Select" + execute_cmd "perl -MIO::Uncompress::Unzip -le 'pass'" 'Checking dependencies: perl IO::Uncompress::Unzip' "Error perl IO::Uncompress::Unzip not found, please install perl IO::Uncompress::Unzip" + execute_cmd "perl -Mthreads -le 'pass'" 'Checking dependencies: perl threads' "Error perl IO::Compress not found, please install perl threads" + execute_cmd "perl -MThread::Semaphore -le 'pass'" 'Checking dependencies: perl Thread::Semaphore' "Error perl Thread::Semaphore, please install perl Thread::Semaphore" + + execute_cmd "perl -MPOSIX -le 'pass'" 'Checking dependencies: perl POSIX' "Error perl POSIX not found, please install perl POSIX" + execute_cmd "perl -MTime::HiRes -le 'pass'" 'Checking dependencies: perl Time::HiRes' "Error perl Time::HiRes not found, please install perl Time::HiRes" + execute_cmd "perl -MScalar::Util -le 'pass'" 'Checking dependencies: perl Scalar::Util' "Error perl Scalar::Util not found, please install perl Scalar::Util" fi # install tentacle @@ -351,8 +361,8 @@ uninstall () { } help () { - echo " --install To install Pandora FMS Servers on this system (You have to be root)" - echo " --uninstall To uninstall and remove Pandora FMS Servers on this System" + echo " --install To install Tentacle Server on this system (You have to be root)" + echo " --uninstall To uninstall and remove Tentacle Server on this System" echo " " echo " Additional second parameter (after --install) " echo " " @@ -401,4 +411,3 @@ case "$MODE" in *) help esac - From 18f2cee2a7698e6b6e4624d72d14400109eea0ce Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 2 Feb 2023 11:18:47 +0100 Subject: [PATCH 053/182] #10283 fixed filter design in snmp console --- .../include/class/SnmpConsole.class.php | 105 +++++++++--------- pandora_console/include/styles/tables.css | 22 +++- 2 files changed, 74 insertions(+), 53 deletions(-) diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php index 9aae307bc5..96553d2ac4 100644 --- a/pandora_console/include/class/SnmpConsole.class.php +++ b/pandora_console/include/class/SnmpConsole.class.php @@ -413,73 +413,74 @@ class SnmpConsole extends HTML 'class' => 'flex-row', 'inputs' => [ [ - 'label' => __('Alert'), - 'type' => 'select', - 'id' => 'filter_alert', - 'name' => 'filter_alert', - 'class' => 'w200px', - 'fields' => $show_alerts, - 'return' => true, - 'selected' => $this->filter_alert, + 'label' => __('Alert'), + 'type' => 'select', + 'id' => 'filter_alert', + 'input_class' => 'filter_input_datatable', + 'name' => 'filter_alert', + 'fields' => $show_alerts, + 'return' => true, + 'selected' => $this->filter_alert, ], [ - 'label' => __('Severity'), - 'type' => 'select', - 'id' => 'filter_severity', - 'name' => 'filter_severity', - 'class' => 'w200px', - 'fields' => $severities, - 'return' => true, - 'selected' => $this->filter_severity, + 'label' => __('Severity'), + 'type' => 'select', + 'id' => 'filter_severity', + 'input_class' => 'filter_input_datatable', + 'name' => 'filter_severity', + 'fields' => $severities, + 'return' => true, + 'selected' => $this->filter_severity, ], [ - 'label' => __('Free search'), - 'type' => 'text', - 'class' => 'w400px', - 'id' => 'filter_free_search', - 'name' => 'filter_free_search', - 'value' => $this->filter_free_search, + 'label' => __('Free search'), + 'type' => 'text', + 'id' => 'filter_free_search', + 'input_class' => 'filter_input_datatable', + 'name' => 'filter_free_search', + 'value' => $this->filter_free_search, ], [ - 'label' => __('Status'), - 'type' => 'select', - 'id' => 'filter_status', - 'name' => 'filter_status', - 'class' => 'w200px', - 'fields' => $status_array, - 'return' => true, - 'selected' => $this->filter_status, + 'label' => __('Status'), + 'type' => 'select', + 'id' => 'filter_status', + 'input_class' => 'filter_input_datatable', + 'name' => 'filter_status', + 'fields' => $status_array, + 'return' => true, + 'selected' => $this->filter_status, ], [ - 'label' => __('Group by Enterprise String/IP'), - 'type' => 'select', - 'name' => 'filter_group_by', - 'selected' => $this->filter_group_by, - 'disabled' => false, - 'return' => true, - 'id' => 'filter_group_by', - 'fields' => [ + 'label' => __('Group by Enterprise String/IP'), + 'type' => 'select', + 'name' => 'filter_group_by', + 'selected' => $this->filter_group_by, + 'disabled' => false, + 'return' => true, + 'id' => 'filter_group_by', + 'input_class' => 'filter_input_datatable', + 'fields' => [ 0 => __('No'), 1 => __('Yes'), ], ], [ - 'label' => __('Max. hours old'), - 'type' => 'text', - 'class' => 'w200px', - 'id' => 'filter_hours_ago', - 'name' => 'filter_hours_ago', - 'value' => $this->filter_hours_ago, + 'label' => __('Max. hours old'), + 'type' => 'text', + 'id' => 'filter_hours_ago', + 'input_class' => 'filter_input_datatable', + 'name' => 'filter_hours_ago', + 'value' => $this->filter_hours_ago, ], [ - 'label' => __('Trap type'), - 'type' => 'select', - 'id' => 'filter_trap_type', - 'name' => 'filter_trap_type', - 'class' => 'w200px', - 'fields' => $trap_types, - 'return' => true, - 'selected' => $this->filter_trap_type, + 'label' => __('Trap type'), + 'type' => 'select', + 'id' => 'filter_trap_type', + 'input_class' => 'filter_input_datatable', + 'name' => 'filter_trap_type', + 'fields' => $trap_types, + 'return' => true, + 'selected' => $this->filter_trap_type, ], ], ], diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index 40ecaf11ba..fca924b6e0 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -323,6 +323,25 @@ a.pandora_pagination.current:hover { cursor: default; } +.filter_input_datatable { + width: 45% !important; + display: flex; + flex-wrap: nowrap; + flex-direction: row; + max-width: 450px; + min-width: 400px; +} +.filter_input_datatable input { + flex: 1; +} +.filter_input_datatable label { + width: 93px; + max-width: 100%; +} +.filter_input_datatable .select2.select2-container { + flex: 1; +} + /* Default datatable filter style */ .datatable_filter.content { display: flex; @@ -336,7 +355,8 @@ a.pandora_pagination.current:hover { } .datatable_filter.content li { flex: 1 1 auto; - margin: 1em auto; + margin: 1em 0; + padding: 0px 10px; } .sorting_desc { background: url(../../images/sort_down_green.png) no-repeat; From c9ea46e219f58da0df3eacbec1b89933add280f0 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 2 Feb 2023 11:25:59 +0100 Subject: [PATCH 054/182] #10283 align left input only in datatable_filter --- pandora_console/include/styles/tables.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index fca924b6e0..30592ed6db 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -341,7 +341,9 @@ a.pandora_pagination.current:hover { .filter_input_datatable .select2.select2-container { flex: 1; } - +.datatable_filter.content li.filter_input_datatable { + margin: 1em 0; +} /* Default datatable filter style */ .datatable_filter.content { display: flex; @@ -355,7 +357,7 @@ a.pandora_pagination.current:hover { } .datatable_filter.content li { flex: 1 1 auto; - margin: 1em 0; + margin: 1em auto; padding: 0px 10px; } .sorting_desc { From 90790a83ce236fb03535ba2dbd617c604a845cff Mon Sep 17 00:00:00 2001 From: rafael Date: Thu, 2 Feb 2023 11:34:23 +0100 Subject: [PATCH 055/182] 10100 adding dependencie php8 --- pandora_console/pandora_console.redhat.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 888063115f..368922bfc3 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -26,7 +26,7 @@ BuildRoot: %{_tmppath}/%{name} BuildArch: noarch AutoReq: 0 Requires: %{httpd_name} >= 2.0.0 -Requires: mod_php >= 8.0 +Requires: php >= 8.0 Requires: php-gd, php-ldap, php-snmp, php-session, php-gettext Requires: php-mysqlnd, php-mbstring, php-zip, php-zlib, php-curl Requires: xorg-x11-fonts-75dpi, xorg-x11-fonts-misc, php-pecl-zip From 5106e658c362e9599dfa2ecbc292385f20245e44 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 2 Feb 2023 11:49:09 +0100 Subject: [PATCH 056/182] Improve pandora_server_tasks. * Do not let pandora_server_tasks die. * Remove a query from self_monitoring that could freeze the pandora_server_tasks thread. --- pandora_server/bin/pandora_server | 180 +++++++++++++------------- pandora_server/lib/PandoraFMS/Core.pm | 11 -- 2 files changed, 91 insertions(+), 100 deletions(-) diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index fd8fa0d99d..1f6d17af49 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -387,112 +387,114 @@ sub pandora_server_tasks ($) { my $counter = 0; my $first_run = 1; while ($THRRUN == 1) { - if (pandora_is_master($pa_config) == 1) { + eval { + if (pandora_is_master($pa_config) == 1) { - # TASKS EXECUTED ONCE - # ------------------- - if ($first_run == 1) { - $first_run = 0; + # TASKS EXECUTED ONCE + # ------------------- + if ($first_run == 1) { + $first_run = 0; - # Update the agent cache. - enterprise_hook('update_agent_cache', [\%Config]); - } - - # TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks) - # -------------------------------------------------- - if (($counter % 5) == 0) { - - # Update forced alerts - pandora_exec_forced_alerts ($pa_config, $dbh); - - my @agents = get_db_rows ($dbh, 'SELECT id_agente, update_alert_count FROM tagente WHERE update_alert_count=1'); - foreach my $agent (@agents) { - if ($agent->{'update_alert_count'} == 1) { - pandora_update_agent_alert_count ($pa_config, $dbh, $agent->{'id_agente'}); - } + # Update the agent cache. + enterprise_hook('update_agent_cache', [\%Config]); } - } - # TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks) - # --------------------------------------------------- - if (($counter % 30) == 0) { + # TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks) + # -------------------------------------------------- + if (($counter % 5) == 0) { - # Update module status and fired alert counts - my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_secondary_groups FROM tagente WHERE (update_module_count=1 OR update_secondary_groups=1)'); - foreach my $agent (@agents) { - logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); + # Update forced alerts + pandora_exec_forced_alerts ($pa_config, $dbh); - if ($agent->{'update_module_count'} == 1) { - pandora_update_agent_module_count ($pa_config, $dbh, $agent->{'id_agente'}); - } - - if ($agent->{'update_secondary_groups'} == 1) { - pandora_update_secondary_groups_cache ($pa_config, $dbh, $agent->{'id_agente'}); + my @agents = get_db_rows ($dbh, 'SELECT id_agente, update_alert_count FROM tagente WHERE update_alert_count=1'); + foreach my $agent (@agents) { + if ($agent->{'update_alert_count'} == 1) { + pandora_update_agent_alert_count ($pa_config, $dbh, $agent->{'id_agente'}); + } } } - # Keepalive module control.(very DB intensive, not run frecuently - pandora_module_keep_alive_nd ($pa_config, $dbh); - - # Set the status of unknown modules - pandora_module_unknown ($pa_config, $dbh); - - # Check if an autodisabled agent needs to be autodisable - pandora_disable_autodisable_agents ($pa_config, $dbh); - } - - # TASKS EXECUTED EVERY 60 SECONDS (High latency tasks) - # ---------------------------------------------------- - if (($counter % 60) == 0) { - # Downtimes are executed only 30 x Server Threshold secs - pandora_planned_downtime ($pa_config, $dbh); - - # Realtime stats (Only master server!) - ( VERY HEAVY !) - # Realtimestats == 1, generated by WEB Console, not by server! - if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){ + # TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks) + # --------------------------------------------------- + if (($counter % 30) == 0) { + + # Update module status and fired alert counts + my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_secondary_groups FROM tagente WHERE (update_module_count=1 OR update_secondary_groups=1)'); + foreach my $agent (@agents) { + logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); + + if ($agent->{'update_module_count'} == 1) { + pandora_update_agent_module_count ($pa_config, $dbh, $agent->{'id_agente'}); + } + + if ($agent->{'update_secondary_groups'} == 1) { + pandora_update_secondary_groups_cache ($pa_config, $dbh, $agent->{'id_agente'}); + } + } + + # Keepalive module control.(very DB intensive, not run frecuently + pandora_module_keep_alive_nd ($pa_config, $dbh); - # Check if I need to refresh stats - my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat"); - if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){ - pandora_group_statistics ($pa_config, $dbh); - pandora_server_statistics ($pa_config, $dbh); - } + # Set the status of unknown modules + pandora_module_unknown ($pa_config, $dbh); + + # Check if an autodisabled agent needs to be autodisable + pandora_disable_autodisable_agents ($pa_config, $dbh); } - # Check if snmptrapd is freeze. - pandora_snmptrapd_still_working ($pa_config, $dbh); + # TASKS EXECUTED EVERY 60 SECONDS (High latency tasks) + # ---------------------------------------------------- + if (($counter % 60) == 0) { + # Downtimes are executed only 30 x Server Threshold secs + pandora_planned_downtime ($pa_config, $dbh); + + # Realtime stats (Only master server!) - ( VERY HEAVY !) + # Realtimestats == 1, generated by WEB Console, not by server! + if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){ + + # Check if I need to refresh stats + my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat"); + if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){ + pandora_group_statistics ($pa_config, $dbh); + pandora_server_statistics ($pa_config, $dbh); + } + } + + # Check if snmptrapd is freeze. + pandora_snmptrapd_still_working ($pa_config, $dbh); - # Event auto-expiry - my $expiry_time = $pa_config->{"event_expiry_time"}; - my $expiry_window = $pa_config->{"event_expiry_window"}; - if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) { - my $time_ref = time (); - my $expiry_limit = $time_ref - $expiry_time; - my $expiry_window = $time_ref - $expiry_window; - db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window); + # Event auto-expiry + my $expiry_time = $pa_config->{"event_expiry_time"}; + my $expiry_window = $pa_config->{"event_expiry_window"}; + if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) { + my $time_ref = time (); + my $expiry_limit = $time_ref - $expiry_time; + my $expiry_window = $time_ref - $expiry_window; + db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window); + } } } - } - # COMMON TASKS (master and non-master) - # --------------------------------------------------------------- - if (($counter % 30) == 0) { - # Update configuration options from the console. - pandora_get_sharedconfig ($pa_config, $dbh); + # COMMON TASKS (master and non-master) + # --------------------------------------------------------------- + if (($counter % 30) == 0) { + # Update configuration options from the console. + pandora_get_sharedconfig ($pa_config, $dbh); - # Rotate the log file. - pandora_rotate_logfile($pa_config); - - # Set event storm protection - pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); - } - # Pandora self monitoring - if (defined($pa_config->{"self_monitoring"}) - && $pa_config->{"self_monitoring"} == 1 - && !is_metaconsole($pa_config) - && $counter % $pa_config->{'self_monitoring_interval'} == 0) { - pandora_self_monitoring ($pa_config, $dbh); - } + # Rotate the log file. + pandora_rotate_logfile($pa_config); + + # Set event storm protection + pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); + } + # Pandora self monitoring + if (defined($pa_config->{"self_monitoring"}) + && $pa_config->{"self_monitoring"} == 1 + && !is_metaconsole($pa_config) + && $counter % $pa_config->{'self_monitoring_interval'} == 0) { + pandora_self_monitoring ($pa_config, $dbh); + } + }; # Avoid counter overflow if ($counter >= ~0){ diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index b2ea690cfa..89e283a64e 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -6005,10 +6005,6 @@ sub pandora_self_monitoring ($$) { $pandoradb = 1; } - my $start_performance = time; - get_db_value($dbh, "SELECT COUNT(*) FROM tagente_datos"); - my $read_speed = int((time - $start_performance) * 1e6); - my $elasticsearch_perfomance = enterprise_hook("elasticsearch_performance", [$pa_config, $dbh]); $xml_output .= $elasticsearch_perfomance if defined($elasticsearch_perfomance); @@ -6055,13 +6051,6 @@ sub pandora_self_monitoring ($$) { $xml_output .=" "; } - $xml_output .=" "; - $xml_output .=" Execution_Time"; - $xml_output .=" generic_data"; - $xml_output .=" us"; - $xml_output .=" $read_speed"; - $xml_output .=" "; - $xml_output .= ""; my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".self.".$utimestamp.".data"; From 925880dbdbe1bd0b31859700975977909aabd5cc Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 2 Feb 2023 17:06:28 +0100 Subject: [PATCH 057/182] #9523 dialog title plugins --- pandora_console/godmode/servers/plugin.php | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 5a0d8a063a..b6d78e1d98 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -892,7 +892,7 @@ if (($create != '') || ($view != '')) { echo ''; diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index d2fc5698a6..2153686774 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -130,7 +130,7 @@ function execute_response(event_id, server_id) { jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: getUrlAjax(), dataType: "json", success: function(response) { // If cannot get response abort it @@ -161,7 +161,7 @@ function execute_response_massive(events, response_id, response_parameters) { jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: getUrlAjax(), dataType: "json", success: function(data) { // If cannot get response abort it @@ -211,7 +211,7 @@ function execute_response_massive(events, response_id, response_parameters) { jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: getUrlAjax(), dataType: "html", success: function(data) { $(".container-massive-events-response").append(data); @@ -248,13 +248,21 @@ function show_response_dialog(response_id, response) { params.push({ name: "server_id", value: response.server_id }); params.push({ name: "response", value: JSON.stringify(response) }); + var view = ``; + + if ($("#event_response_window").length) { + view = "#event_response_window"; + } else if ($("#sound_event_response_window").length) { + view = "#sound_event_response_window"; + } + jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: getUrlAjax(), dataType: "html", success: function(data) { - $("#event_response_window") + $(view) .hide() .empty() .append(data) @@ -300,7 +308,7 @@ function perform_response(response, response_id, index) { jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: getUrlAjax(), dataType: "html", success: function(data) { var out = data.replace(/[\n|\r]/g, "
"); @@ -320,8 +328,6 @@ function event_change_status(event_ids, server_id) { $("#button-status_button").attr("disabled", "disabled"); $("#response_loading").show(); - var url = getUrlAjax(); - jQuery.ajax({ data: { page: "include/ajax/events", @@ -331,7 +337,7 @@ function event_change_status(event_ids, server_id) { server_id: server_id }, type: "POST", - url: url, + url: getUrlAjax(), dataType: "json", success: function(data) { $("#button-status_button").removeAttr("disabled"); @@ -384,8 +390,6 @@ function event_change_status(event_ids, server_id) { // Change te owner of an event to one user of empty function event_change_owner(event_id, server_id) { - var url = getUrlAjax(); - var new_owner = $("#id_owner").val(); $("#button-owner_button").attr("disabled", "disabled"); @@ -400,7 +404,7 @@ function event_change_owner(event_id, server_id) { new_owner: new_owner }, type: "POST", - url: url, + url: getUrlAjax(), async: true, dataType: "html", success: function(data) { @@ -474,11 +478,11 @@ function event_comment(current_event) { $("#button-comment_button").attr("disabled", "disabled"); $("#response_loading").show(); - var url = getUrlAjax(); + jQuery.ajax({ data: params.join("&"), type: "POST", - url: url, + url: getUrlAjax(), dataType: "html", success: function() { $("#button-comment_button").removeAttr("disabled"); @@ -499,11 +503,11 @@ function update_event(table, id_evento, type, event_rep, row, server_id) { values[this.name] = $(this).val(); }); var t1 = new Date(); - var url = getUrlAjax(); + $.ajax({ async: true, type: "POST", - url: url, + url: getUrlAjax(), data: { page: "include/ajax/events", validate_event: type.validate_event, @@ -794,7 +798,7 @@ function show_response_dialog_massive(response_id, response_parameters) { jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: getUrlAjax(), dataType: "json", success: function(response) { // If cannot get response abort it @@ -932,7 +936,7 @@ function process_buffers(buffers) { jQuery.ajax({ data: params.join("&"), type: "POST", - url: $("#hidden-ajax_file").val(), + url: getUrlAjax(), async: true, dataType: "html", success: function(data) { @@ -1204,10 +1208,12 @@ function table_info_response_event(response_id, event_id, server_id, massive) { params.push({ name: "server_id", value: server_id }); params.push({ name: "event_id", value: event_id }); + var url = getUrlAjax(); + jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: url, dataType: "json", success: function(response) { if (response) { @@ -1220,7 +1226,7 @@ function table_info_response_event(response_id, event_id, server_id, massive) { jQuery.ajax({ data: params, type: "POST", - url: $("#hidden-ajax_file").val(), + url: url, dataType: "html", success: function(output) { if (massive === true) { From f845cc94787a8cda7aadef2a1c0d64ba008e533a Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 8 Feb 2023 01:01:58 +0100 Subject: [PATCH 091/182] 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 41c4d14609..fe5bad7109 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230207 +Version: 7.0NG.768-230208 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 8356fb5e9a..38f99a713f 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.768-230207" +pandora_version="7.0NG.768-230208" 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 8b85b2f4f8..f01ddb5744 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230207'; +use constant AGENT_BUILD => '230208'; # 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 6fd83ca74f..c1b7aa663a 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_linux %define version 7.0NG.768 -%define release 230207 +%define release 230208 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 339dd209ba..962b9077ba 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230207 +%define release 230208 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 1a412689bb..a6a9b0271b 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230207" +PI_BUILD="230208" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 8488ced2e5..4f5de91e58 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230207} +{230208} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index b5110d1f98..304f3a22f8 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.768 Build 230207") +#define PANDORA_VERSION ("7.0NG.768 Build 230208") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 075e64c86e..030041571c 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.768(Build 230207))" + VALUE "ProductVersion", "(7.0NG.768(Build 230208))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index a56cde214b..807a36e537 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230207 +Version: 7.0NG.768-230208 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 15b27b4dff..6ff898257a 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.768-230207" +pandora_version="7.0NG.768-230208" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index e3ab2c4a2a..1777d0bb57 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 = 'PC230207'; +$build_version = 'PC230208'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 89d4d17655..064cf37935 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 02ff4577ac..fff8104658 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.768 -%define release 230207 +%define release 230208 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index ae0f408b01..7b79bbbd4c 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.768 -%define release 230207 +%define release 230208 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index ed97ed63d9..3696050dea 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230207" +PI_BUILD="230208" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 887f138e91..cb45ea6415 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230207"; +my $version = "7.0NG.768 Build 230208"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 55eb14fda9..f3346387d2 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.768 Build 230207"; +my $version = "7.0NG.768 Build 230208"; # save program name for logging my $progname = basename($0); From fc7673f6516d1445f361eeb6562ae8db57c77023 Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 8 Feb 2023 14:59:24 +0100 Subject: [PATCH 092/182] 10242 adding scripts for external databases --- .../deploy-scripts/deploy_ext_database_el8.sh | 320 ++++++++++++++++++ .../deploy_ext_database_ubuntu_2204.sh | 257 ++++++++++++++ 2 files changed, 577 insertions(+) create mode 100644 extras/deploy-scripts/deploy_ext_database_el8.sh create mode 100644 extras/deploy-scripts/deploy_ext_database_ubuntu_2204.sh diff --git a/extras/deploy-scripts/deploy_ext_database_el8.sh b/extras/deploy-scripts/deploy_ext_database_el8.sh new file mode 100644 index 0000000000..422887b0e2 --- /dev/null +++ b/extras/deploy-scripts/deploy_ext_database_el8.sh @@ -0,0 +1,320 @@ +#!/bin/bash +####################################################### +# PandoraFMS Community online installation script +####################################################### +## Tested versions ## +# Centos 8.4, 8.5 +# Rocky 8.4, 8.5, 8.6, 8.7 +# Almalinuz 8.4, 8.5 +# RedHat 8.5 + +#Constants +S_VERSION='202302081' +LOGFILE="/tmp/deploy-ext-db-$(date +%F).log" + + +# define default variables +[ "$TZ" ] || TZ="Europe/Madrid" +[ "$MYVER" ] || MYVER=57 +[ "$DBHOST" ] || DBHOST=127.0.0.1 +[ "$DBNAME" ] || DBNAME=pandora +[ "$DBUSER" ] || DBUSER=pandora +[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPORT" ] || DBPORT=3306 +[ "$DBROOTUSER" ] || DBROOTUSER=root +[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 +[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 +[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") + +# Ansi color code variables +red="\e[0;91m" +green="\e[0;92m" +cyan="\e[0;36m" +reset="\e[0m" + +# Functions +execute_cmd () { + local cmd="$1" + local msg="$2" + + echo -e "${cyan}$msg...${reset}" + $cmd &>> "$LOGFILE" + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$3" ] && echo "$3" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$HOME"/pandora_deploy_tmp &>> "$LOGFILE" + exit 1 + else + echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}" + return 0 + fi +} + +check_cmd_status () { + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$1" ] && echo "$1" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE" + exit 1 + else + echo -e "${green}OK${reset}" + return 0 + fi +} + +check_root_permissions () { + echo -en "${cyan}Checking root account... ${reset}" + if [ "$(whoami)" != "root" ]; then + echo -e "${red}Fail${reset}" + echo "Please use a root account or sudo for installing Pandora FMS" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + exit 1 + + else + echo -e "${green}OK${reset}" + fi +} + +## Main +echo "Starting PandoraFMS External DB deployment EL8 ver. $S_VERSION" + +# Centos Version +if [ ! "$(grep -Ei 'centos|rocky|Almalinux|Red Hat Enterprise' /etc/redhat-release)" ]; then + printf "\n ${red}Error this is not a Centos/Rocky/Almalinux Base system, this installer is compatible with RHEL/Almalinux/Centos/Rockylinux systems only${reset}\n" + exit 1 +fi + + +echo -en "${cyan}Check Centos Version...${reset}" +[ $(sed -nr 's/VERSION_ID+=\s*"([0-9]).*"$/\1/p' /etc/os-release) -eq '8' ] +check_cmd_status 'Error OS version, RHEL/Almalinux/Centos/Rockylinux 8+ is expected' + +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" + +# initialice logfile +execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE" +echo "Community installer version: $S_VERSION" >> "$LOGFILE" + +# Pre checks +# Root permisions +check_root_permissions + +# Systemd +execute_cmd "systemctl status" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8' + +# Check memomry greather or equal to 2G +execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)' + +# Check disk size at least 10 Gb free space +execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)' + +# Setting timezone +rm -rf /etc/localtime &>> "$LOGFILE" +execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ" + +# Execute tools check +execute_cmd "awk --version" 'Checking needed tools: awk' +execute_cmd "grep --version" 'Checking needed tools: grep' +execute_cmd "sed --version" 'Checking needed tools: sed' +execute_cmd "dnf --version" 'Checking needed tools: dnf' + +# Creating working directory +rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE" +mkdir "$HOME"/pandora_deploy_tmp &>> "$LOGFILE" +execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_deploy_tmp" + +## Extra steps on redhat envs +if [ "$(grep -Ei 'Red Hat Enterprise' /etc/redhat-release)" ]; then + ## In case REDHAT + # Check susbscription manager status: + echo -en "${cyan}Checking Red Hat Enterprise subscription... ${reset}" + subscription-manager list &>> "$LOGFILE" + subscription-manager status &>> "$LOGFILE" + check_cmd_status 'Error checking subscription status, make sure your server is activated and suscribed to Red Hat Enterprise repositories' + + # Ckeck repolist + dnf repolist &>> "$LOGFILE" + echo -en "${cyan}Checking Red Hat Enterprise repolist... ${reset}" + dnf repolist | grep 'rhel-8-for-x86_64-baseos-rpms' &>> "$LOGFILE" + check_cmd_status 'Error checking repositories status, could try a subscription-manager attach command or contact sysadmin' + + #install extra repos + extra_repos=" \ + tar \ + dnf-utils \ + https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ + https://repo.percona.com/yum/percona-release-latest.noarch.rpm" + + execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" + execute_cmd "subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms" "Enabling subscription to codeready-builder" +else + # For alma/rocky/centos + extra_repos=" \ + tar \ + dnf-utils \ + epel-release \ + https://repo.percona.com/yum/percona-release-latest.noarch.rpm" + + execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" + execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools" +fi + + +#Installing wget +execute_cmd "dnf install -y wget" "Installing wget" + + +# Install percona Database +execute_cmd "dnf module disable -y mysql" "Disabiling mysql module" + +if [ "$MYVER" -eq '80' ] ; then + execute_cmd "percona-release setup ps80 -y" "Enabling mysql80 module" + execute_cmd "dnf install -y percona-server-server percona-xtrabackup-24" "Installing Percona Server 80" +fi + +if [ "$MYVER" -ne '80' ] ; then + execute_cmd "dnf install -y Percona-Server-server-57 percona-xtrabackup-24" "Installing Percona Server 57" +fi + +# Disabling SELINUX and firewalld +setenforce 0 &>> "$LOGFILE" +sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config &>> "$LOGFILE" +systemctl disable firewalld --now &>> "$LOGFILE" + +# Adding standar cnf for initial setup. +cat > /etc/my.cnf << EO_CONFIG_TMP +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +symbolic-links=0 +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid +EO_CONFIG_TMP + +#Configuring Database +if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then + execute_cmd "systemctl start mysqld" "Starting database engine" + export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev) + if [ "$MYVER" -eq '80' ] ; then + echo """ + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = 'Pandor4!'; + UNINSTALL COMPONENT 'file://component_validate_password'; + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = '$DBROOTPASS'; + """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE" + fi + + if [ "$MYVER" -ne '80' ] ; then + echo """ + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('Pandor4!'); + UNINSTALL PLUGIN validate_password; + SET PASSWORD FOR '$DBROOTUSER'@'localhost' = PASSWORD('$DBROOTPASS'); + """ | mysql --connect-expired-password -u$DBROOTUSER &>> "$LOGFILE"fi + fi + + export MYSQL_PWD=$DBROOTPASS + echo -en "${cyan}Creating Pandora FMS database...${reset}" + echo "create database $DBNAME" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support." + + echo "CREATE USER \"$DBUSER\"@'%' IDENTIFIED BY \"$DBPASS\";" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -u$DBROOTUSER -P$DBPORT -h$DBHOST + +#Generating my.cnf +cat > /etc/my.cnf << EO_CONFIG_F +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +user=mysql +character-set-server=utf8 +skip-character-set-client-handshake +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 +# Mysql optimizations for Pandora FMS +# Please check the documentation in http://pandorafms.com for better results + +max_allowed_packet = 64M +innodb_buffer_pool_size = $POOL_SIZE +innodb_lock_wait_timeout = 90 +innodb_file_per_table +innodb_flush_log_at_trx_commit = 0 +innodb_flush_method = O_DIRECT +innodb_log_file_size = 64M +innodb_log_buffer_size = 16M +innodb_io_capacity = 100 +thread_cache_size = 8 +thread_stack = 256K +max_connections = 100 + +key_buffer_size=4M +read_buffer_size=128K +read_rnd_buffer_size=128K +sort_buffer_size=128K +join_buffer_size=4M + +query_cache_type = 1 +query_cache_size = 64M +query_cache_min_res_unit = 2k +query_cache_limit = 256K + +#skip-log-bin + +sql_mode="" + +[mysqld_safe] +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid + +EO_CONFIG_F + + if [ "$MYVER" -eq '80' ] ; then + sed -i -e "/query_cache.*/ s/^#*/#/g" /etc/my.cnf + sed -i -e "s/#skip-log-bin/skip-log-bin/g" /etc/my.cnf + fi + + execute_cmd "systemctl restart mysqld" "Configuring database engine" + execute_cmd "systemctl enable mysqld --now" "Enabling Database service" +fi +export MYSQL_PWD=$DBPASS + + +# Kernel optimization + +if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then +cat >> /etc/sysctl.conf < /dev/null # remove last log before start + +# define default variables +[ "$TZ" ] || TZ="Europe/Madrid" +[ "$DBHOST" ] || DBHOST=127.0.0.1 +[ "$DBNAME" ] || DBNAME=pandora +[ "$DBUSER" ] || DBUSER=pandora +[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPORT" ] || DBPORT=3306 +[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 +[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 +[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") + + +# Ansi color code variables +red="\e[0;91m" +green="\e[0;92m" +cyan="\e[0;36m" +reset="\e[0m" + +# Functions + +execute_cmd () { + local cmd="$1" + local msg="$2" + + echo -e "${cyan}$msg...${reset}" + $cmd &>> "$LOGFILE" + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$3" ] && echo "$3" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$WORKDIR" &>> "$LOGFILE" + exit 1 + else + echo -e "\e[1A\e ${cyan}$msg...${reset} ${green}OK${reset}" + return 0 + fi +} + +check_cmd_status () { + if [ $? -ne 0 ]; then + echo -e "${red}Fail${reset}" + [ "$1" ] && echo "$1" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + rm -rf "$WORKDIR" &>> "$LOGFILE" + exit 1 + else + echo -e "${green}OK${reset}" + return 0 + fi +} + +check_root_permissions () { + echo -en "${cyan}Checking root account... ${reset}" + if [ "$(whoami)" != "root" ]; then + echo -e "${red}Fail${reset}" + echo "Please use a root account or sudo for installing Pandora FMS" + echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" + exit 1 + + else + echo -e "${green}OK${reset}" + fi +} + +## Main +echo "Starting PandoraFMS External DB deployment Ubuntu 22.04 ver. $S_VERSION" + +# Ubuntu Version +if [ ! "$(grep -Ei 'Ubuntu' /etc/lsb-release)" ]; then + printf "\n ${red}Error this is not a Ubuntu system, this installer is compatible with Ubuntu systems only${reset}\n" + exit 1 +fi + + +echo -en "${cyan}Check Ubuntu Version...${reset}" +[ $(sed -nr 's/VERSION_ID+=\s*"([0-9][0-9].[0-9][0-9])"$/\1/p' /etc/os-release) == "22.04" ] +check_cmd_status 'Error OS version, Ubuntu 22.04 is expected' + +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" + +# initialice logfile +execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE" +echo "Community installer version: $S_VERSION" >> "$LOGFILE" + +# Pre checks +# Root permisions +check_root_permissions + +#Install awk, sed, grep if not present +execute_cmd "apt install -y gawk sed grep" 'Installing needed tools' + +# Systemd +execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8' + +# Check memomry greather or equal to 2G +execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" 'Checking memory (required: 2 GB)' + +# Check disk size at least 10 Gb free space +execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)' + +# Setting timezone +rm -rf /etc/localtime &>> "$LOGFILE" +execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ" + +# Execute tools check +execute_cmd "awk --version" 'Checking needed tools: awk' +execute_cmd "grep --version" 'Checking needed tools: grep' +execute_cmd "sed --version" 'Checking needed tools: sed' +execute_cmd "apt --version" 'Checking needed tools: apt' + +# Creating working directory +rm -rf "$WORKDIR" &>> "$LOGFILE" +mkdir -p "$WORKDIR" &>> "$LOGFILE" +execute_cmd "cd $WORKDIR" "Moving to workdir: $WORKDIR" + +## Install utils +execute_cmd "apt update" "Updating repos" +execute_cmd "apt install -y net-tools vim curl wget software-properties-common apt-transport-https" "Installing utils" + +# Disabling apparmor and ufw +systemctl stop ufw.service &>> "$LOGFILE" +systemctl disable ufw &>> "$LOGFILE" +systemctl stop apparmor &>> "$LOGFILE" +systemctl disable apparmor &>> "$LOGFILE" + +#install mysql +execute_cmd "curl -O https://repo.percona.com/apt/percona-release_latest.generic_all.deb" "Downloading Percona repository for MySQL8" +execute_cmd "apt install -y gnupg2 lsb-release ./percona-release_latest.generic_all.deb" "Installing Percona repository for MySQL8" +execute_cmd "percona-release setup ps80" "Configuring Percona repository for MySQL8" + +echo -en "${cyan}Installing Percona Server for MySQL8...${reset}" + env DEBIAN_FRONTEND=noninteractive apt install -y percona-server-server &>> "$LOGFILE" +check_cmd_status "Error Installing MySql Server" + +#Configuring Database +if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then + execute_cmd "systemctl start mysql" "Starting database engine" + + echo """ + ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '$DBROOTPASS'; + """ | mysql -uroot &>> "$LOGFILE" + + export MYSQL_PWD=$DBROOTPASS + echo -en "${cyan}Creating Pandora FMS database...${reset}" + echo "create database $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST + check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support." + + echo "CREATE USER \"$DBUSER\"@'%' IDENTIFIED BY \"$DBPASS\";" | mysql -uroot -P$DBPORT -h$DBHOST + echo "ALTER USER \"$DBUSER\"@'%' IDENTIFIED WITH mysql_native_password BY \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST + echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%'" | mysql -uroot -P$DBPORT -h$DBHOST +fi +export MYSQL_PWD=$DBPASS + +#Generating my.cnf +cat > /etc/mysql/my.cnf << EOF_DB +[mysqld] +datadir=/var/lib/mysql +user=mysql +character-set-server=utf8 +skip-character-set-client-handshake +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 +# Mysql optimizations for Pandora FMS +# Please check the documentation in http://pandorafms.com for better results + +max_allowed_packet = 64M +innodb_buffer_pool_size = $POOL_SIZE +innodb_lock_wait_timeout = 90 +innodb_file_per_table +innodb_flush_log_at_trx_commit = 0 +innodb_flush_method = O_DIRECT +innodb_log_file_size = 64M +innodb_log_buffer_size = 16M +innodb_io_capacity = 100 +thread_cache_size = 8 +thread_stack = 256K +max_connections = 100 + +key_buffer_size=4M +read_buffer_size=128K +read_rnd_buffer_size=128K +sort_buffer_size=128K +join_buffer_size=4M + +skip-log-bin + +sql_mode="" + +log-error=/var/log/mysql/error.log +[mysqld_safe] +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid + +EOF_DB + +execute_cmd "systemctl restart mysql" "Configuring and restarting database engine" + +# Kernel optimization +if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then +cat >> /etc/sysctl.conf < Date: Mon, 6 Feb 2023 12:47:36 +0100 Subject: [PATCH 093/182] Update pandora_exec and pandora_agent_exec. The previous versions of pandora_exec and pandora_agent_exec did not kill the running process after a timeout. --- pandora_agents/pc/pandora_agent_exec | 61 ++++++++++++------------ pandora_agents/unix/pandora_agent_exec | 61 ++++++++++++------------ pandora_server/bin/pandora_exec | 65 ++++++++++++-------------- 3 files changed, 87 insertions(+), 100 deletions(-) diff --git a/pandora_agents/pc/pandora_agent_exec b/pandora_agents/pc/pandora_agent_exec index 48fba5c0d8..2a990067ae 100644 --- a/pandora_agents/pc/pandora_agent_exec +++ b/pandora_agents/pc/pandora_agent_exec @@ -1,15 +1,8 @@ #!/usr/bin/perl -########################################################################## -# pandora_agent_exec +################################################################################ +# pandora_exec - Execute a command with a time limit. # -# Executes the given command and prints its output to stdout. If the -# execution times out or the command does not exist nothing is printed -# to stdout. This is part of Pandora FMS Plugin server, do not delete!. -# -# Usage: pandora_agent_exec -########################################################################## -# Copyright (c) 2008-2010 Ramon Novoa, rnovoa@gmail.com -# (c) 2008-2010 Artica Soluciones Tecnologicas S.L +# Copyright (c) 2008-2023 Artica PFMS S.L. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -22,37 +15,41 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -########################################################################## - +################################################################################ use strict; use warnings; +use POSIX qw(WEXITSTATUS WIFEXITED); -# Check command line parameters +# Check command line arguments. if ($#ARGV < 1) { + print("Usage: $0 \n"); exit 1; } my @opts = @ARGV; my $timeout = shift(@opts); -my $command = join(' ', @opts); -my $output = ''; -my $ReturnCode = 0; +my $command = ($0 =~ m/_agent_exec$/) ? # For backward compatibility with pandora_agent. + join(' ', @opts) : + join(' ', map { quotemeta($_) } @opts); -# Execute the command -eval { - local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; - - $output = `$command`; - $ReturnCode = ($? >> 8) & 0xff; - alarm 0; -}; - -# Timeout -if ($@ eq "alarm\n") { - exit 3; +# Fork: +# * The child will run the command. +# * The parent will timeout if needed +# and exit with the appropriate exit status. +my $pid = fork(); +if ($pid == 0) { + setpgrp(); + exec($command); +} else { + eval { + local $SIG{ALRM} = sub { kill(9, -$pid); exit 1; }; + alarm $timeout; + waitpid($pid, 0); + alarm 0; + if (WIFEXITED(${^CHILD_ERROR_NATIVE})) { + exit WEXITSTATUS(${^CHILD_ERROR_NATIVE}); + } + }; } -print $output; - -exit $ReturnCode; +exit 1; diff --git a/pandora_agents/unix/pandora_agent_exec b/pandora_agents/unix/pandora_agent_exec index 48fba5c0d8..2a990067ae 100755 --- a/pandora_agents/unix/pandora_agent_exec +++ b/pandora_agents/unix/pandora_agent_exec @@ -1,15 +1,8 @@ #!/usr/bin/perl -########################################################################## -# pandora_agent_exec +################################################################################ +# pandora_exec - Execute a command with a time limit. # -# Executes the given command and prints its output to stdout. If the -# execution times out or the command does not exist nothing is printed -# to stdout. This is part of Pandora FMS Plugin server, do not delete!. -# -# Usage: pandora_agent_exec -########################################################################## -# Copyright (c) 2008-2010 Ramon Novoa, rnovoa@gmail.com -# (c) 2008-2010 Artica Soluciones Tecnologicas S.L +# Copyright (c) 2008-2023 Artica PFMS S.L. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -22,37 +15,41 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -########################################################################## - +################################################################################ use strict; use warnings; +use POSIX qw(WEXITSTATUS WIFEXITED); -# Check command line parameters +# Check command line arguments. if ($#ARGV < 1) { + print("Usage: $0 \n"); exit 1; } my @opts = @ARGV; my $timeout = shift(@opts); -my $command = join(' ', @opts); -my $output = ''; -my $ReturnCode = 0; +my $command = ($0 =~ m/_agent_exec$/) ? # For backward compatibility with pandora_agent. + join(' ', @opts) : + join(' ', map { quotemeta($_) } @opts); -# Execute the command -eval { - local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; - - $output = `$command`; - $ReturnCode = ($? >> 8) & 0xff; - alarm 0; -}; - -# Timeout -if ($@ eq "alarm\n") { - exit 3; +# Fork: +# * The child will run the command. +# * The parent will timeout if needed +# and exit with the appropriate exit status. +my $pid = fork(); +if ($pid == 0) { + setpgrp(); + exec($command); +} else { + eval { + local $SIG{ALRM} = sub { kill(9, -$pid); exit 1; }; + alarm $timeout; + waitpid($pid, 0); + alarm 0; + if (WIFEXITED(${^CHILD_ERROR_NATIVE})) { + exit WEXITSTATUS(${^CHILD_ERROR_NATIVE}); + } + }; } -print $output; - -exit $ReturnCode; +exit 1; diff --git a/pandora_server/bin/pandora_exec b/pandora_server/bin/pandora_exec index d6d5da1c8c..2a990067ae 100755 --- a/pandora_server/bin/pandora_exec +++ b/pandora_server/bin/pandora_exec @@ -1,15 +1,8 @@ #!/usr/bin/perl -########################################################################## -# pandora_exec +################################################################################ +# pandora_exec - Execute a command with a time limit. # -# Executes the given command and prints its output to stdout. If the -# execution times out or the command does not exist nothing is printed -# to stdout. This is part of Pandora FMS Plugin server, do not delete!. -# -# Usage: pandora_exec -########################################################################## -# Copyright (c) 2008 Ramon Novoa, rnovoa@gmail.com -# (c) 2008 Artica Soluciones Tecnologicas S.L +# Copyright (c) 2008-2023 Artica PFMS S.L. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -22,41 +15,41 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -########################################################################## - +################################################################################ use strict; use warnings; +use POSIX qw(WEXITSTATUS WIFEXITED); -# Check command line parameters +# Check command line arguments. if ($#ARGV < 1) { + print("Usage: $0 \n"); exit 1; } my @opts = @ARGV; my $timeout = shift(@opts); -my $command; -foreach my $arg (@opts) { - $command .= $^O ne 'MSWin32' ? quotemeta ($arg) . ' ' : '"' . $arg . '" '; -} -chomp ($command); -my $output = ''; -my $ReturnCode = 0; +my $command = ($0 =~ m/_agent_exec$/) ? # For backward compatibility with pandora_agent. + join(' ', @opts) : + join(' ', map { quotemeta($_) } @opts); -# Execute the command -eval { - local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $timeout; - - $output = `$command`; - $ReturnCode = ($? >> 8) & 0xff; - alarm 0; -}; - -# Timeout -if ($@ eq "alarm\n") { - exit 3; +# Fork: +# * The child will run the command. +# * The parent will timeout if needed +# and exit with the appropriate exit status. +my $pid = fork(); +if ($pid == 0) { + setpgrp(); + exec($command); +} else { + eval { + local $SIG{ALRM} = sub { kill(9, -$pid); exit 1; }; + alarm $timeout; + waitpid($pid, 0); + alarm 0; + if (WIFEXITED(${^CHILD_ERROR_NATIVE})) { + exit WEXITSTATUS(${^CHILD_ERROR_NATIVE}); + } + }; } -print $output; - -exit $ReturnCode; +exit 1; From bcfa977f567b86ff0b43358e90ba008830f816da Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 8 Feb 2023 15:23:13 +0100 Subject: [PATCH 094/182] #10335 fixed plugin select in edit modules in bulk --- .../agentes/module_manager_editor_plugin.php | 3 +- .../godmode/massive/massive_edit_modules.php | 74 +++++++++---------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 2cc0ec3d8e..9477091e95 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -89,8 +89,7 @@ $password_fields = []; // If there are $macros, we create the form fields if (!empty($macros)) { - $macros = json_decode($macros, true); - + $macros = json_decode(io_safe_output($macros), true); foreach ($macros as $k => $m) { $data = []; $data[0] = $m['desc']; diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 85a0006986..a03e278957 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -2094,46 +2094,21 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' switch ($field) { case 'id_plugin': if ($value != 0) { - $value_field_1 = get_parameter('_field1_', ''); - $value_field_1_desc = get_parameter('desc_field1_', ''); - - $value_field_2 = get_parameter('_field2_', ''); - $value_field_2_desc = get_parameter('desc_field2_', ''); - - $value_field_3 = get_parameter('_field3_', ''); - $value_field_3_desc = get_parameter('desc_field3_', ''); - - $value_field_4 = get_parameter('_field4_', ''); - $value_field_4_desc = get_parameter('desc_field4_', ''); - - $value_field_5 = get_parameter('_field5_', ''); - $value_field_5_desc = get_parameter('desc_field5_', ''); - - $values['macros'] = '{"1":{"macro":"_field1_","desc":"'.io_safe_input($value_field_1_desc).'","help":"'.io_safe_input($value_field_1_desc).'","value":"'.$value_field_1.'"}'; - - if ($value_field_2_desc != '') { - $values['macros'] .= ',"2":{"macro":"_field2_","desc":"'.io_safe_input($value_field_2_desc).'","help":"'.io_safe_input($value_field_2_desc).'","value":"'.$value_field_2.'"}'; - - if ($value_field_3_desc != '') { - $values['macros'] .= ',"3":{"macro":"_field3_","desc":"'.io_safe_input($value_field_3_desc).'","help":"'.io_safe_input($value_field_3_desc).'","value":"'.$value_field_3.'"}'; - - if ($value_field_4_desc != '') { - $values['macros'] .= ',"4":{"macro":"_field4_","desc":"'.io_safe_input($value_field_4_desc).'","help":"'.io_safe_input($value_field_4_desc).'","value":"'.$value_field_4.'"}'; - - if ($value_field_5_desc != '') { - $values['macros'] .= ',"5":{"macro":"_field5_","desc":"'.io_safe_input($value_field_5_desc).'","help":"'.io_safe_input($value_field_5_desc).'","value":"'.$value_field_5.'"}'; - } else { - $values['macros'] .= '}'; - } - } else { - $values['macros'] .= '}'; - } - } else { - $values['macros'] .= '}'; + for ($i = 0; $i <= 15; $i++) { + $value_field = get_parameter('_field'.$i.'_', ''); + $value_field_desc = get_parameter('desc_field'.$i.'_', ''); + if ($value_field_desc != '') { + $values['macros'][$i] = [ + 'macro' => '_field'.$i.'_', + 'desc' => io_safe_input($value_field_desc), + 'help' => io_safe_input($value_field_desc), + 'value' => $value_field, + ]; } - } else { - $values['macros'] .= '}'; } + + $values['macros'] = json_encode($values['macros']); + $values[$field] = $value; } break; @@ -2260,7 +2235,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' // Apply at All agents (within valid groups). $modules = db_get_all_rows_sql( sprintf( - 'SELECT tam.id_agente_modulo, tam.id_tipo_modulo + 'SELECT tam.id_agente_modulo, tam.id_tipo_modulo,tam.macros, tam.id_plugin FROM tagente_modulo tam INNER JOIN tagente ta ON ta.id_agente = tam.id_agente WHERE ta.id_grupo IN (%s) %s;', @@ -2277,6 +2252,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' [ 'id_agente_modulo', 'id_tipo_modulo', + 'macros', + 'id_plugin', ] ); } else { @@ -2289,6 +2266,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' [ 'id_agente_modulo', 'id_tipo_modulo', + 'macros', + 'id_plugin', ] ); } @@ -2346,6 +2325,23 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' } } + if ($module['macros'] && $module['id_plugin'] == $values['id_plugin']) { + $module_macros = json_decode($module['macros'], true); + $values_macros = json_decode($values['macros'], true); + + foreach ($values_macros as $k => $value_macro) { + foreach ($module_macros as $s => $module_macro) { + if ($value_macro['macro'] == $module_macro['macro'] && $value_macro['value'] !== '') { + $module_macros[$s]['value'] = $value_macro['value']; + $module_macros[$s]['desc'] = $value_macro['desc']; + $module_macros[$s]['help'] = $value_macro['help']; + } + } + } + + $values['macros'] = json_encode($module_macros); + } + $result = modules_update_agent_module( $module['id_agente_modulo'], $values, From 8b9803c1c558e8f08bd1d733bf8381fbd7fa5523 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 8 Feb 2023 17:04:24 +0100 Subject: [PATCH 095/182] fixed tinyMCE converting URLs to relative ones --- pandora_console/include/rest-api/models/VisualConsole/View.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/rest-api/models/VisualConsole/View.php b/pandora_console/include/rest-api/models/VisualConsole/View.php index cd1e25fd49..e8305df830 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/View.php +++ b/pandora_console/include/rest-api/models/VisualConsole/View.php @@ -144,6 +144,8 @@ class View extends \HTML tinyMCE.init({ selector: "#textarea_label", theme: "advanced", + convert_urls:false, + relative_urls:false, content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css", theme_advanced_font_sizes: "4pt=.visual_font_size_4pt, " + From 34c61bb513b86c7a51c67365242784ea3d676cbb Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 9 Feb 2023 01:02:05 +0100 Subject: [PATCH 096/182] 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 fe5bad7109..4cfb010cf2 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230208 +Version: 7.0NG.768-230209 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 38f99a713f..38048034a1 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.768-230208" +pandora_version="7.0NG.768-230209" 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 f01ddb5744..228a025448 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230208'; +use constant AGENT_BUILD => '230209'; # 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 c1b7aa663a..1fb9eac584 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_linux %define version 7.0NG.768 -%define release 230208 +%define release 230209 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 962b9077ba..1c08401142 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230208 +%define release 230209 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 a6a9b0271b..66d6f764fa 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230208" +PI_BUILD="230209" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 4f5de91e58..faf4af76a5 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230208} +{230209} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 304f3a22f8..af6acde6bc 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.768 Build 230208") +#define PANDORA_VERSION ("7.0NG.768 Build 230209") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 030041571c..fb7c956dcf 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.768(Build 230208))" + VALUE "ProductVersion", "(7.0NG.768(Build 230209))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 807a36e537..6fbb9eae7c 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230208 +Version: 7.0NG.768-230209 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 6ff898257a..19865fc581 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.768-230208" +pandora_version="7.0NG.768-230209" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 1777d0bb57..2f11c97e68 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 = 'PC230208'; +$build_version = 'PC230209'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 064cf37935..e7026a9169 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index fff8104658..de33a9be3f 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.768 -%define release 230208 +%define release 230209 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 7b79bbbd4c..8ce0f6c363 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.768 -%define release 230208 +%define release 230209 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3696050dea..0714a32686 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230208" +PI_BUILD="230209" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index cb45ea6415..6192b62b47 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230208"; +my $version = "7.0NG.768 Build 230209"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index f3346387d2..3a9abd0f9b 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.768 Build 230208"; +my $version = "7.0NG.768 Build 230209"; # save program name for logging my $progname = basename($0); From 50e8b457f8d2ae1d0bece5a83937550f393ae8a3 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 9 Feb 2023 11:42:42 +0100 Subject: [PATCH 097/182] #10302 fixed tz in event list --- pandora_console/operation/events/events.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 6777ced4c3..c7c8be45ce 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -350,7 +350,7 @@ if (is_ajax() === true) { 'te.warning_instructions', 'te.unknown_instructions', 'te.owner_user', - 'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp', + 'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp', 'te.custom_data', 'te.data', 'te.module_status', @@ -380,7 +380,7 @@ if (is_ajax() === true) { $order['field'] = 'agent_name'; break; - case 'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp': + case 'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp': $order['field'] = 'ack_utimestamp'; break; @@ -528,7 +528,7 @@ if (is_ajax() === true) { true ); $tmp->timestamp = ui_print_timestamp( - $tmp->timestamp, + $tmp->utimestamp, true ); From 9f8d302719765df6144dfc0266c5056319854afc Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 10 Feb 2023 01:01:50 +0100 Subject: [PATCH 098/182] 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 4cfb010cf2..b565d1ff22 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230209 +Version: 7.0NG.768-230210 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 38048034a1..7dc4394f80 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.768-230209" +pandora_version="7.0NG.768-230210" 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 228a025448..3d0e51330f 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230209'; +use constant AGENT_BUILD => '230210'; # 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 1fb9eac584..48e2b24538 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_linux %define version 7.0NG.768 -%define release 230209 +%define release 230210 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 1c08401142..92666a0db0 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230209 +%define release 230210 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 66d6f764fa..b5ad7ba5c4 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230209" +PI_BUILD="230210" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index faf4af76a5..8927624adc 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230209} +{230210} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index af6acde6bc..5067264a29 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.768 Build 230209") +#define PANDORA_VERSION ("7.0NG.768 Build 230210") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index fb7c956dcf..54596f74f5 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.768(Build 230209))" + VALUE "ProductVersion", "(7.0NG.768(Build 230210))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 6fbb9eae7c..9a08efb4dc 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230209 +Version: 7.0NG.768-230210 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 19865fc581..70a58b8f43 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.768-230209" +pandora_version="7.0NG.768-230210" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 2f11c97e68..79016bf075 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 = 'PC230209'; +$build_version = 'PC230210'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index e7026a9169..e19455763e 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index de33a9be3f..35238d78ba 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.768 -%define release 230209 +%define release 230210 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 8ce0f6c363..ab61c7894d 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.768 -%define release 230209 +%define release 230210 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 0714a32686..4a3432fbfe 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230209" +PI_BUILD="230210" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 6192b62b47..15b8b0897e 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230209"; +my $version = "7.0NG.768 Build 230210"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 3a9abd0f9b..b0839f05af 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.768 Build 230209"; +my $version = "7.0NG.768 Build 230210"; # save program name for logging my $progname = basename($0); From 06442fa6e30cb00fe4d41245814ff53831722c96 Mon Sep 17 00:00:00 2001 From: Calvo Date: Fri, 10 Feb 2023 15:03:57 +0100 Subject: [PATCH 099/182] WIP: Omnishell error xml if YAML::Tiny not installed on agent --- pandora_agents/unix/pandora_agent | 46 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index f01ddb5744..90b7d93c7c 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -556,30 +556,38 @@ BEGIN { sub runCommand { my ($self, $ref, $output_mode) = @_; + my $result; if($self->load_libraries()) { # Functionality possible. my $command = $self->{'commands'}->{$ref}; - my $result = $self->evaluate_command($ref); - if (ref($result) eq "HASH") { - # Process command result. - if (defined($output_mode) && $output_mode eq 'xml') { - my $output = ''; - $output .= "\n"; - $output .= " \n"; - $output .= " {'name'}."]]>\n"; - $output .= " \n"; - $output .= " {'error_level'}."]]>\n"; - $output .= " {'stdout'}."]]>\n"; - $output .= " {'stderr'}."]]>\n"; - $output .= " \n"; - $output .= "\n"; + $result = $self->evaluate_command($ref); + } else { + $result = { + 'stderr' => 'Cannot use commands without YAML dependency, please install it.', + 'name' => 'YAML::Tiny', + 'error_level' => 2, + }; + } - return $output; - } - return $result; - } else { - $self->set_last_error('Failed to process ['.$ref.']: '.$result); + if (ref($result) eq "HASH") { + # Process command result. + if (defined($output_mode) && $output_mode eq 'xml') { + my $output = ''; + $output .= "\n"; + $output .= " \n"; + $output .= " {'name'}."]]>\n"; + $output .= " \n"; + $output .= " {'error_level'}."]]>\n"; + $output .= " {'stdout'}."]]>\n"; + $output .= " {'stderr'}."]]>\n"; + $output .= " \n"; + $output .= "\n"; + + return $output; } + return $result; + } else { + $self->set_last_error('Failed to process ['.$ref.']: '.$result); } return undef; From 1e5ac4281c0751f6ed6a72d2b2004c766ac1650b Mon Sep 17 00:00:00 2001 From: artica Date: Sat, 11 Feb 2023 01:02:09 +0100 Subject: [PATCH 100/182] 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 b565d1ff22..19d729f0d0 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230210 +Version: 7.0NG.768-230211 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 7dc4394f80..c33f1bed6d 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.768-230210" +pandora_version="7.0NG.768-230211" 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 3d0e51330f..b745fd89b1 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230210'; +use constant AGENT_BUILD => '230211'; # 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 48e2b24538..ce2bcea385 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_linux %define version 7.0NG.768 -%define release 230210 +%define release 230211 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 92666a0db0..817db34242 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230210 +%define release 230211 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 b5ad7ba5c4..66c90d0773 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230210" +PI_BUILD="230211" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 8927624adc..89efa6e3c2 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230210} +{230211} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 5067264a29..f1ffa7392a 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.768 Build 230210") +#define PANDORA_VERSION ("7.0NG.768 Build 230211") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 54596f74f5..473b20bbb9 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.768(Build 230210))" + VALUE "ProductVersion", "(7.0NG.768(Build 230211))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 9a08efb4dc..8f221ab965 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230210 +Version: 7.0NG.768-230211 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 70a58b8f43..b2c8bfcebd 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.768-230210" +pandora_version="7.0NG.768-230211" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 79016bf075..176d23b0d6 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 = 'PC230210'; +$build_version = 'PC230211'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index e19455763e..851451d651 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 35238d78ba..1defcc1be7 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.768 -%define release 230210 +%define release 230211 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index ab61c7894d..d99379b166 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.768 -%define release 230210 +%define release 230211 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 4a3432fbfe..0a51e9e089 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230210" +PI_BUILD="230211" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 15b8b0897e..9d0a89c017 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230210"; +my $version = "7.0NG.768 Build 230211"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b0839f05af..5b81529bb2 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.768 Build 230210"; +my $version = "7.0NG.768 Build 230211"; # save program name for logging my $progname = basename($0); From 98c05a4bea3facfab91cb6fced89b39e120d0a07 Mon Sep 17 00:00:00 2001 From: artica Date: Sun, 12 Feb 2023 01:02:01 +0100 Subject: [PATCH 101/182] 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 19d729f0d0..e7b513e141 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230211 +Version: 7.0NG.768-230212 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 c33f1bed6d..962bdbdedc 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.768-230211" +pandora_version="7.0NG.768-230212" 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 b745fd89b1..f3c98efa21 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230211'; +use constant AGENT_BUILD => '230212'; # 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 ce2bcea385..8137d70444 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_linux %define version 7.0NG.768 -%define release 230211 +%define release 230212 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 817db34242..0662632ca1 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230211 +%define release 230212 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 66c90d0773..ea44be02b3 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230211" +PI_BUILD="230212" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 89efa6e3c2..92c21d5c1d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230211} +{230212} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f1ffa7392a..baebb9ff14 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.768 Build 230211") +#define PANDORA_VERSION ("7.0NG.768 Build 230212") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 473b20bbb9..754d2fed2a 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.768(Build 230211))" + VALUE "ProductVersion", "(7.0NG.768(Build 230212))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8f221ab965..0b84ee5643 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230211 +Version: 7.0NG.768-230212 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 b2c8bfcebd..810cdafcb5 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.768-230211" +pandora_version="7.0NG.768-230212" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 176d23b0d6..1155531082 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 = 'PC230211'; +$build_version = 'PC230212'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 851451d651..178158ddb4 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 1defcc1be7..a777c099e7 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.768 -%define release 230211 +%define release 230212 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index d99379b166..2989d2001e 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.768 -%define release 230211 +%define release 230212 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 0a51e9e089..d09995795c 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230211" +PI_BUILD="230212" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 9d0a89c017..7909617726 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230211"; +my $version = "7.0NG.768 Build 230212"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 5b81529bb2..a6533edb52 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.768 Build 230211"; +my $version = "7.0NG.768 Build 230212"; # save program name for logging my $progname = basename($0); From 885c128556752d4d3848b4808d36ff876092fbcd Mon Sep 17 00:00:00 2001 From: artica Date: Mon, 13 Feb 2023 01:01:18 +0100 Subject: [PATCH 102/182] 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 e7b513e141..7802c679e5 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230212 +Version: 7.0NG.768-230213 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 962bdbdedc..eb4279b84f 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.768-230212" +pandora_version="7.0NG.768-230213" 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 f3c98efa21..1668a50e86 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230212'; +use constant AGENT_BUILD => '230213'; # 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 8137d70444..4482ace58a 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_linux %define version 7.0NG.768 -%define release 230212 +%define release 230213 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 0662632ca1..1b07645a58 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230212 +%define release 230213 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 ea44be02b3..601db13b4b 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230212" +PI_BUILD="230213" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 92c21d5c1d..1cf8ab41dc 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230212} +{230213} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index baebb9ff14..d44d4eb5a1 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.768 Build 230212") +#define PANDORA_VERSION ("7.0NG.768 Build 230213") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 754d2fed2a..e983b3cba2 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.768(Build 230212))" + VALUE "ProductVersion", "(7.0NG.768(Build 230213))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 0b84ee5643..8b393620b9 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230212 +Version: 7.0NG.768-230213 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 810cdafcb5..399096ff6a 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.768-230212" +pandora_version="7.0NG.768-230213" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 1155531082..5a8c0631b1 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 = 'PC230212'; +$build_version = 'PC230213'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 178158ddb4..835b2efaea 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index a777c099e7..90ebdbf8bc 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.768 -%define release 230212 +%define release 230213 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 2989d2001e..9698e8c1dc 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.768 -%define release 230212 +%define release 230213 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index d09995795c..52e6b86b35 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230212" +PI_BUILD="230213" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 7909617726..2667cdbbb7 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230212"; +my $version = "7.0NG.768 Build 230213"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index a6533edb52..378688aa67 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.768 Build 230212"; +my $version = "7.0NG.768 Build 230213"; # save program name for logging my $progname = basename($0); From 4cd0820f117a4428c65e4e6dae60603fc3d4d340 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 13 Feb 2023 11:44:01 +0100 Subject: [PATCH 103/182] #10118 Changed radio button --- .../agentes/pandora_networkmap.editor.php | 33 ++++++++++++------- .../agentes/pandora_networkmap.view.php | 30 +++++++++++++---- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index c03af62bf3..507e037b1e 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -352,7 +352,23 @@ if ($not_found) { $table->data[6][1] = html_print_input_text('scale_z', $scale_z, '', 2, 10, true).ui_print_help_tip(__('Introduce zoom level. 1 = Highest resolution. Figures may include decimals'), true); $table->data['source'][0] = __('Source'); - $table->data['source'][1] = html_print_radio_button('source', 'group', __('Group'), $source, true, $disabled_source).html_print_radio_button('source', 'recon_task', __('Discovery task'), $source, true, $disabled_source).html_print_radio_button('source', 'ip_mask', __('CIDR IP mask'), $source, true, $disabled_source); + $table->data['source'][1] = html_print_select( + [ + 'group' => __('Group'), + 'recon_task' => __('Discovery task'), + 'ip_mask' => __('CIDR IP mask'), + ], + 'source', + $source, + '', + '', + 0, + true, + false, + false, + '', + $disabled_source + ); $table->data['source_data_recon_task'][0] = __('Source from recon task'); $table->data['source_data_recon_task'][0] .= ui_print_help_tip( @@ -498,9 +514,9 @@ if ($not_found) { '; From d2856e09bd72c94972bcd7dbc5913b845c6bc124 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 13 Feb 2023 13:39:20 +0100 Subject: [PATCH 104/182] implemented per-task sap license --- pandora_console/include/functions_config.php | 4 ---- pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 12 ++++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index b0d15d5cef..1acbfa0760 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -463,10 +463,6 @@ function config_update_config() if (config_update_value('ipam_ocuppied_warning_treshold', get_parameter('ipam_ocuppied_warning_treshold'), true) === false) { $error_update[] = __('Ipam Ocuppied Manager Warning'); } - - if (config_update_value('sap_license', get_parameter('sap_license'), true) === false) { - $error_update[] = __('SAP/R3 Plugin Licence'); - } } break; diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index e6c42fab34..2d5928333d 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -221,10 +221,14 @@ sub data_consumer ($$) { if ($task->{'type'} == DISCOVERY_APP_SAP) { # SAP TASK, retrieve license. - $task->{'sap_license'} = pandora_get_config_value( - $dbh, - 'sap_license' - ); + if (defined($task->{'field4'}) && $task->{'field4'} ne "") { + $task->{'sap_license'} = $task->{'field4'}; + } else { + $task->{'sap_license'} = pandora_get_config_value( + $dbh, + 'sap_license' + ); + } # Retrieve credentials for task (optional). if (defined($task->{'auth_strings'}) From b3ca6c78bf46abd2637b0a519d1d1372e8d853e3 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 13 Feb 2023 13:58:37 +0100 Subject: [PATCH 105/182] #9713 ent Problems with the copy button fixed --- .../include/functions_filemanager.php | 193 +++++++++--------- 1 file changed, 93 insertions(+), 100 deletions(-) diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 1db21b308a..4fc6dd0b14 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -1,4 +1,5 @@ - function show_create_text_file() { - actions_dialog('create_text_file'); - $("#create_text_file").css("display", "block"); - check_opened_dialog('create_text_file'); - } + function show_create_text_file() { + actions_dialog('create_text_file'); + $("#create_text_file").css("display", "block"); + check_opened_dialog('create_text_file'); + } + function show_upload_file() { actions_dialog('upload_file'); $("#upload_file").css("display", "block"); check_opened_dialog('upload_file'); } - function check_opened_dialog(check_opened){ - if(check_opened !== 'create_folder'){ + function check_opened_dialog(check_opened) { + if (check_opened !== 'create_folder') { if (($("#create_folder").hasClass("ui-dialog-content") && $('#create_folder').dialog('isOpen') === true)) { $('#create_folder').dialog('close'); } } - if(check_opened !== 'create_text_file'){ - if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) { - $('#create_text_file').dialog('close'); + if (check_opened !== 'create_text_file') { + if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) { + $('#create_text_file').dialog('close'); + } } - } - if(check_opened !== 'upload_file'){ + if (check_opened !== 'upload_file') { if (($("#upload_file").hasClass("ui-dialog-content") && $('#upload_file').dialog('isOpen')) === true) { $('#upload_file').dialog('close'); } } } - function actions_dialog(action){ - $('.'+action).addClass('file_table_modal_active'); - var title_action =''; + function actions_dialog(action) { + $('.' + action).addClass('file_table_modal_active'); + var title_action = ''; switch (action) { case 'create_folder': - title_action = ""; + title_action = ""; break; - - case 'create_text_file': - title_action = ""; - break; - + + case 'create_text_file': + title_action = ""; + break; + case 'upload_file': - title_action = ""; + title_action = ""; break; default: break; } - $('#'+action) - .dialog({ - title: title_action, - resizable: true, - draggable: true, - modal: true, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 500, - minWidth: 500, - minHeight: 210, - maxWidth: 800, - maxHeight: 300, - close: function () { - $('.'+action).removeClass('file_table_modal_active'); - } - }).show(); + $('#' + action) + .dialog({ + title: title_action, + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 500, + minWidth: 500, + minHeight: 210, + maxWidth: 800, + maxHeight: 300, + close: function() { + $('.' + action).removeClass('file_table_modal_active'); + } + }).show(); } - function show_modal_real_path (path) { + function show_modal_real_path(path) { + if (navigator.clipboard && window.isSecureContext) ; + else ; $('#modal_real_path').addClass('file_table_modal_active'); $('#real_path').empty(); $('#real_path').html(path); title_action = ""; $('#modal_real_path') - .dialog({ - title: title_action, - resizable: true, - draggable: true, - modal: true, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 448, - minWidth: 448, - minHeight: 213, - maxWidth: 800, - maxHeight: 300, - close: function () { - $('#modal_real_path').removeClass('file_table_modal_active'); - } - }).show(); + .dialog({ + title: title_action, + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 448, + minWidth: 448, + minHeight: 213, + maxWidth: 800, + maxHeight: 300, + close: function() { + $('#modal_real_path').removeClass('file_table_modal_active'); + } + }).show(); - $("#submit-submit").on("click",copyToClipboard); + $("#submit-submit").on("click", copyToClipboard); } function copyToClipboard() { - navigator.clipboard.writeText($("#real_path").text()).then(function (){ - $('#modal_real_path').dialog('close'); - }); + if (navigator.clipboard && window.isSecureContext) { + window.navigator.clipboard.writeText($("#real_path").text()).then(function() { + $('#modal_real_path').dialog('close'); + }); + } } '.$data[1].''; + $error_message = __('This file could be executed by any user'); + $error_message .= '. '.__('Make sure it can\'t perform dangerous tasks'); + $data[1] = ''.$data[1].''; } $data[2] = ui_print_timestamp( @@ -753,11 +742,11 @@ function filemanager_file_explorer( $data[3] = ui_format_filesize($fileinfo['size']); } - // Actions buttons - // Delete button. - $data[4] = ''; - $data[4] .= ''; - $typefile = array_pop(explode('.', $fileinfo['name'])); + // Actions buttons + // Delete button. + $data[4] = ''; + $data[4] .= ''; + $typefile = array_pop(explode('.', $fileinfo['name'])); if (is_writable($fileinfo['realpath']) === true && (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3) && ($readOnly === false) @@ -805,9 +794,9 @@ function filemanager_file_explorer( $data[4] .= ''.html_print_image('images/book_edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Real path'), 'class' => 'invert_filter']).''; } - $data[4] .= ''; + $data[4] .= ''; - array_push($table->data, $data); + array_push($table->data, $data); } } else { ui_print_info_message( @@ -900,7 +889,7 @@ function filemanager_file_explorer( 'content' => html_print_input_file( 'file', true, - [ 'style' => 'border:0; padding:0; width:100%' ] + ['style' => 'border:0; padding:0; width:100%'] ), ], true @@ -985,8 +974,12 @@ function filemanager_file_explorer( // Show Modal Real Path $modal_real_path = "
Real path to plugin execution is:
-
-
".html_print_submit_button(__('Copy'), 'submit', false, 'class="sub next"', true).'
'; +
"; + + if (isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'on' || $_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '127.0.0.1') { + $modal_real_path .= "
".html_print_submit_button(__('Copy'), 'submit', false, 'class="sub next"', true).'
'; + } + html_print_div( [ 'id' => 'modal_real_path', @@ -1141,4 +1134,4 @@ function filemanager_safe_directory( } return $directory; -} \ No newline at end of file +} From feb2f3ffa29f91ff35773b355961ff1ea8f6087d Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Mon, 13 Feb 2023 15:03:23 +0100 Subject: [PATCH 106/182] 10092-Widget tree view, Not normal status --- pandora_console/include/class/Tree.class.php | 21 +++++++++++++++ .../include/javascript/pandora_dashboards.js | 5 ++++ .../lib/Dashboard/Widgets/tree_view.php | 27 ++++++++++++++----- pandora_console/operation/tree.php | 7 ++++- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index fb88063623..bf3fbf9b5d 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -214,6 +214,11 @@ class Tree AND ta.unknown_count = 0 AND ta.normal_count > 0) '; break; + + case AGENT_STATUS_NOT_NORMAL: + $agent_status_filter = ' AND (ta.critical_count > 0 + OR ta.warning_count > 0) '; + break; } return $agent_status_filter; @@ -285,6 +290,10 @@ class Tree return $show_init_condition; } + if ((int) $this->filter['statusModule'] === 6) { + return ' AND (ta.warning_count > 0 OR ta.critical_count > 0)'; + } + $field_filter = modules_get_counter_by_states($this->filter['statusModule']); if ($field_filter === false) { return ' AND 1=0'; @@ -894,6 +903,18 @@ class Tree $agent['counters']['ok'] = $agent['normal_count']; $agent['counters']['total'] = $agent['normal_count']; break; + + case AGENT_MODULE_STATUS_NOT_NORMAL: + if (empty($agent['critical_count']) === false) { + $agent['counters']['critical'] = $agent['critical_count']; + } + + if (empty($agent['warning_count']) === false) { + $agent['counters']['warning'] = $agent['warning_count']; + } + + $agent['counters']['total'] = ($agent['warning_count'] + $agent['critical_count']); + break; } } diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 02b8e47c08..cac0d10d97 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -956,6 +956,11 @@ function processTreeSearch(settings) { agents: settings.translate.ok.agents, modules: settings.translate.ok.modules, none: settings.translate.ok.none + }, + not_normal: { + agents: settings.translate.not_normal.agents, + modules: settings.translate.not_normal.modules, + none: settings.translate.not_normal.none } } }); diff --git a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php index 2c0441ead8..954a6930e6 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php +++ b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php @@ -243,6 +243,10 @@ class TreeViewWidget extends Widget $values['agentStatus'] = AGENT_STATUS_NOT_INIT; break; + case 6: + $values['agentStatus'] = AGENT_STATUS_NOT_NORMAL; + break; + default: case -1: $values['agentStatus'] = AGENT_STATUS_ALL; @@ -284,6 +288,10 @@ class TreeViewWidget extends Widget $values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_INIT; break; + case 6: + $values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_NORMAL; + break; + default: case -1: $values['moduleStatus'] = -1; @@ -381,12 +389,13 @@ class TreeViewWidget extends Widget // Agents status. $fields = [ - AGENT_STATUS_ALL => __('All'), - AGENT_STATUS_NORMAL => __('Normal'), - AGENT_STATUS_WARNING => __('Warning'), - AGENT_STATUS_CRITICAL => __('Critical'), - AGENT_STATUS_UNKNOWN => __('Unknown'), - AGENT_STATUS_NOT_INIT => __('Not init'), + AGENT_STATUS_ALL => __('All'), + AGENT_STATUS_NORMAL => __('Normal'), + AGENT_STATUS_WARNING => __('Warning'), + AGENT_STATUS_CRITICAL => __('Critical'), + AGENT_STATUS_UNKNOWN => __('Unknown'), + AGENT_STATUS_NOT_INIT => __('Not init'), + AGENT_STATUS_NOT_NORMAL => __('Not normal'), ]; $inputs[] = [ @@ -420,6 +429,7 @@ class TreeViewWidget extends Widget AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'), AGENT_MODULE_STATUS_UNKNOWN => __('Unknown'), AGENT_MODULE_STATUS_NOT_INIT => __('Not init'), + AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'), ]; if (is_metaconsole() === false) { @@ -682,6 +692,11 @@ class TreeViewWidget extends Widget 'modules' => __('Normal modules'), 'none' => __('Normal'), ], + 'not_normal' => [ + 'agents' => __('Not normal agents'), + 'modules' => __('Not normal modules'), + 'none' => __('Not normal'), + ], 'module' => __('Module'), 'timeOnlyTitle' => __('Choose time'), 'timeText' => __('Time'), diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index ece2266800..e0e5f7aef1 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -484,7 +484,12 @@ enterprise_hook('close_meta_frame'); agents: "", modules: "", none: "" - } + }, + not_normal: { + agents: "", + modules: "", + none: "" + }, } }); } From a9832e9886b9bbff50c51021b0fe1d44c721ae7e Mon Sep 17 00:00:00 2001 From: Calvo Date: Mon, 13 Feb 2023 15:40:55 +0100 Subject: [PATCH 107/182] WIP: Added pandora notification if missing library on agent --- .../include/class/ConsoleSupervisor.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index b6a6d3df43..17d7b2213a 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -518,6 +518,14 @@ class ConsoleSupervisor $this->checkSyncQueueLength(); $this->checkSyncQueueStatus(); } + + /* + * Checkc agent missing libraries. + * NOTIF.AGENT.LIBRARY + */ + if ((bool) enterprise_installed() === true) { + $this->checkLibaryError(); + } } @@ -2806,4 +2814,29 @@ class ConsoleSupervisor } + /** + * Chechs if an agent has a dependency eror on omnishell + * + * @return void + */ + public function checkLibaryError() + { + $sql = 'SELECT COUNT(errorlevel) from tremote_command_target WHERE errorlevel = 2'; + + $error_dependecies = db_get_sql($sql); + if ($error_dependecies > 0) { + $this->notify( + [ + 'type' => 'NOTIF.AGENT.LIBRARY', + 'title' => __('Agent dependency error'), + 'message' => __( + 'There are omnishell agents with dependency errors', + ), + 'url' => $url, + ] + ); + } + } + + } From 5b263981c477010b8d6d5dcd813cd25e1ad480ef Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 13 Feb 2023 17:06:09 +0100 Subject: [PATCH 108/182] #10118 Added group multiselector --- pandora_console/extras/mr/61.sql | 2 ++ .../include/class/NetworkMap.class.php | 21 ++++++++++++------- .../agentes/pandora_networkmap.editor.php | 14 ++++++++++--- .../operation/agentes/pandora_networkmap.php | 6 +++--- .../agentes/pandora_networkmap.view.php | 2 -- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/pandora_console/extras/mr/61.sql b/pandora_console/extras/mr/61.sql index b73069c058..2812efb2a6 100644 --- a/pandora_console/extras/mr/61.sql +++ b/pandora_console/extras/mr/61.sql @@ -2,6 +2,8 @@ START TRANSACTION; ALTER TABLE `tserver` ADD COLUMN `server_keepalive_utimestamp` BIGINT NOT NULL DEFAULT 0; +ALTER TABLE `tmap` MODIFY COLUMN `id_group` TEXT NOT NULL default ''; + CREATE TABLE IF NOT EXISTS `tmonitor_filter` ( `id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id_name` VARCHAR(600) NOT NULL, diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 7b43a3daf6..ebfa966a9b 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -792,17 +792,22 @@ class NetworkMap || $this->mapOptions['map_filter']['dont_show_subgroups'] == 1 ) { // Show only current selected group. - $filter['id_grupo'] = $this->idGroup; + $filter['id_grupo'] = explode(',', $this->idGroup); } else { // Show current group and children. - $childrens = groups_get_children($this->idGroup, null, true); - if (!empty($childrens)) { - $childrens = array_keys($childrens); + foreach (explode(',', $this->idGroup) as $key => $group) { + $childrens = groups_get_children($group, null, true); + if (!empty($childrens)) { + $childrens = array_keys($childrens); - $filter['id_grupo'] = $childrens; - $filter['id_grupo'][] = $this->idGroup; - } else { - $filter['id_grupo'] = $this->idGroup; + if (empty($filter['id_grupo']) === false) { + $filter['id_grupo'] = array_merge($filter['id_grupo'], $childrens); + } else { + $filter['id_grupo'] = $childrens; + } + } else { + $filter['id_grupo'][] = $group; + } } } diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index 507e037b1e..0d2c7193e1 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -337,7 +337,14 @@ if ($not_found) { ); $table->data[3][0] = __('Description'); - $table->data[3][1] = html_print_textarea('description', 7, 25, $description, '', true); + $table->data[3][1] = html_print_input_text( + 'description', + $description, + '', + 100, + 100, + true + ); $table->data[4][0] = __('Position X'); $table->data[4][1] = html_print_input_text('pos_x', $offset_x, '', 2, 10, true); @@ -401,11 +408,12 @@ if ($not_found) { $config['id_user'], 'AR', true, - 'id_group', - $id_group, + 'id_group[]', + explode(',', $id_group), '', '', '', + true, true ).'
'; $table->data['source_data_group'][1] .= html_print_image( diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 9c57ad033f..9fcf1b7fae 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -237,7 +237,7 @@ if ($new_networkmap || $save_networkmap) { } if ($save_networkmap) { - $id_group = (int) get_parameter('id_group', 0); + $id_group = get_parameter('id_group', 0); $id_group_map = (int) get_parameter('id_group_map', 0); @@ -292,7 +292,7 @@ if ($new_networkmap || $save_networkmap) { $values = []; $values['name'] = $name; - $values['id_group'] = $id_group; + $values['id_group'] = implode(',', $id_group); $values['source_period'] = 60; $values['width'] = $width; $values['height'] = $height; @@ -333,7 +333,7 @@ if ($new_networkmap || $save_networkmap) { if ($source == 'group') { $values['source'] = 0; - $values['source_data'] = $id_group; + $values['source_data'] = implode(',', $id_group); } else if ($source == 'recon_task') { $values['source'] = 1; $values['source_data'] = $recon_task_id; diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 6613daea79..61cfba9e97 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -315,8 +315,6 @@ if (is_ajax() === true) { $("#source").change(function() { const source = $(this).val(); - console.log("aaaaaaaaaaaaaaaa"); - if (source == \'recon_task\') { $("#form_editor-source_data_ip_mask") .css(\'display\', \'none\'); From 8ca25c01a2e4e8db00d3b23bc8a1d9bc5866ba65 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 Feb 2023 17:11:19 +0100 Subject: [PATCH 109/182] #10384 Sql error correction delete modules in bulk --- pandora_console/include/functions_modules.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 15c6da909e..aa45aacc10 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -519,12 +519,13 @@ function modules_delete_agent_module($id_agent_module) 'disabled' => 1, 'delete_pending' => 1, ]; - $result = db_process_sql_update( + $id_agent = db_process_sql_update( 'tagente_modulo', $values, ['id_agente_modulo' => $id_borrar_modulo] ); - if ($result === false) { + + if ($id_agent === false) { $error++; } else { // Set flag to update module status count. @@ -562,7 +563,7 @@ function modules_delete_agent_module($id_agent_module) $result = db_process_delete_temp( 'ttag_module', 'id_agente_modulo', - $id_borrar_modulo + $id_agent ); if ($result === false) { $error++; From 1d62129357ef41d17af10f6bdd3de92d9b3c79b9 Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 14 Feb 2023 01:01:40 +0100 Subject: [PATCH 110/182] 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 7802c679e5..cb4b34773f 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.768-230213 +Version: 7.0NG.768-230214 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 eb4279b84f..2fdf61f38b 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.768-230213" +pandora_version="7.0NG.768-230214" 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 1668a50e86..9d3cc8cba6 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.768'; -use constant AGENT_BUILD => '230213'; +use constant AGENT_BUILD => '230214'; # 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 4482ace58a..7a8736a942 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_linux %define version 7.0NG.768 -%define release 230213 +%define release 230214 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 1b07645a58..e3a4334b3d 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_linux %define version 7.0NG.768 -%define release 230213 +%define release 230214 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 601db13b4b..ba729305b9 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230213" +PI_BUILD="230214" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 1cf8ab41dc..15174f2833 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230213} +{230214} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index d44d4eb5a1..5138ad8fe4 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.768 Build 230213") +#define PANDORA_VERSION ("7.0NG.768 Build 230214") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index e983b3cba2..bcba63f1ba 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.768(Build 230213))" + VALUE "ProductVersion", "(7.0NG.768(Build 230214))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8b393620b9..5fdad46edb 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.768-230213 +Version: 7.0NG.768-230214 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 399096ff6a..02c7869a01 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.768-230213" +pandora_version="7.0NG.768-230214" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 5a8c0631b1..a38089f89a 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 = 'PC230213'; +$build_version = 'PC230214'; $pandora_version = 'v7.0NG.768'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 835b2efaea..77ba7bc29c 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 90ebdbf8bc..8dbbf2efa9 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.768 -%define release 230213 +%define release 230214 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 9698e8c1dc..e4390722e2 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.768 -%define release 230213 +%define release 230214 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 52e6b86b35..1f651d7741 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.768" -PI_BUILD="230213" +PI_BUILD="230214" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index d29d04b6a7..77d8749d2d 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.768 Build 230213"; +my $version = "7.0NG.768 Build 230214"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 378688aa67..e3522c3c6a 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.768 Build 230213"; +my $version = "7.0NG.768 Build 230214"; # save program name for logging my $progname = basename($0); From 9c4a0f8a2bcae7f3094f8d72a3ff2a5917767ff6 Mon Sep 17 00:00:00 2001 From: Calvo Date: Tue, 14 Feb 2023 09:03:51 +0100 Subject: [PATCH 111/182] Agent library error notification --- pandora_console/include/class/ConsoleSupervisor.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 17d7b2213a..1f82d1cea0 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -258,6 +258,14 @@ class ConsoleSupervisor $this->checkSyncQueueStatus(); } + /* + * Checkc agent missing libraries. + * NOTIF.AGENT.LIBRARY + */ + if ((bool) enterprise_installed() === true) { + $this->checkLibaryError(); + } + } @@ -2832,7 +2840,8 @@ class ConsoleSupervisor 'message' => __( 'There are omnishell agents with dependency errors', ), - 'url' => $url, + + 'url' => '__url__/index.php?sec=gextensions&sec2=enterprise/tools/omnishell', ] ); } From 55347713516a40fdf30bd36ce97acce723b4f657 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 14 Feb 2023 10:24:08 +0100 Subject: [PATCH 112/182] added all nodes option in sql query report item in meta --- .../reporting_builder.item_editor.php | 26 ++++- .../include/functions_reporting.php | 109 ++++++++++++++++-- 2 files changed, 123 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 80e72e65cf..8c66b583ee 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1233,6 +1233,29 @@ $class = 'databox filters'; } ?> + 'All nodes'], $servers); + if ($meta) { + ?> + + + + + + + + @@ -6334,6 +6357,7 @@ function chooseType() { $("#row_alert_templates").hide(); $("#row_alert_actions").hide(); $("#row_servers").hide(); + $("#row_servers_all_opt").hide(); $("#row_multiple_servers").hide(); $("#row_sort").hide(); $("#row_date").hide(); @@ -6648,7 +6672,7 @@ function chooseType() { $("#row_header").show(); $("#row_custom").show(); $("#row_custom_example").show(); - $("#row_servers").show(); + $("#row_servers_all_opt").show(); $("#row_historical_db_check").show(); break; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 637ae59752..c17745da8b 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -68,6 +68,7 @@ define('REPORT_STATUS_IGNORED', 5); // Clases. use PandoraFMS\Enterprise\Metaconsole\Node; +use PandoraFMS\Enterprise\Metaconsole\Synchronizer; use PandoraFMS\Event; use PandoraFMS\Module; @@ -7421,6 +7422,14 @@ function reporting_text($report, $content) } +/** + * Build SQL report item. + * + * @param array $report Report info. + * @param array $content Content info. + * + * @return array + */ function reporting_sql($report, $content) { global $config; @@ -7438,15 +7447,97 @@ function reporting_sql($report, $content) $return['description'] = $content['description']; $return['date'] = reporting_get_date_text(); - if ($config['metaconsole'] && !empty($content['server_name'])) { - $id_meta = metaconsole_get_id_server( + if (is_metaconsole() === true + && empty($content['server_name']) === false + && $content['server_name'] !== 'all' + ) { + $id_server = metaconsole_get_id_server( $content['server_name'] ); - - $server = metaconsole_get_connection_by_id($id_meta); - metaconsole_connect($server); } + if (is_metaconsole() === true && $content['server_name'] === 'all') { + $sync = new Synchronizer(); + $results = $sync->apply( + function ($node) use ($report, $content) { + try { + $node->connect(); + $rs = reporting_sql_auxiliary($report, $content); + $node->disconnect(); + } catch (Exception $e) { + return [ + 'error' => __( + 'Failed to connect to node %s', + $node->server_name() + ), + ]; + } + + if ($rs === false) { + return ['result' => []]; + } + + return ['result' => $rs]; + }, + false + ); + + $data = []; + $return['correct'] = 1; + $return['error'] = ''; + + foreach ($results as $id_node => $items) { + foreach ($items['result']['data'] as $key => $item) { + $items['result']['data'][$key] = ['node_id' => $id_node] + $items['result']['data'][$key]; + } + + if ((int) $items['result']['correct'] !== 1) { + $return['correct'] = 0; + } + + if ($items['result']['error'] !== '') { + $return['error'] = $items['result']['error']; + } + + $return['sql'] = $items['result']['sql']; + + $data = array_merge($data, $items['result']['data']); + } + + $return['data'] = $data; + } else { + try { + if (is_metaconsole() === true && $id_server > 0) { + $node = new Node($id_server); + $node->connect(); + } + + $query_result = reporting_sql_auxiliary($report, $content); + $return = array_merge($return, $query_result); + + if (is_metaconsole() === true && $id_server > 0) { + $node->disconnect(); + } + } catch (\Exception $e) { + if (is_metaconsole() === true && $id_server > 0) { + $node->disconnect(); + } + } + } + + return reporting_check_structure_content($return); +} + + +/** + * Auxiliary function for reporting_sql. + * + * @param array $report Report info. + * @param array $content Content info. + * + * @return array + */ +function reporting_sql_auxiliary($report, $content) { if ($content['treport_custom_sql_id'] != 0) { $sql = io_safe_output( db_get_value_filter( @@ -7459,7 +7550,7 @@ function reporting_sql($report, $content) $sql = $content['external_source']; } - // Check if exist sql macro. + // Check if SQL macro exists. $sql = reporting_sql_macro($report, $sql); // Do a security check on SQL coming from the user. @@ -7514,11 +7605,7 @@ function reporting_sql($report, $content) $return['error'] = __('Illegal query: Due security restrictions, there are some tokens or words you cannot use: *, delete, drop, alter, modify, password, pass, insert or update.'); } - if ($config['metaconsole'] && !empty($content['server_name'])) { - metaconsole_restore_db(); - } - - return reporting_check_structure_content($return); + return $return; } From ccb0cda3057fa784e0675723031d1732a7113da8 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 14 Feb 2023 12:16:38 +0100 Subject: [PATCH 113/182] #10118 changed CIDR input --- .../include/class/NetworkMap.class.php | 4 ++- .../include/functions_networkmap.php | 15 ++++++----- .../agentes/pandora_networkmap.editor.php | 26 ++++++++++++++++++- .../agentes/pandora_networkmap.view.php | 11 +++++++- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index ebfa966a9b..3f1a5f6e9a 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -782,7 +782,9 @@ class NetworkMap if ($this->network) { // Network map, based on direct network. $nodes = networkmap_get_nodes_from_ip_mask( - $this->network + $this->network, + false, + ' ' ); } else if ($this->mapOptions['map_filter']['empty_map']) { // Empty map returns no data. diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 120af5b571..de685384be 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -1356,9 +1356,10 @@ function networkmap_get_types($strict_user=false) */ function networkmap_get_nodes_from_ip_mask( $ip_mask, - $return_ids_only=false + $return_ids_only=false, + $separator=',', ) { - $list_ip_masks = explode(',', $ip_mask); + $list_ip_masks = explode($separator, $ip_mask); if (empty($list_ip_masks) === true) { return []; @@ -1375,14 +1376,14 @@ function networkmap_get_nodes_from_ip_mask( $sql = sprintf( 'SELECT * FROM `tagente` - INNER JOIN - (SELECT DISTINCT `id_agent` FROM + INNER JOIN + (SELECT DISTINCT `id_agent` FROM (SELECT `id_agente` AS "id_agent", `direccion` AS "ip" - FROM `tagente` + FROM `tagente` UNION SELECT ag.`id_agent`, a.`ip` - FROM `taddress_agent` ag - INNER JOIN `taddress` a + FROM `taddress_agent` ag + INNER JOIN `taddress` a ON ag.id_a=a.id_a ) t_tmp WHERE (-1 << %d) & INET_ATON(t_tmp.ip) = INET_ATON("%s") diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index 0d2c7193e1..59f2befad4 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -273,6 +273,21 @@ if (!empty($result)) { if ($not_found) { ui_print_error_message(__('Not found networkmap.')); } else { + if ($disabled_source === false) { + $info1 = __('To create a network map that visually recreates link-level (L2) relationships, you must first discover these relationships with Discovery Server. Network maps only reflect relationships that have already been discovered.'); + $separator = '
'; + $info2 = __('Discovery Server discovers relationships between interfaces (L2) through SNMP and relationships between hosts (L3) through route discovery.'); + $info3 = __('You can also create these relationships manually by editing nodes or re-passing a discovery task after adding new information (for example by adding new SNMP communities).'); + $info4 = __('See our documentation for more information.'); + ui_print_info_message( + [ + 'no_close' => false, + 'message' => $info1.$separator.$info2.$separator.$info3.$separator.$info4, + ], + 'style="width: 98%;"' + ); + } + $table = new stdClass(); $table->id = 'form_editor'; @@ -401,7 +416,16 @@ if ($not_found) { ); $table->data['source_data_ip_mask'][0] = __('Source from CIDR IP mask'); - $table->data['source_data_ip_mask'][1] = html_print_input_text('ip_mask', $ip_mask, '', 20, 255, true, $disabled_source); + $table->data['source_data_ip_mask'][1] = html_print_textarea( + 'ip_mask', + 3, + 5, + $ip_mask, + 'style="width: 238px"', + true, + '', + $disabled_source + ); $table->data['source_data_group'][0] = __('Source group'); $table->data['source_data_group'][1] = '
'.html_print_select_groups( diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 61cfba9e97..d85264b093 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -237,7 +237,16 @@ if (is_ajax() === true) { ); $table->data['source_data_ip_mask'][0] = __('Source from CIDR IP mask'); - $table->data['source_data_ip_mask'][1] = html_print_input_text('ip_mask', $map_info['source_data'], '', 20, 255, true); + $table->data['source_data_ip_mask'][1] = html_print_textarea( + 'ip_mask', + 3, + 5, + $map_info['source_data'], + '', + true, + '', + $disabled_source + ); $dont_show_subgroups = 0; if (isset($map_filter['dont_show_subgroups'])) { From 856fade86cfe187f715cc0db73fdff42f2b3631f Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 14 Feb 2023 14:45:46 +0100 Subject: [PATCH 114/182] #10118 Added spinner --- .../operation/agentes/pandora_networkmap.editor.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index 59f2befad4..a638bc9aa9 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -274,6 +274,10 @@ if ($not_found) { ui_print_error_message(__('Not found networkmap.')); } else { if ($disabled_source === false) { + echo '
'; + echo html_print_image('images/spinner.gif', true, 'width: 50px;height: 50px;'); + echo '
'.__('Creating map...').'
'; + echo '
'; $info1 = __('To create a network map that visually recreates link-level (L2) relationships, you must first discover these relationships with Discovery Server. Network maps only reflect relationships that have already been discovered.'); $separator = '
'; $info2 = __('Discovery Server discovers relationships between interfaces (L2) through SNMP and relationships between hosts (L3) through route discovery.'); @@ -546,6 +550,7 @@ if ($not_found) {