Added switch to agetn conf to avoid automatic Ip update

This commit is contained in:
Calvo 2022-07-15 13:40:54 +02:00
parent 99bfdc804e
commit 3ee8f6b431
5 changed files with 21 additions and 2 deletions

View File

@ -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;

View File

@ -302,6 +302,15 @@ $table_ip = '<div class="label_select"><p class="input_label">'.__('IP Address')
$table_ip .= '<div class="label_select_parent">';
$table_ip .= '<div class="label_select_child_left">'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'</div>';
$table_ip .= '<div class="label_select_child_right">'.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).'</div>';
$table_ip .= '</div></div>';
if ($id_agente) {

View File

@ -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');

View File

@ -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`),

View File

@ -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);
}