diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 216e3149e3..f1cc960a5c 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -122,6 +122,7 @@ module_min_critical 91 module_max_critical 0 module_end + # Number processes module_begin module_name Number processes diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 574029ce9f..31b1752a4e 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.775-240220 +Version: 7.0NG.775-240223 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 2b0d9e0fb4..501e690c23 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.775-240220" +pandora_version="7.0NG.775-240223" 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 5a963ef6e5..81bdfc118f 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1039,7 +1039,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.775'; -use constant AGENT_BUILD => '240220'; +use constant AGENT_BUILD => '240223'; # 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 53d0db8510..bd06b0e4fc 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240220 +%define release 240223 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec index 3e053d1139..4818693de8 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240220 +%define release 240223 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec index 2d3be11084..6e304c3849 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240220 +%define release 240223 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index 78495c142d..36ace10ab4 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240220 +%define release 240223 Summary: Pandora FMS Linux agent, binary version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index ae7336afaa..7d1bd6f6f7 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240220 +%define release 240223 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 4231f83ca3..2935baa16a 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240220" +PI_BUILD="240223" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 2ff61033c6..cdde841254 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -157,8 +157,8 @@ ehorus_conf "C:\Program Files\ehorus_agent\ehorus_agent.conf" module_begin module_name CPU Load module_type generic_data -module_wmiquery SELECT LoadPercentage FROM Win32_Processor -module_wmicolumn LoadPercentage +module_wmiquery SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor where name like '_Total' +module_wmicolumn PercentProcessorTime module_max 100 module_min 0 module_description User CPU Usage (%) diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index dfdeecea3d..7ef6c38b49 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{240220} +{240223} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 0f7f128e46..05557e696c 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.775 Build 240220") +#define PANDORA_VERSION ("7.0NG.775 Build 240223") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ff6ed8fa7e..9de5fc525c 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.775(Build 240220))" + VALUE "ProductVersion", "(7.0NG.775(Build 240223))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index cab607fc18..40d89f5b8c 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.775-240220 +Version: 7.0NG.775-240223 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 610e452556..b6e0dc13a3 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.775-240220" +pandora_version="7.0NG.775-240223" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 90c9527e55..0b43ce0bba 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -496,6 +496,10 @@ function mainAgentsModules() $agents = []; } + if (isset($agents_id) === false) { + $agents_id = ''; + } + $filter_agents = html_print_label_input_block( __('Agents'), html_print_select( diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 957d3a17a1..15c9e614ee 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -91,7 +91,7 @@ function mainModuleGroups() $module_group_search = get_parameter('module_group_search', ''); // Check the user's group permissions. - $user_groups = users_get_groups($config['user'], 'AR'); + $user_groups = users_get_groups($config['id_user'], 'AR'); $info = array_filter( $info, function ($v) use ($user_groups) { @@ -112,7 +112,7 @@ function mainModuleGroups() ); if (empty($info) === false) { - $groups_view = ($is_not_paginated) ? $info : array_slice( + $groups_view = (isset($is_not_paginated) === true) ? $info : array_slice( $info, $offset, $config['block_size'] @@ -374,6 +374,10 @@ function mainModuleGroups() '…' ); $j = 1; + if (isset($background_color) === false) { + $background_color = 'none'; + } + if (isset($array_data[$key])) { foreach ($value['gm'] as $k => $v) { if (isset($array_data[$key][$k])) { diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index a3f5872f84..d47d65ef56 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -273,6 +273,14 @@ function buildConnectionURL($method) { global $config; + if (isset($config['gotty_ssh_use_ssl']) === false) { + $config['gotty_ssh_use_ssl'] = ''; + } + + if (isset($config['gotty_telnet_use_ssl']) === false) { + $config['gotty_telnet_use_ssl'] = ''; + } + $address = (empty($config['gotty_addr']) === true) ? $_SERVER['SERVER_ADDR'] : $config['gotty_addr']; $use_ssl = ($method === 'ssh') ? $config['gotty_ssh_use_ssl'] : $config['gotty_telnet_use_ssl']; $protocol = ((bool) $use_ssl === true) ? 'https://' : 'http://'; @@ -353,6 +361,18 @@ function quickShellSettings() config_update_value('gotty_telnet_enabled', $gotty_telnet_enabled); } + if (isset($config['gotty_addr']) === false) { + $config['gotty_addr'] = ''; + } + + if (isset($config['gotty_ssh_use_ssl']) === false) { + $config['gotty_ssh_use_ssl'] = ''; + } + + if (isset($config['gotty_telnet_use_ssl']) === false) { + $config['gotty_telnet_use_ssl'] = ''; + } + if ($config['gotty_addr'] != $gotty_addr) { config_update_value('gotty_addr', $gotty_addr); } @@ -389,6 +409,25 @@ function quickShellSettings() $general_table->data = []; $general_table->style = []; $general_table->style[0] = 'width: 50%;'; + if (isset($config['gotty_addr']) === false) { + $config['gotty_addr'] = ''; + } + + if (isset($config['gotty_ssh_enabled']) === false) { + $config['gotty_ssh_enabled'] = ''; + } + + if (isset($config['gotty_ssh_use_ssl']) === false) { + $config['gotty_ssh_use_ssl'] = ''; + } + + if (isset($disable_agentaccess) === false) { + $disable_agentaccess = ''; + } + + if (isset($config['gotty_telnet_use_ssl']) === false) { + $config['gotty_telnet_use_ssl'] = ''; + } $general_table->data[0][] = html_print_label_input_block( __('Address'), diff --git a/pandora_console/extensions/users_connected.php b/pandora_console/extensions/users_connected.php index 4b76957344..712dcd014d 100644 --- a/pandora_console/extensions/users_connected.php +++ b/pandora_console/extensions/users_connected.php @@ -229,7 +229,7 @@ function users_extension_main_god($god=true) $data = []; $data[0] = ''.$row['id_user'].''; - $data[1] = $last_login_data['ip_origin']; + $data[1] = $last_login_data['ip_origen']; $data[2] = date($config['date_format'], $last_login_data['utimestamp']); $data[3] = date($config['date_format'], $row['last_connect']); array_push($table->data, $data); diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index 4d53485fe6..453a4ead7f 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -62,6 +62,8 @@ ADD COLUMN `id_agent_data` int not null default 0 AFTER `script_type`; ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ; ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT NULL AFTER `url`; +ALTER TABLE `tagente_modulo` ADD COLUMN `disabled_by_safe_mode` TINYINT UNSIGNED NOT NULL DEFAULT 0; + UPDATE `tncm_template` SET `vendors` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM vendors))), '"]'), `models` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM models))), '"]'); UPDATE `tncm_agent_data_template` SET `vendors` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM vendors))), '"]'), `models` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM models))), '"]'); diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e2573bd859..5eee6a6669 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -161,6 +161,10 @@ echo sprintf('
', $menuTypeClass); 'code' => false, ]; + if (isset($_GET['sec']) === false) { + $_GET['sec'] = ''; + } + if (!isset($_GET['sec2'])) { $_GET['sec2'] = ''; } diff --git a/pandora_console/general/noaccess.php b/pandora_console/general/noaccess.php index b2fe4515a2..9299489864 100644 --- a/pandora_console/general/noaccess.php +++ b/pandora_console/general/noaccess.php @@ -152,9 +152,11 @@ echo __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance.'); echo '

'; echo __('Please know that all attempts to access this page are recorded in security logs of %s System Database', get_product_name()); - if ($config['logged'] == false) { - if (session_status() === PHP_SESSION_ACTIVE) { - session_destroy(); + if (isset($config['logged']) === true) { + if ($config['logged'] == false) { + if (session_status() === PHP_SESSION_ACTIVE) { + session_destroy(); + } } } ?> diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 18722508e9..36d2458be7 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -246,6 +246,7 @@ if ($new_agent === true) { // QR Code table. +$CodeQRContent = ''; if ($new_agent === false) { $CodeQRContent .= html_print_div(['id' => 'qr_container_image'], true); $CodeQRContent .= html_print_anchor( diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c6b5f2b691..6a1084e605 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -816,6 +816,23 @@ if ($id_agente) { $helper = ($help_header === 'main_tab') ? 'main_tab' : ''; $pure = (int) get_parameter('pure'); + $menu_tabs = []; + // Agent details. + $menu_tab_url = ''.__('General setup').''; + array_push($menu_tabs, $menu_tab_url); + // Agent details. + $menu_tab_url = ''.__('Agent detail').''; + array_push($menu_tabs, $menu_tab_url); + // Manage agents. + $menu_tab_url = ''.__('Manage agents').''; + array_push($menu_tabs, $menu_tab_url); + // Events. + $menu_tab_url = ''.__('View events').''; + array_push($menu_tabs, $menu_tab_url); + // Events. + $menu_tab_url = ''.__('Custom reports').''; + array_push($menu_tabs, $menu_tab_url); + $dots = dot_tab($menu_tabs); if ($pure === 0) { ui_print_standard_header( __('Agent setup view').' ( '.strtolower(agents_get_alias($id_agente)).' )', @@ -837,7 +854,9 @@ if ($id_agente) { 'link' => '', 'label' => $tab_name, ], - ] + ], + [], + $dots ); } } else { @@ -857,7 +876,9 @@ if ($id_agente) { 'link' => 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente', 'label' => __('Manage agents'), ], - ] + ], + [], + $dots ); } @@ -2334,6 +2355,23 @@ if ($delete_module) { exit; } + // Check if module is used by agent for Safe mode. + $is_safe_mode_module = modules_check_safe_mode($id_borrar_modulo); + if ($is_safe_mode_module === true && isset($id_agente) === true) { + db_process_sql_update('tagente', ['safe_mode_module' => '0'], ['id_agente' => $id_agente]); + db_process_sql_update( + 'tagente_modulo', + [ + 'disabled' => 0, + 'disabled_by_safe_mode' => 0, + ], + [ + 'id_agente' => $id_agente, + 'disabled_by_safe_mode' => 1, + ] + ); + } + // Before delete the main module, check and delete the childrens from the original module. module_check_childrens_and_delete($id_borrar_modulo); diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 904b807bbd..44332487ce 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -55,7 +55,7 @@ if ($id_field) { $display_on_front = $field['display_on_front']; $is_password_type = $field['is_password_type']; $combo_values = $field['combo_values'] ? $field['combo_values'] : ''; - $is_combo_enable = $config['is_combo_enable']; + $is_combo_enable = (isset($config['is_combo_enable']) === true) ? $config['is_combo_enable'] : false; $is_link_enabled = $field['is_link_enabled']; $header_title = __('Update agent custom field'); } else { @@ -162,6 +162,10 @@ $table->data[2][0] = html_print_label_input_block( ) ); +if (isset($config['is_combo_enable']) === false) { + $config['is_combo_enable'] = false; +} + $table->data[2][1] = html_print_label_input_block( __('Enabled combo'), html_print_checkbox_switch_extended( diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index abbbc4d9c1..affa225969 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -164,12 +164,13 @@ foreach ($password_fields as $k => $p) { return; } - const moduleId = ; - + const moduleId = 0) ? $module['id'] : $id_agent_module; ?>; + const isPolicy = 0) ? '1' : '0'; ?>; + load_plugin_description($("#id_plugin").val()); - - load_plugin_macros_fields('simple-macro', moduleId); - + + load_plugin_macros_fields('simple-macro', moduleId, isPolicy); + forced_title_callback(); $('select#id_plugin').select2('close'); diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index a5b4de7c80..b242e41e29 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -109,7 +109,7 @@ if (is_ajax()) { for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $field_description = $fields_descriptions[($i - 1)]; $field_value = $fields_values[($i - 1)]; - $field_hidden = $fields_hidden_checked[($i - 1)]; + $field_hidden = (isset($fields_hidden_checked[($i - 1)]) === true) ? $fields_hidden_checked[($i - 1)] : ''; if (!empty($field_description)) { diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 5d71895ecd..fe0790f71b 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -253,7 +253,7 @@ if (is_metaconsole() === true) { echo '
'; } -if (!$id_cluster) { +if (isset($id_cluster) === false) { ui_toggle( $form_filter, ''.__('Alert control filter').'', @@ -1115,7 +1115,7 @@ if (isset($dont_display_alert_create_bttn)) { } } -if ($display_create && (check_acl($config['id_user'], 0, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) && !$id_cluster) { +if ($display_create && (check_acl($config['id_user'], 0, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) && isset($id_cluster) === false) { echo '
'; $actionButtons = html_print_submit_button( __('Create'), diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index 46095b6efb..02a221fee8 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -242,6 +242,7 @@ if (empty($result) === false) { html_print_table($table); $tablePagination = ui_pagination($total_categories, $url, $offset, 0, true, 'offset', false); } else { + $tablePagination = ''; // No categories available or selected. ui_print_info_message(['no_close' => true, 'message' => __('No categories found') ]); } diff --git a/pandora_console/godmode/extensions.php b/pandora_console/godmode/extensions.php index 3ff09273c6..3db36f71a9 100644 --- a/pandora_console/godmode/extensions.php +++ b/pandora_console/godmode/extensions.php @@ -195,13 +195,13 @@ foreach ($extensions as $file => $extension) { $data[] = ''.$file.''; // Get version of this extensions - if ($config['extensions'][$file]['operation_menu']) { + if (isset($config['extensions'][$file]['operation_menu']) === true) { $data[] = $config['extensions'][$file]['operation_menu']['version']; - } else if ($config['extensions'][$file]['godmode_menu']) { + } else if (isset($config['extensions'][$file]['godmode_menu']) === true) { $data[] = $config['extensions'][$file]['godmode_menu']['version']; - } else if ($config['extensions'][$file]['extension_ope_tab']) { + } else if (isset($config['extensions'][$file]['extension_ope_tab']) === true) { $data[] = $config['extensions'][$file]['extension_ope_tab']['version']; - } else if ($config['extensions'][$file]['extension_god_tab']) { + } else if (isset($config['extensions'][$file]['extension_god_tab']) === true) { $data[] = $config['extensions'][$file]['extension_god_tab']['version']; } else { $data[] = __('N/A'); @@ -216,7 +216,7 @@ foreach ($extensions as $file => $extension) { $data[] = $config['extensions'][$file]['godmode_menu']['version']; } else if (isset($config['extensions'][$file]['extension_ope_tab'])) { $data[] = $config['extensions'][$file]['extension_ope_tab']['version']; - } else if ($config['extensions'][$file]['extension_god_tab']) { + } else if (isset($config['extensions'][$file]['extension_god_tab']) === true) { $data[] = $config['extensions'][$file]['extension_god_tab']['version']; } else { $data[] = __('N/A'); diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index f1b40867d9..6aad60e71d 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -1205,9 +1205,9 @@ $tab = 'group_edition'; '; $output .= '
'; @@ -58,9 +66,11 @@ if ($files !== false) { } } -if ($files64 !== false) { - foreach ($files64 as $key => $file) { - $output .= ''; +if (isset($files64) === true) { + if ($files64 !== false) { + foreach ($files64 as $key => $file) { + $output .= ''; + } } } diff --git a/pandora_plugins/web_check/web_check_lwp.pl b/pandora_plugins/web_check/web_check_lwp.pl new file mode 100644 index 0000000000..73b1c0a028 --- /dev/null +++ b/pandora_plugins/web_check/web_check_lwp.pl @@ -0,0 +1,24 @@ +use strict; +use warnings; + +use LWP::UserAgent (); +use Data::Dumper; + +die "Usage: $0 \n" unless @ARGV == 3; + +my ($URL, $username, $password) = @ARGV; + +my $ua = LWP::UserAgent->new(timeout => 10); +$ua->protocols_allowed( ['http', 'https'] ); +$ua->ssl_opts("verify_hostname" => 0); + +$ua->credentials($URL, "", $username, $password); + +my $response = $ua->get($URL); + +if ($response->is_success) { + print $response->decoded_content; +} +else { + die print(Dumper($response)); +} diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 32dda79f86..bf7886e02f 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.775-240220 +Version: 7.0NG.775-240223 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 73676e3385..d6b1c3b013 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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.775-240220" +pandora_version="7.0NG.775-240223" package_cpan=0 package_pandora=1 diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 1945cbd08f..f7d4df74aa 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -816,5 +816,8 @@ madeserver_autofit 7d # Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY). madeserver_sensitivity 0.1 +# If greater than 0, generate an event when more than the specified number of XML data files are queued for an agent. +too_many_xml 10 + # Encoding to use on mail subject (MIME-Header by default) -# mail_subject_encoding MIME-Header-ISO_2022_JP \ No newline at end of file +# mail_subject_encoding MIME-Header-ISO_2022_JP diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 707da83437..75b1303f7d 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -46,7 +46,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.775"; -my $pandora_build = "240220"; +my $pandora_build = "240223"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -589,6 +589,8 @@ sub pandora_load_config { $pa_config->{"madeserver"} = 0; # 774. + $pa_config->{"too_many_xml"} = 10; # 776. + $pa_config->{"mail_subject_encoding"} = 'MIME-Header'; # 776. # Check for UID0 @@ -1417,6 +1419,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^madeserver\s+([0-1])/i){ $pa_config->{'madeserver'}= clean_blank($1); } + elsif ($parametro =~ m/^too_many_xml\s+([0-9]*)/i){ + $pa_config->{'too_many_xml'}= clean_blank($1); + } } # end of loop for parameter # # The DB host was overridden by pandora_ha. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3dd7397a48..5d3d34f870 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -7197,12 +7197,15 @@ sub pandora_disable_autodisable_agents ($$) { SELECT tm.id_agente, count(*) as sync_modules, ta.unknown_count FROM tagente_modulo tm JOIN tagente ta ON ta.id_agente = tm.id_agente + LEFT JOIN tagente_estado te ON tm.id_agente_modulo = te.id_agente_modulo WHERE ta.disabled = 0 + AND ta.modo=2 + AND te.estado != 4 + AND tm.delete_pending=0 AND NOT ((id_tipo_modulo >= 21 AND id_tipo_modulo <= 23) OR id_tipo_modulo = 100) GROUP BY tm.id_agente ) AS subquery - WHERE subquery.unknown_count >= subquery.sync_modules;'; - + WHERE subquery.unknown_count >= subquery.sync_modules;'; my @agents_autodisabled = get_db_rows ($dbh, $sql); return if ($#agents_autodisabled < 0); @@ -7767,12 +7770,12 @@ sub safe_mode($$$$$$) { # Going to critical. Disable the rest of the modules. if ($new_status == MODULE_CRITICAL) { logger($pa_config, "Enabling safe mode for agent " . $agent->{'nombre'}, 10); - db_do($dbh, 'UPDATE tagente_modulo SET disabled=1 WHERE id_agente=? AND id_agente_modulo!=?', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); + db_do($dbh, 'UPDATE tagente_modulo SET disabled=1, disabled_by_safe_mode=1 WHERE id_agente=? AND id_agente_modulo!=? AND disabled=0', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); } # Coming back from critical. Enable the rest of the modules. elsif ($known_status == MODULE_CRITICAL) { logger($pa_config, "Disabling safe mode for agent " . $agent->{'nombre'}, 10); - db_do($dbh, 'UPDATE tagente_modulo SET disabled=0 WHERE id_agente=? AND id_agente_modulo!=?', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); + db_do($dbh, 'UPDATE tagente_modulo SET disabled=0, disabled_by_safe_mode=0 WHERE id_agente=? AND id_agente_modulo!=? AND disabled_by_safe_mode=1', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); # Prevent the modules from becoming unknown! db_do ($dbh, 'UPDATE tagente_estado SET utimestamp = ? WHERE id_agente = ? AND id_agente_modulo!=?', time(), $agent->{'id_agente'}, $module->{'id_agente_modulo'}); @@ -7798,7 +7801,7 @@ sub pandora_safe_mode_modules_update { # If status is critical, disable the rest of the modules. if ($status == MODULE_CRITICAL) { logger($pa_config, "Update modules for safe mode agent with alias:" . $agent->{'alias'} . ".", 10); - db_do($dbh, 'UPDATE tagente_modulo SET disabled=1 WHERE id_agente=? AND id_agente_modulo!=?', $agent_id, $agent->{'safe_mode_module'}); + db_do($dbh, 'UPDATE tagente_modulo SET disabled=1, disabled_by_safe_mode=1 WHERE id_agente=? AND id_agente_modulo!=? AND disabled=0', $agent_id, $agent->{'safe_mode_module'}); } } diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 6125a68e20..8a72ef7605 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -56,6 +56,7 @@ our @ISA = qw(PandoraFMS::ProducerConsumerServer); my @TaskQueue :shared; my %PendingTasks :shared; my %Agents :shared; +my %AgentCounts; my $Sem :shared; my $TaskSem :shared; my $AgentSem :shared; @@ -73,6 +74,7 @@ sub new ($$;$) { @TaskQueue = (); %PendingTasks = (); %Agents = (); + %AgentCounts = (); $Sem = Thread::Semaphore->new; $TaskSem = Thread::Semaphore->new (0); $AgentSem = Thread::Semaphore->new (1); @@ -142,6 +144,9 @@ sub data_producer ($) { opendir (DIR, $pa_config->{'incomingdir'}) || die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!"; + # Reset agent XML file counts + %AgentCounts = (); + # Do not read more than max_queue_files files my $file_count = 0; while (my $file = readdir (DIR)) { @@ -177,11 +182,21 @@ sub data_producer ($) { next if ($file !~ /^(.*)[\._]\d+\.data$/); my $agent_name = $1; + $AgentCounts{$agent_name} = defined($AgentCounts{$agent_name}) ? $AgentCounts{$agent_name} + 1 : 1; next if (agent_lock($pa_config, $dbh, $agent_name) == 0); push (@tasks, $file); } + # Generate an event if there are too many XML files for a given agent. + if ($pa_config->{'too_many_xml'} > 0) { + while (my ($agent_name, $xml_count) = each(%AgentCounts)) { + if ($xml_count > $pa_config->{'too_many_xml'}) { + pandora_timed_event(300, $pa_config, "More than " . $pa_config->{'too_many_xml'} . " XML files queued for agent $agent_name", 0, 0, 0, 0, 0, 'warning', 0, $dbh); + } + } + } + return @tasks; } @@ -200,6 +215,9 @@ sub data_producer_smart_queue ($) { opendir (DIR, $pa_config->{'incomingdir'}) || die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!"; + # Reset agent XML file counts + %AgentCounts = (); + # Do not read more than max_queue_files files my $smart_queue = {}; while (my $file = readdir (DIR)) { @@ -209,6 +227,9 @@ sub data_producer_smart_queue ($) { next if ($file !~ /^(.*)[\._]\d+\.data$/); my $agent_name = $1; + # Update per agent XML counts. + $AgentCounts{$agent_name} = defined($AgentCounts{$agent_name}) ? $AgentCounts{$agent_name} + 1 : 1; + # Queue a new file. if (!defined($smart_queue->{$agent_name})) { $smart_queue->{$agent_name} = $file; @@ -229,6 +250,15 @@ sub data_producer_smart_queue ($) { push (@tasks, $file); } + # Generate an event if there are too many XML files for a given agent. + if ($pa_config->{'too_many_xml'} > 0) { + while (my ($agent_name, $xml_count) = each(%AgentCounts)) { + if ($xml_count > $pa_config->{'too_many_xml'}) { + pandora_timed_event(300, $pa_config, "More than " . $pa_config->{'too_many_xml'} . " XML files queued for agent $agent_name", 0, 0, 0, 0, 0, 'warning', 0, $dbh); + } + } + } + return @tasks; } diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index bc2ebd3ceb..d498494201 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.775"; -my $pandora_build = "240220"; +my $pandora_build = "240223"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index c3c3eac327..a0d1f17417 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240220 +%define release 240223 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 418e81db3b..80d046be93 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240220 +%define release 240223 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index fc83c77573..9e2cb1a0f1 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240220" +PI_BUILD="240223" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 76413d5d41..29fceb9e59 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.775 Build 240220"; +my $version = "7.0NG.775 Build 240223"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 7372926bdb..c8f80529a6 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.775 Build 240220"; +my $version = "7.0NG.775 Build 240223"; # save program name for logging my $progname = basename($0);