2010-01-25 Pablo de la Concepción <pablo.concepcion@artica.es>
* conf/pandora_server.conf, lib/PandoraFMS/Config.pm, lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Added activate_gis configuration parameter, and modified Core.pm and Dataserver.pm to skip positional data processing when activate_gis is not activated git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2305 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e164d8103a
commit
7d37597db7
|
@ -1,3 +1,10 @@
|
|||
2010-01-25 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* conf/pandora_server.conf, lib/PandoraFMS/Config.pm,
|
||||
lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Added activate_gis
|
||||
configuration parameter, and modified Core.pm and Dataserver.pm to skip
|
||||
positional data processing when activate_gis is not activated
|
||||
|
||||
2010-01-21 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* pandora_server.spec: Fixed spec to be more compatible with other
|
||||
|
|
|
@ -233,3 +233,6 @@ max_queue_files 250
|
|||
# restart 0
|
||||
# restart_delay 60
|
||||
|
||||
|
||||
# Flag to activate GIS (positional infomration for agents and maps) by default it is desactivated
|
||||
# activate_gis 0
|
||||
|
|
|
@ -185,6 +185,7 @@ sub pandora_load_config {
|
|||
$pa_config->{"inventory_threads"} = 2; # 2.1
|
||||
$pa_config->{"export_threads"} = 1; # 3.0
|
||||
$pa_config->{"web_threads"} = 1; # 3.0
|
||||
$pa_config->{"activate_gis"} = 0; # 3.1
|
||||
|
||||
$pa_config->{"max_queue_files"} = 250;
|
||||
|
||||
|
@ -510,6 +511,9 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^restart\s+([0-1])/i) {
|
||||
$pa_config->{'restart'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^activate_gis\s+([0-1])/i) {
|
||||
$pa_config->{'activate_gis'} = clean_blank($1);
|
||||
}
|
||||
} # end of loop for parameter #
|
||||
|
||||
|
||||
|
|
|
@ -727,7 +727,7 @@ sub pandora_update_agent ($$$$$$$;$$$$) {
|
|||
}
|
||||
|
||||
#Test if we have received the optional position parameters
|
||||
if (!defined ($longitude) || !defined ($latitude ) || !defined ($altitude)){
|
||||
if (!defined ($longitude) || !defined ($latitude ) || !defined ($altitude) || $pa_config->{'activate_gis'} == 0 ){
|
||||
if ( defined ($timezone_offset)) {
|
||||
# Update the table tagente with all the new data
|
||||
db_do ($dbh, 'UPDATE tagente SET intervalo = ?, agent_version = ?, ultimo_contacto_remoto = ?, ultimo_contacto = ?, os_version = ?,
|
||||
|
@ -738,6 +738,7 @@ sub pandora_update_agent ($$$$$$$;$$$$) {
|
|||
db_do ($dbh, 'UPDATE tagente SET intervalo = ?, agent_version = ?, ultimo_contacto_remoto = ?, ultimo_contacto = ?, os_version = ? WHERE id_agente = ?',
|
||||
$agent_interval, $agent_version, $agent_timestamp, $timestamp, $os_version, $agent_id);
|
||||
}
|
||||
# Without valid positional paremeters or desactivated gis system there is nothing more to do here
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -892,8 +893,8 @@ sub pandora_create_agent ($$$$$$$$$$$;$$$$) {
|
|||
|
||||
$description = "Created by $server_name" unless ($description ne '');
|
||||
my $agent_id;
|
||||
# Test if the optional positional parameters are defined
|
||||
if (!defined ($timezone_offset) || !defined ($longitude) || !defined ($latitude ) || !defined ($altitude)){
|
||||
# Test if the optional positional parameters are defined or GIS is disabled
|
||||
if (!defined ($timezone_offset) || !defined ($longitude) || !defined ($latitude ) || !defined ($altitude) || $pa_config->{'activate_gis'} == 0){
|
||||
$agent_id = db_insert ($dbh, 'INSERT INTO tagente (`nombre`, `direccion`, `comentarios`, `id_grupo`, `id_os`, `server_name`, `intervalo`, `id_parent`, `modo`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)', $agent_name, $address, $description, $group_id, $os_id, $server_name, $interval, $parent_id);
|
||||
}
|
||||
|
|
|
@ -153,28 +153,31 @@ sub data_consumer ($$) {
|
|||
sub process_xml_data ($$$$$) {
|
||||
my ($pa_config, $file_name, $data, $server_id, $dbh) = @_;
|
||||
|
||||
my ($agent_name, $agent_version, $timestamp, $interval, $os_version) =
|
||||
my ($agent_name, $agent_version, $timestamp, $interval, $os_version, $timezone_offset) =
|
||||
($data->{'agent_name'}, $data->{'version'}, $data->{'timestamp'},
|
||||
$data->{'interval'}, $data->{'os_version'});
|
||||
|
||||
# Get GIS information
|
||||
my ($timezone_offset, $longitude, $latitude, $altitude) = ($data->{'timezone_offset'},
|
||||
$data->{'longitude'}, $data->{'latitude'}, $data->{'altitude'});
|
||||
|
||||
# Validate the GIS informtation
|
||||
# Timezone offset must be an integer beween -12 and +12
|
||||
if ($timezone_offset !~ /[-+]?[0-9,11,12]/) {
|
||||
$timezone_offset = 0; # Default value
|
||||
}
|
||||
$data->{'interval'}, $data->{'os_version'}, $data->{'timezone_offset'});
|
||||
|
||||
my $valid_position_data = 1;
|
||||
# If position data are not valid should be ignored
|
||||
if ($longitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $latitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $altitude !~ /[-+]?[0-9]*\.?[0-9]+/) {
|
||||
$valid_position_data = 0;
|
||||
}
|
||||
|
||||
logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude", 10);
|
||||
|
||||
# Get GIS information
|
||||
my ($longitude, $latitude, $altitude) = (
|
||||
$data->{'longitude'}, $data->{'latitude'}, $data->{'altitude'});
|
||||
|
||||
if ($pa_config->{'activate_gis'}) {
|
||||
|
||||
# Validate the GIS informtation
|
||||
# Timezone offset must be an integer beween -12 and +12
|
||||
if ($timezone_offset !~ /[-+]?[0-9,11,12]/) {
|
||||
$timezone_offset = 0; # Default value
|
||||
}
|
||||
|
||||
# If position data are not valid should be ignored
|
||||
if ($longitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $latitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $altitude !~ /[-+]?[0-9]*\.?[0-9]+/) {
|
||||
$valid_position_data = 0;
|
||||
}
|
||||
|
||||
logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude", 10);
|
||||
}
|
||||
# Unknown agent!
|
||||
if (! defined ($agent_name) || $agent_name eq '') {
|
||||
logger($pa_config, "$file_name has data from an unnamed agent", 3);
|
||||
|
@ -220,7 +223,7 @@ sub process_xml_data ($$$$$) {
|
|||
$description = $data->{'description'} if (defined ($data->{'description'}));
|
||||
|
||||
# Create the agent
|
||||
if ($valid_position_data == 1) {
|
||||
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0 ) {
|
||||
logger($pa_config, "Creating agent $agent_name at long: $longitude lat: $latitude alt: $altitude", 5);
|
||||
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, '', 0, $group_id, 0, $os,
|
||||
$description, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude);
|
||||
|
@ -237,7 +240,7 @@ sub process_xml_data ($$$$$) {
|
|||
}
|
||||
$AgentSem->up ();
|
||||
|
||||
if ($valid_position_data == 1) {
|
||||
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0) {
|
||||
logger($pa_config, "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude", 5);
|
||||
# Update agent information including position information
|
||||
pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude);
|
||||
|
|
Loading…
Reference in New Issue