diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f59bb0ff18..5a22f8ecae 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.769-230227 +Version: 7.0NG.769-230228 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 a9ee5343bd..ac85303303 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.769-230227" +pandora_version="7.0NG.769-230228" 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 bddaac64d4..a994aabc8b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1023,7 +1023,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.769'; -use constant AGENT_BUILD => '230227'; +use constant AGENT_BUILD => '230228'; # 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 005d3a8bc3..1e35d4443c 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.769 -%define release 230227 +%define release 230228 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 07b3d30bdf..3519ff8837 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.769 -%define release 230227 +%define release 230228 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 f9ef95d7ab..ec3075858c 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230227" +PI_BUILD="230228" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c4f68463d7..2f2c4f1324 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230227} +{230228} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index c5bac1e0ac..9d41d77811 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.769 Build 230227") +#define PANDORA_VERSION ("7.0NG.769 Build 230228") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ad8addeb38..ab42fb366e 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.769(Build 230227))" + VALUE "ProductVersion", "(7.0NG.769(Build 230228))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 2a40cdd9c1..12ed651bf5 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.769-230227 +Version: 7.0NG.769-230228 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 8a957476bd..32b28e5e53 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.769-230227" +pandora_version="7.0NG.769-230228" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index 4be17f74cf..76c076e0af 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -230,7 +230,7 @@ function dbmgr_extension_main() 'dbport' => $node->dbport(), 'dbname' => $node->dbname(), 'dbuser' => $node->dbuser(), - 'dbpass' => $node->dbpass(), + 'dbpass' => io_output_password($node->dbpass()), ] ); $error = ''; 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/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 379d27fcca..0bd5d33830 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -391,7 +391,7 @@ foreach ($actions as $action) { $data = []; - $data[0] = ''.$action['name'].''; + $data[0] = ''.$action['name'].''; if ($action['id_group'] == 0 && $can_edit_all == false) { $data[0] .= ui_print_help_tip(__('You cannot edit this action, You don\'t have the permission to edit All group.'), true); } @@ -467,7 +467,7 @@ if (isset($data)) { if (is_management_allowed() === true) { echo '
'; - echo '
'; + echo ''; html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_input_hidden('create_alert', 1); echo '
'; diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 88a9500bb9..5a02e4814f 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -795,15 +795,16 @@ foreach ($commands as $command) { ); $data['action'] = ''; $table->cellclass[]['action'] = 'table_action_buttons'; + $offset_delete = ($offset >= ($total_commands - 1)) ? ($offset - $limit) : $offset; // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. if ($is_management_allowed === true && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { if (is_user_admin($config['id_user']) === true) { $data['action'] = ''; - $data['action'] .= ''.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).''; - $data['action'] .= ''.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).''; $data['action'] .= ''; } diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 0227f2eb93..78631ec803 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -352,7 +352,8 @@ if ($search_string) { $filter[] = "(name LIKE '%".$search_string."%' OR description LIKE '%".$search_string."%' OR value LIKE '%".$search_string."%')"; } -$filter['offset'] = (int) get_parameter('offset'); +$offset = (int) get_parameter('offset'); +$filter['offset'] = $offset; $filter['limit'] = (int) $config['block_size']; if (!is_user_admin($config['id_user'])) { $filter['id_group'] = array_keys(users_get_groups(false, 'LM')); @@ -420,7 +421,7 @@ foreach ($templates as $template) { && check_acl($config['id_user'], $template['id_group'], 'LM') ) { $table->cellclass[][4] = 'table_action_buttons'; - $data[4] = '
'; + $data[4] = ''; $data[4] .= html_print_input_hidden('duplicate_template', 1, true); $data[4] .= html_print_input_hidden('source_id', $template['id'], true); $data[4] .= html_print_input_image( diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 068026c953..240fa26fc3 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -372,8 +372,9 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) { ); } +$offset = (int) get_parameter('offset', 0); -echo ''; +echo ''; $table_html = html_print_table($table, true); echo $table_html; diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 670f48d939..6ec11274e5 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -1147,9 +1147,10 @@ if ($step == 2) { echo ui_get_using_system_timezone_warning(); } +$offset = (int) get_parameter('offset'); // If it's the last step it will redirect to template lists. if ($step >= LAST_STEP) { - echo ''; + echo ''; } else { echo ''; } diff --git a/pandora_console/godmode/groups/configure_modu_group.php b/pandora_console/godmode/groups/configure_modu_group.php index ee7e08d9d2..7e47cd87c5 100644 --- a/pandora_console/godmode/groups/configure_modu_group.php +++ b/pandora_console/godmode/groups/configure_modu_group.php @@ -57,6 +57,7 @@ $custom_id = ''; $create_group = (bool) get_parameter('create_group'); $id_group = (int) get_parameter('id_group'); +$offset = (int) get_parameter('offset', 0); if ($id_group) { $group = db_get_row('tmodule_group', 'id_mg', $id_group); @@ -86,9 +87,9 @@ $table->data[1][0] = html_print_input_text('name', $name, '', 35, 100, true); echo ''; if (is_metaconsole() === true) { - $formUrl = 'index.php?sec=advanced&sec2=advanced/component_management&tab=module_group'; + $formUrl = 'index.php?sec=advanced&sec2=advanced/component_management&tab=module_group&offset='.$offset; } else { - $formUrl = 'index.php?sec=gmodules&sec2=godmode/groups/modu_group_list'; + $formUrl = 'index.php?sec=gmodules&sec2=godmode/groups/modu_group_list&offset='.$offset; } echo ''; diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 83ecb54444..01229392d1 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -273,18 +273,18 @@ if (empty($groups) === false) { } $table->data = []; - + $offset_delete = ($offset >= $total_groups - 1) ? ($offset - $config['block_size']) : $offset; foreach ($groups as $id_group) { $data = []; $data[0] = $id_group['id_mg']; if ($is_management_allowed === true) { - $data[1] = ''.ui_print_truncate_text($id_group['name'], GENERIC_SIZE_TEXT).''; + $data[1] = ''.ui_print_truncate_text($id_group['name'], GENERIC_SIZE_TEXT).''; if (is_metaconsole() === true) { - $data[2] = ''.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; + $data[2] = ''.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; } else { $table->cellclass[][2] = 'table_action_buttons'; - $data[2] = ''.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; + $data[2] = ''.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; } } else { $data[1] = ''; 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, diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 6c8f7f5865..fd57e56f23 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -606,9 +606,10 @@ if ((bool) $id !== false || $new_component $search_id_group = (int) get_parameter('search_id_group'); $search_string = (string) get_parameter('search_string'); +$offset = (int) get_parameter('offset'); $url = ui_get_url_refresh( [ - 'offset' => false, + 'offset' => $offset, 'search_string' => $search_string, 'search_id_group' => $search_id_group, 'id' => $id, @@ -616,7 +617,7 @@ $url = ui_get_url_refresh( true, false ); - +$name_url = 'index.php?sec=templates&sec2=godmode/modules/manage_network_components'; $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; @@ -721,6 +722,8 @@ $total_components = network_components_get_network_components( 'COUNT(*) AS total' ); $total_components = $total_components[0]['total']; +$offset_delete = ($offset >= ($total_components - 1)) ? ($offset - $config['block_size']) : $offset; +ui_pagination($total_components, $name_url); $filter['offset'] = (int) get_parameter('offset'); $filter['limit'] = (int) $config['block_size']; $components = network_components_get_network_components( @@ -799,7 +802,7 @@ foreach ($components as $component) { true ); - $data[0] = ''; + $data[0] = ''; $data[0] .= io_safe_output($component['name']); $data[0] .= ''; } else { @@ -818,7 +821,7 @@ foreach ($components as $component) { $data[6] = html_print_anchor( [ - 'href' => $url.'&search_id_group='.$search_id_group.'search_string='.$search_string.'&duplicate_network_component=1&source_id='.$component['id_nc'], + 'href' => $url.'&search_id_group='.$search_id_group.'search_string='.$search_string.'&duplicate_network_component=1&source_id='.$component['id_nc'].'&offset='.$offset, 'content' => html_print_image( 'images/copy.svg', true, @@ -833,7 +836,7 @@ foreach ($components as $component) { $data[6] .= html_print_anchor( [ - 'href' => $url.'&delete_component=1&id='.$component['id_nc'].'&search_id_group='.$search_id_group.'search_string='.$search_string, + 'href' => $url.'&delete_component=1&id='.$component['id_nc'].'&search_id_group='.$search_id_group.'search_string='.$search_string.'&offset='.$offset_delete, 'onClick' => 'if (! confirm (\''.__('Are you sure?').'\')) return false', 'content' => html_print_image( 'images/delete.svg', @@ -866,8 +869,6 @@ html_print_table($table); html_print_input_hidden('multiple_delete', 1); echo ''; -$actionButtons = []; - if (isset($data) === false) { ui_print_info_message( [ @@ -877,6 +878,7 @@ if (isset($data) === false) { ); } +$actionButtons = []; if ($is_management_allowed === true) { $actionButtons[] = html_print_submit_button( __('Create'), diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index ecc25cd950..e7c61be8f8 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -151,6 +151,9 @@ if ($update_config == 1 && $config['history_db_enabled'] == 1) { } } +$total_agents = db_get_value('count(*)', 'tagente'); +$disable_agentaccess = ($total_agents >= 200 && $config['agentaccess'] == 0) ? true : false; + $table_status = new StdClass(); $table_status->width = '100%'; $table_status->class = 'databox filters'; @@ -590,7 +593,7 @@ $table_other->data[$i++][1] = html_print_input_text( ); $table_other->data[$i][0] = __('Use agent access graph'); -$table_other->data[$i++][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true); +$table_other->data[$i++][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true, $disable_agentaccess); $table_other->data[$i][0] = __('Max. recommended number of files in attachment directory'); $table_other->data[$i++][1] = html_print_input_text( diff --git a/pandora_console/godmode/tag/tag.php b/pandora_console/godmode/tag/tag.php index da4a638208..308fe6a1a8 100644 --- a/pandora_console/godmode/tag/tag.php +++ b/pandora_console/godmode/tag/tag.php @@ -207,14 +207,14 @@ if (empty($tag_name) === false) { // If the user has filtered the view. $filter_performed = !empty($filter); - -$filter['offset'] = (int) get_parameter('offset'); +$offset = (int) get_parameter('offset'); +$filter['offset'] = $offset; $filter['limit'] = (int) $config['block_size']; // Statements for pagination. -$url = ui_get_url_refresh(); +$url = 'index.php?sec=gusuarios&sec2=godmode/tag/tag'; $total_tags = tags_get_tag_count($filter); - +$offset_delete = ($offset >= ($total_tags - 1)) ? ($offset - $config['block_size']) : $offset; $result = tags_search_tag(false, $filter); // Filter form. @@ -392,7 +392,7 @@ if (empty($result) === false) { ] ); $data[6] .= ''; - $data[6] .= ''.html_print_image( + $data[6] .= ''.html_print_image( 'images/cross.png', true, [ diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index fd3d27cd8d..23f242f4b5 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -855,7 +855,7 @@ foreach ($info as $user_id => $user_info) { true ); /* - $data[6] = '
'; + $data[6] = ''; $data[6] .= html_print_input_hidden( 'id', $user_info['id_user'], @@ -932,7 +932,8 @@ foreach ($info as $user_id => $user_info) { && isset($user_info['not_delete']) === false ) { /* - $data[6] .= ''; + $offset_delete = ($offset >= count($info) - 1) ? ($offset - $config['block_size']) : $offset; + $data[6] .= ''; $data[6] .= html_print_input_hidden( 'delete_user', $user_info['id_user'], diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index bfa8e2fd68..837be70906 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -258,14 +258,21 @@ class ConsoleSupervisor $this->checkSyncQueueStatus(); } - /* - * Checkc agent missing libraries. - * NOTIF.AGENT.LIBRARY - */ + /* + * Check number of agents is equals and more than 200. + * NOTIF.ACCESSSTASTICS.PERFORMANCE + */ + + $this->checkAccessStatisticsPerformance(); + + /* + * Checkc agent missing libraries. + * NOTIF.AGENT.LIBRARY + */ + if ((bool) enterprise_installed() === true) { $this->checkLibaryError(); } - } @@ -527,13 +534,22 @@ class ConsoleSupervisor $this->checkSyncQueueStatus(); } + /* + * Check number of agents is equals and more than 200. + * NOTIF.ACCESSSTASTICS.PERFORMANCE + */ + + $this->checkAccessStatisticsPerformance(); + /* * Checkc agent missing libraries. * NOTIF.AGENT.LIBRARY */ + if ((bool) enterprise_installed() === true) { $this->checkLibaryError(); } + } @@ -548,6 +564,34 @@ class ConsoleSupervisor } + /** + * Check number of agents and disable agentaccess token if number + * is equals and more than 200. + * + * @return void + */ + public function checkAccessStatisticsPerformance() + { + $total_agents = db_get_value('count(*)', 'tagente'); + + if ($total_agents >= 200) { + db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']); + $this->notify( + [ + 'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE', + 'title' => __('Access statistics performance'), + 'message' => __( + 'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty' + ), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + ] + ); + } else { + $this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE'); + } + } + + /** * Update targets for given notification using object targets. * diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index e7273c3287..a853e7eef5 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 = 'PC230227'; +$build_version = 'PC230228'; $pandora_version = 'v7.0NG.769'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 688bdb782f..bd1577116c 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -11071,20 +11071,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', [ diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 705d67ab3b..8ed023ddde 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -159,6 +159,7 @@ function notifications_get_subtypes(?string $source=null) 'NOTIF.SERVER.STATUS', 'NOTIF.SERVER.QUEUE', 'NOTIF.SERVER.MASTER', + 'NOTIF.ACCESSSTASTICS.PERFORMANCE', ], ]; diff --git a/pandora_console/install.php b/pandora_console/install.php index d7451230e0..2a7bde9bb0 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
--row --column +python3 pandora_googlesheets.py --creds_json/creds_base64 --name --sheet --cell --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 + 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) + 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) diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index a4c5ada50d..2a1355e9c1 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.769-230227 +Version: 7.0NG.769-230228 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 d3ca335b86..2d309987f3 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.769-230227" +pandora_version="7.0NG.769-230228" package_cpan=0 package_pandora=1 diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 957d2d8f42..c6b1fc15bb 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -42,9 +42,6 @@ use PandoraFMS::PredictionServer; use PandoraFMS::WebServer; use PandoraFMS::InventoryServer; -# Constants for Win32 services. -use constant WIN32_SERVICE_STOPPED => 0x01; -use constant WIN32_SERVICE_RUNNING => 0x04; # Global vars my %Config :shared; @@ -255,7 +252,6 @@ sub pandora_crash () { print_message (\%Config, " Error description:\n", 0); print_message (\%Config, $full_error, 0); - callback_stop() if ($^O eq 'MSWin32' && defined($Config{'win32_service'})); } ######################################################################################## @@ -510,135 +506,6 @@ sub pandora_server_tasks ($) { db_disconnect($dbh); } -################################################################################ -## Install the Windows service. -################################################################################ -sub win32_install_service() { - - # Load Win32::Daemon. - eval "use Win32::Daemon"; - die($@) if ($@); - - # Configure and install the service. - my $service_path = $0; - my $service_params = "-S run \"" . $Config{'pandora_path'} ."\""; - my %service_hash = ( - machine => '', - name => 'PANDORAFMSSRV', - display => 'Pandora FMS Server', - path => $service_path, - user => '', - pwd => '', - description => 'Pandora FMS Server http://pandorafms.com/', - parameters => $service_params - ); - - if (Win32::Daemon::CreateService(\%service_hash)) { - print "Successfully added.\n"; - exit 0; - } else { - print "Failed to add service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n"; - exit 1; - } -} - -################################################################################ -## Install the Windows service. -################################################################################ -sub win32_uninstall_service() { - - # Load Win32::Daemon. - eval "use Win32::Daemon"; - die($@) if ($@); - - # Uninstall the service. - if (Win32::Daemon::DeleteService('', 'PANDORAFMSSRV')) { - print "Successfully deleted.\n"; - exit 0; - } else { - print "Failed to delete service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n"; - exit 1; - } -} - -################################################################################ -## Windows service callback function for the running event. -################################################################################ -sub callback_running { - if (Win32::Daemon::State() == WIN32_SERVICE_RUNNING) { - } -} - -################################################################################ -## Windows service callback function for the start event. -################################################################################ -sub callback_start { - no strict; - - # Accept_connections (); - my $thr = threads->create(\&main); - if (!defined($thr)) { - Win32::Daemon::State(WIN32_SERVICE_STOPPED); - Win32::Daemon::StopService(); - return; - } - $thr->detach(); - - Win32::Daemon::State(WIN32_SERVICE_RUNNING); -} - -################################################################################ -## Windows service callback function for the stop event. -################################################################################ -sub callback_stop { - - $RUN = 0; - Win32::Daemon::State(WIN32_SERVICE_STOPPED); - Win32::Daemon::StopService(); -} - -################################################################################ -# Run as a Windows service. -################################################################################ -sub win32_service_run() { - - # Load Win32::Daemon. - eval "use Win32::Daemon"; - die($@) if ($@); - - # Run the Pandora FMS Server as a Windows service. - Win32::Daemon::RegisterCallbacks({ - start => \&callback_start, - running => \&callback_running, - stop => \&callback_stop, - }); - Win32::Daemon::StartService(); -} - -################################################################################ -## Parse command line options. -################################################################################ -sub parse_service_options ($) { - my $config = shift; - - # Sanity checks. - return unless defined($config->{'win32_service'}); - die ("[ERROR] Windows services are only available on Win32.\n\n") if ($^O ne 'MSWin32'); - - # Win32 service management. - eval "use Win32::Daemon"; - die($@) if ($@); - - if ($config->{'win32_service'} eq 'install') { - win32_install_service(); - } elsif ($config->{'win32_service'} eq 'uninstall') { - win32_uninstall_service(); - } elsif ($config->{'win32_service'} eq 'run') { - } else { - die("[ERROR] Unknown action: " . $config->{'win32_service'}); - } -} - ################################################################ ################################################################ ## Main. @@ -967,17 +834,9 @@ $SIG{'ALRM'} = 'IGNORE'; pandora_init(\%Config, pandora_get_initial_product_name() . ' Server'); pandora_load_config (\%Config); -# Parse command line options. -parse_service_options(\%Config); # Run as a regular process. -if (!defined($Config{'win32_service'})) { - main(); -} -# Run as a Windows service. -else { - win32_service_run(); -} +main(); ################################################################################ # Kill any scripts started by the Pandora FMS Server that are still running. diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 72de95c29a..7c486b3c4a 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.769"; -my $pandora_build = "230227"; +my $pandora_build = "230228"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -64,7 +64,6 @@ sub help_screen { print " -d : Debug mode activated. Writes extensive information in the logfile \n"; print " -D : Daemon mode (runs in background)\n"; print " -P : Store PID to file.\n"; - print " -S : Manage the win32 service.\n"; print " -h : This screen. Shows a little help screen \n"; print " \n"; exit; @@ -111,9 +110,6 @@ sub pandora_init { elsif ($parametro =~ m/-D\z/) { $pa_config->{"daemon"}=1; } - elsif ($parametro =~ m/^-S\z/i) { - $pa_config->{'win32_service'}= clean_blank($ARGV[$ax+1]); - } else { ($pa_config->{"pandora_path"} = $parametro); } diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 0faecb33d3..d44dac7d4f 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.769"; -my $pandora_build = "230227"; +my $pandora_build = "230228"; 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 f93bb611ad..8fbf6b3a47 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.769 -%define release 230227 +%define release 230228 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 46c861f6bd..2e8dbd979d 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.769 -%define release 230227 +%define release 230228 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 5420293644..b4b9a39a65 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230227" +PI_BUILD="230228" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 05f8f8e7d5..95573a89de 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.769 Build 230227"; +my $version = "7.0NG.769 Build 230228"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 0c9c3aa929..ea984d2726 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.769 Build 230227"; +my $version = "7.0NG.769 Build 230228"; # save program name for logging my $progname = basename($0);