mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-24 10:30:05 +02:00
Server now can get the agent mode from agent
This commit is contained in:
parent
4bed6c1da2
commit
c24aa44ee1
@ -2786,12 +2786,12 @@ Create a new entry in B<tagente> optionaly with position information
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_create_agent ($$$$$$$$$$;$$$$$$$) {
|
||||
sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$) {
|
||||
my ($pa_config, $server_name, $agent_name, $address,
|
||||
$group_id, $parent_id, $os_id,
|
||||
$description, $interval, $dbh, $timezone_offset,
|
||||
$longitude, $latitude, $altitude, $position_description,
|
||||
$custom_id, $url_address) = @_;
|
||||
$custom_id, $url_address, $agent_mode) = @_;
|
||||
|
||||
logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10);
|
||||
|
||||
@ -2803,6 +2803,8 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$) {
|
||||
}
|
||||
}
|
||||
|
||||
$agent_mode = 1 unless defined($agent_mode);
|
||||
|
||||
$description = "Created by $server_name" unless ($description ne '');
|
||||
my ($columns, $values) = db_insert_get_values ({ 'nombre' => safe_input($agent_name),
|
||||
'direccion' => $address,
|
||||
@ -2812,7 +2814,7 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$) {
|
||||
'server_name' => $server_name,
|
||||
'intervalo' => $interval,
|
||||
'id_parent' => $parent_id,
|
||||
'modo' => 1,
|
||||
'modo' => $agent_mode,
|
||||
'custom_id' => $custom_id,
|
||||
'url_address' => $url_address,
|
||||
'timezone_offset' => $timezone_offset
|
||||
|
@ -250,6 +250,10 @@ sub process_xml_data ($$$$$) {
|
||||
}
|
||||
}
|
||||
|
||||
# Get agent mode
|
||||
my $agent_mode = 1; # Default value learning mode
|
||||
$agent_mode = $data->{'agent_mode'} if (defined ($data->{'agent_mode'}));
|
||||
|
||||
# Unknown agent!
|
||||
if (! defined ($agent_name) || $agent_name eq '') {
|
||||
logger($pa_config, "$file_name has data from an unnamed agent", 3);
|
||||
@ -331,7 +335,7 @@ sub process_xml_data ($$$$$) {
|
||||
$description = $data->{'description'} if (defined ($data->{'description'}));
|
||||
|
||||
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address, $group_id, $parent_id, $os,
|
||||
$description, $interval, $dbh, $timezone_offset, undef, undef, undef, undef, $custom_id, $url_address);
|
||||
$description, $interval, $dbh, $timezone_offset, undef, undef, undef, undef, $custom_id, $url_address, $agent_mode);
|
||||
|
||||
if (! defined ($agent_id)) {
|
||||
return;
|
||||
@ -596,8 +600,8 @@ sub process_module_data ($$$$$$$$$) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Is the agent learning?
|
||||
if ($agent->{'modo'} ne '1') {
|
||||
# Is the agent not learning?
|
||||
if ($agent->{'modo'} == 0) {
|
||||
logger($pa_config, "Learning mode disabled. Skipping module '$module_name' agent '$agent_name'.", 10);
|
||||
$ModuleSem->up ();
|
||||
return;
|
||||
@ -697,7 +701,7 @@ sub process_module_data ($$$$$$$$$) {
|
||||
}
|
||||
|
||||
# Update module configuration if in learning mode and not a policy module
|
||||
if ($agent->{'modo'} eq '1' && $policy_linked == 0) {
|
||||
if ((($agent->{'modo'} eq '1') || ($agent->{'modo'} eq '2')) && $policy_linked == 0) {
|
||||
update_module_configuration ($pa_config, $dbh, $module, $module_conf);
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ sub data_consumer ($$) {
|
||||
if ($agent_id > 0) {
|
||||
|
||||
# Skip if not in learning mode
|
||||
next if ($agent->{'modo'} != 1);
|
||||
next unless (($agent->{'modo'} == 1) || ($agent->{'modo'} == 2));
|
||||
}
|
||||
|
||||
# Get the parent host
|
||||
|
Loading…
x
Reference in New Issue
Block a user