diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index f94cb7737b..40469f75b2 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -228,7 +228,9 @@ if($new_agent){ } $table->data[2][0] = __('IP Address'); -$table->data[2][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true); +$table->data[2][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true). + html_print_checkbox ("unique_ip", 1, $config['unique_ip'], true).__('Unique IP') . + ui_print_help_tip (__("Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent"), true); if ($id_agente) { $table->data[2][1] .= ' '; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index fab0ad7637..92c3cc4b73 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -81,6 +81,7 @@ $alias_as_name = 0; $direccion_agente = get_parameter('direccion', ''); $direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = io_safe_input($direccion_agente); +$unique_ip = 0; $intervalo = SECONDS_5MINUTES; $ff_interval = 0; $quiet_module = 0; @@ -160,6 +161,7 @@ if ($create_agent) { $alias = (string) get_parameter_post("alias",''); $alias_as_name = (int) get_parameter_post("alias_as_name", 0); $direccion_agente = (string) get_parameter_post("direccion",''); + $unique_ip = (int) get_parameter_post("unique_ip", 0); //safe_output only validate ip $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -214,7 +216,12 @@ if ($create_agent) { $nombre_agente = $alias; } - if(!$exists_alias){ + if($unique_ip && $direccion_agente != ''){ + $sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"'; + $exists_ip = db_get_row_sql($sql); + } + + if(!$exists_alias && !$exists_ip){ $id_agente = db_process_sql_insert ( 'tagente', array ( @@ -304,6 +311,9 @@ if ($create_agent) { if($exists_alias){ $agent_creation_error = __('Could not be created, because name already exists'); } + elseif($exists_ip){ + $agent_creation_error = __('Could not be created, because IP already exists'); + } } } } @@ -712,6 +722,7 @@ if ($update_agent) { // if modified some agent paramenter $alias = str_replace('`','‘',(string) get_parameter_post ("alias", "")); $alias_as_name = (int) get_parameter_post ('alias_as_name', 0); $direccion_agente = (string) get_parameter_post ("direccion", ''); + $unique_ip = (int) get_parameter_post ('unique_ip', 0); //safe_output only validate ip $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -795,9 +806,18 @@ if ($update_agent) { // if modified some agent paramenter ui_print_error_message(__('No agent alias specified')); //If there is an agent with the same name, but a different ID } + + if($unique_ip && $direccion_agente != ''){ + $sql = 'SELECT direccion FROM tagente WHERE direccion = "' . $direccion_agente . '"'; + $exists_ip = db_get_row_sql($sql); + } + if ($grupo <= 0) { ui_print_error_message(__('The group id %d is incorrect.', $grupo)); } + elseif($exists_ip){ + ui_print_error_message(__('Duplicate main IP address')); + } else { //If different IP is specified than previous, add the IP if ($direccion_agente != '' && diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index b935f4fc13..aedeec5173 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -230,6 +230,11 @@ $table->data[38][0] = __('Set alias as name by default in agent creation'); $table->data[38][1] = __('Yes').' '.html_print_radio_button ('alias_as_name', 1, '', $config["alias_as_name"], true).' '; $table->data[38][1] .= __('No').' '.html_print_radio_button ('alias_as_name', 0, '', $config["alias_as_name"], true); +$table->data[39][0] = __('Unique IP') . + ui_print_help_tip (__("Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent"), true); +$table->data[39][1] = __('Yes').' '.html_print_radio_button ('unique_ip', 1, '', $config["unique_ip"], true).' '; +$table->data[39][1] .= __('No').' '.html_print_radio_button ('unique_ip', 0, '', $config["unique_ip"], true); + echo '