diff --git a/pandora_console/extras/mr/56.sql b/pandora_console/extras/mr/56.sql index 13cc050dfc..e33aa60111 100644 --- a/pandora_console/extras/mr/56.sql +++ b/pandora_console/extras/mr/56.sql @@ -1,3 +1,4 @@ +-- Active: 1653046769261@@127.0.0.1@3306@pandora START TRANSACTION; CREATE TABLE IF NOT EXISTS `tuser_task` ( @@ -38,4 +39,6 @@ ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAUL ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`; +ALTER TABLE `tagente` ADD COLUMN `fixed_ip` TINYINT UNSIGNED NOT NULL DEFAULT 0; + COMMIT; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 95bb218d62..31c4a92a54 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -302,6 +302,15 @@ $table_ip = '

'.__('IP Address') $table_ip .= '

'; $table_ip .= '
'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'
'; $table_ip .= '
'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'
'; +$table_ip .= '
'.html_print_input( + [ + 'type' => 'switch', + 'id' => 'fixed_ip', + 'name' => 'fixed_ip', + 'value' => $fixed_ip, + ], +).__('Fix IP').ui_print_help_tip(__('Avoid automatic IP update when agent IP changes'), true).'
'; + $table_ip .= '
'; if ($id_agente) { diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 4d26746ed1..a1ebc7ce7f 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -173,6 +173,7 @@ $url_description = ''; $quiet = 0; $macros = ''; $cps = 0; +$fixed_ip = 0; $create_agent = (bool) get_parameter('create_agent'); $module_macros = []; @@ -225,6 +226,7 @@ if ($create_agent) { $url_description = (string) get_parameter('url_description'); $quiet = (int) get_parameter('quiet', 0); $cps = (int) get_parameter_switch('cps', -1); + $fixed_ip = (int) get_parameter_switch('fixed_ip', 0); $secondary_groups = (string) get_parameter('secondary_hidden', ''); $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -282,6 +284,7 @@ if ($create_agent) { 'url_address' => $url_description, 'quiet' => $quiet, 'cps' => $cps, + 'fixed_ip' => $fixed_ip, ] ); enterprise_hook('update_agent', [$id_agente]); @@ -326,7 +329,7 @@ if ($create_agent) { "Update GIS data":"'.$update_gis_data.'", "Url description":"'.$url_description.'", "Quiet":"'.(int) $quiet.'", - "Cps":"'.(int) $cps.'"}'; + "Cps":"'.(int) $cps.'",}'; // Create the secondary groups. enterprise_hook( @@ -987,6 +990,7 @@ if ($update_agent) { $fields = db_get_all_fields_in_table('tagent_custom_fields'); $secondary_groups = (string) get_parameter('secondary_hidden', ''); $satellite_server = (int) get_parameter('satellite_server', 0); + $fixed_ip = (int) get_parameter_switch('fixed_ip', 0); if ($fields === false) { $fields = []; @@ -1095,6 +1099,7 @@ if ($update_agent) { 'cps' => $cps, 'safe_mode_module' => $safe_mode_module, 'satellite_server' => $satellite_server, + 'fixed_ip' => $fixed_ip, ]; if ($config['metaconsole_agent_cache'] == 1) { @@ -1234,6 +1239,7 @@ if ($id_agente) { $safe_mode_module = $agent['safe_mode_module']; $safe_mode = ($safe_mode_module) ? 1 : 0; $satellite_server = (int) $agent['satellite_server']; + $fixed_ip = (int) $agent['fixed_ip']; } $update_module = (bool) get_parameter('update_module'); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index eb27e7ef33..95382c1747 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -89,6 +89,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0, `cps` INT NOT NULL DEFAULT 0, `satellite_server` INT NOT NULL DEFAULT 0, + `fixed_ip` TINYINT NOT NULL DEFAULT 0, PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 8d7a28a356..7a7c98b278 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -485,7 +485,7 @@ sub process_xml_data ($$$$$) { # Update the main address if ($address ne '' && $address ne $agent->{'direccion'}) { - pandora_update_agent_address ($pa_config, $agent_id, $agent_name, $address, $dbh); + pandora_update_agent_address ($pa_config, $agent_id, $agent_name, $address, $dbh) unless $agent->{'fixed_ip'} == 1; pandora_add_agent_address($pa_config, $agent_id, $agent_name, $address, $dbh); }