diff --git a/pandora_console/extras/mr/55.sql b/pandora_console/extras/mr/55.sql index 747a8da934..246e8b641f 100644 --- a/pandora_console/extras/mr/55.sql +++ b/pandora_console/extras/mr/55.sql @@ -38,6 +38,8 @@ ALTER TABLE `tbackup` MODIFY COLUMN `id_user` VARCHAR(255) DEFAULT ''; ALTER TABLE `tservice` ADD COLUMN `enable_sunburst` tinyint(1) NOT NULL default 0; ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT ''; +ALTER TABLE `tagente` ADD COLUMN `satellite_server` INT NOT NULL default 0; +ALTER TABLE `tmetaconsole_agent` ADD COLUMN `satellite_server` INT NOT NULL default 0; SET @st_oum763 = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tautoconfig' AND table_schema = DATABASE() AND column_name = 'disabled') > 0, "SELECT 1", @@ -49,3 +51,4 @@ EXECUTE pr_oum763; DEALLOCATE PREPARE pr_oum763; COMMIT; + diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index a9282fa1af..95bb218d62 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -245,8 +245,11 @@ if (!$new_agent && $alias != '') { } // Remote configuration available. + $remote_agent = false; if (isset($filename)) { if (file_exists($filename['md5'])) { + $remote_agent = true; + $agent_name = agents_get_name($id_agente); $agent_name = io_safe_output($agent_name); $agent_md5 = md5($agent_name, false); @@ -427,6 +430,42 @@ $table_server .= html_print_select( true ).'
'; + +$table_satellite = ''; +if ($remote_agent === true) { + // Satellite server selector. + $satellite_servers = db_get_all_rows_filter( + 'tserver', + ['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE], + [ + 'id_server', + 'name', + ] + ); + + $satellite_names = []; + if (empty($satellite_servers) === false) { + foreach ($satellite_servers as $s_server) { + $satellite_names[$s_server['id_server']] = $s_server['name']; + } + + $table_satellite = ''.__('Satellite').'
'; + $table_satellite .= ''.__('Description').'
'; $table_description .= html_print_textarea( @@ -443,7 +482,7 @@ $table_description .= html_print_textarea( echo ''.html_print_image( + 'images/satellite.png', + true, + ['class' => 'invert_filter'] + ); + $remote_cfg .= $satellite_name.'
'; + } } else { $remote_cfg = ''; } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5550bc5413..100b83cf96 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -88,6 +88,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `alias_as_name` TINYINT NOT NULL DEFAULT 0, `safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0, `cps` INT NOT NULL DEFAULT 0, + `satellite_server` INT NOT NULL DEFAULT 0, PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), @@ -3468,6 +3469,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( `alias_as_name` TINYINT NOT NULL DEFAULT 0, `safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0, `cps` INT NOT NULL DEFAULT 0, + `satellite_server` INT NOT NULL DEFAULT 0, PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index acc4d83546..189be884c9 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -3002,10 +3002,10 @@ defined also the parent is updated. =cut ########################################################################## -sub pandora_update_agent ($$$$$$$;$$) { +sub pandora_update_agent ($$$$$$$;$$$) { my ($pa_config, $agent_timestamp, $agent_id, $os_version, $agent_version, $agent_interval, $dbh, $timezone_offset, - $parent_agent_id) = @_; + $parent_agent_id, $satellite_server_id) = @_; # No access update for data without interval. # Single modules from network server, for example. This could be very Heavy for Pandora FMS @@ -3026,6 +3026,7 @@ sub pandora_update_agent ($$$$$$$;$$) { 'os_version' => $os_version, 'timezone_offset' => $timezone_offset, 'id_parent' => $parent_agent_id, + 'satellite_server' => $satellite_server_id }); db_do ($dbh, "UPDATE tagente SET $set WHERE id_agente = ?", @{$values}, $agent_id); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 083fb77f8e..8d7a28a356 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -452,6 +452,16 @@ sub process_xml_data ($$$$$) { logger($pa_config, "Error retrieving information for agent ID $agent_id",10); return; } + + # Get the ID of the Satellite Server if available. + my $satellite_server_id = 0; + if (defined($data->{'satellite_server'})) { + $satellite_server_id = get_server_id($dbh, $data->{'satellite_server'}, SATELLITESERVER); + if ($satellite_server_id < 0) { + logger($pa_config, "Satellite Server '" . $data->{'satellite_server'} . "' does not exist.", 10); + $satellite_server_id = 0; + } + } # Check if agent is disabled and return if it's disabled. Disabled agents doesnt process data # in order to avoid not only events, also possible invalid data coming from agents. @@ -536,7 +546,7 @@ sub process_xml_data ($$$$$) { } # Update agent information - pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $parent_id); + pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $parent_id, $satellite_server_id); # Update GIS data if ($pa_config->{'activate_gis'} != 0 && $agent->{'update_gis_data'} == 1) {