Auto-assign Satellite Servers to agents when possible.
This commit is contained in:
parent
48b20b255b
commit
5e33df93ac
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue