[GeoIP] Added geolocalization to Recon and DataServer

This commit is contained in:
fermin831 2018-07-05 16:43:41 +02:00
parent 219988018f
commit 3c1f192ab4
2 changed files with 14 additions and 6 deletions

View File

@ -39,6 +39,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB;
use PandoraFMS::Core;
use PandoraFMS::ProducerConsumerServer;
use PandoraFMS::GIS;
# Inherits from PandoraFMS::ProducerConsumerServer
our @ISA = qw(PandoraFMS::ProducerConsumerServer);
@ -362,10 +363,13 @@ sub process_xml_data ($$$$$) {
my $description = '';
$description = $data->{'description'} if (defined ($data->{'description'}));
my $alias = (defined ($data->{'agent_alias'}) && $data->{'agent_alias'} ne '') ? $data->{'agent_alias'} : $data->{'agent_name'};
$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, $agent_mode, $alias);
my $location = get_geoip_info($pa_config, $address);
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address,
$group_id, $parent_id, $os,
$description, $interval, $dbh, $timezone_offset,
$location->{'longitude'}, $location->{'latitude'}, undef, undef,
$custom_id, $url_address, $agent_mode, $alias
);
if (! defined ($agent_id)) {
return;
}

View File

@ -418,8 +418,12 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
# Are we filtering hosts by TCP port?
return if ($self->{'recon_ports'} ne '' && $self->tcp_scan($device) == 0);
$agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device, $self->{'group_id'}, 0, $id_os, '', 300, $self->{'dbh'});
my $location = get_geoip_info($self->{'pa_config'}, $device);
$agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device,
$self->{'group_id'}, 0, $id_os,
'', 300, $self->{'dbh'}, undef,
$location->{'longitude'}, $location->{'latitude'}
);
return undef unless defined ($agent_id) and ($agent_id > 0);
pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'});
$agent_learning = 1;