From a81ad713fc02ded546334fc573227b53f13e7b15 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 25 Mar 2024 11:54:24 +0100 Subject: [PATCH] Remove Geo::IP. --- .../pandora_deploy_community.sh | 2 - .../pandora_deploy_community_el8.sh | 2 - extras/docker/centos8/base/Dockerfile | 3 +- pandora_server/Makefile.PL | 1 - pandora_server/lib/PandoraFMS/DataServer.pm | 3 +- pandora_server/lib/PandoraFMS/GIS.pm | 43 --------- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server_installer | 4 +- pandora_server/util/agent_gis_update.pl | 92 ------------------- tests/Dockerfile | 2 - 10 files changed, 4 insertions(+), 150 deletions(-) delete mode 100755 pandora_server/util/agent_gis_update.pl diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 44be2d8fb9..d14da61fe5 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -304,7 +304,6 @@ server_dependencies=" \ perl(Sys::Syslog) \ perl(DBI) \ perl(XML::Simple) \ - perl(Geo::IP) \ perl(IO::Socket::INET6) \ perl(XML::Twig) \ expect \ @@ -344,7 +343,6 @@ ipam_dependencies=" \ perl(Sys::Syslog) \ perl(DBI) \ perl(XML::Simple) \ - perl(Geo::IP) \ perl(IO::Socket::INET6) \ perl(XML::Twig)" execute_cmd "yum install -y $ipam_dependencies" "Installing IPAM Instant client" diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index c37b5df13c..b32ffdab56 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -417,7 +417,6 @@ server_dependencies=" \ perl(Sys::Syslog) \ perl(DBI) \ perl(XML::Simple) \ - perl(Geo::IP) \ perl(IO::Socket::INET6) \ perl(XML::Twig) \ expect \ @@ -457,7 +456,6 @@ ipam_dependencies=" \ perl(Sys::Syslog) \ perl(DBI) \ perl(XML::Simple) \ - perl(Geo::IP) \ perl(IO::Socket::INET6) \ perl(XML::Twig)" execute_cmd "dnf install -y $ipam_dependencies" "Installing IPAM Instant client" diff --git a/extras/docker/centos8/base/Dockerfile b/extras/docker/centos8/base/Dockerfile index 4f9a0c994f..eac2152d3c 100644 --- a/extras/docker/centos8/base/Dockerfile +++ b/extras/docker/centos8/base/Dockerfile @@ -116,7 +116,6 @@ RUN dnf install -y --setopt=tsflags=nodocs \ "perl(Sys::Syslog)" \ "perl(DBI)" \ "perl(XML::Simple)" \ - "perl(Geo::IP)" \ "perl(IO::Socket::INET6)" \ "perl(XML::Twig)" \ expect \ @@ -135,7 +134,7 @@ RUN dnf install -y http://firefly.artica.es/centos8/perl-Crypt-OpenSSL-AES-0.02- # Instant client Oracle RUN dnf install -y https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm # Install IPAM dependencies -RUN dnf install -y "perl(NetAddr::IP)" "perl(Sys::Syslog)" "perl(DBI)" "perl(XML::Simple)" "perl(Geo::IP)" "perl(IO::Socket::INET6)" "perl(XML::Twig)" "perl(DBD::mysql)" --setopt=tsflags=nodocs +RUN dnf install -y "perl(NetAddr::IP)" "perl(Sys::Syslog)" "perl(DBI)" "perl(XML::Simple)" "perl(IO::Socket::INET6)" "perl(XML::Twig)" "perl(DBD::mysql)" --setopt=tsflags=nodocs EXPOSE 80 443 41121 162/udp diff --git a/pandora_server/Makefile.PL b/pandora_server/Makefile.PL index 107bd69c3f..81c97b87f7 100644 --- a/pandora_server/Makefile.PL +++ b/pandora_server/Makefile.PL @@ -31,7 +31,6 @@ WriteMakefile( HTML::Entities => 0, IO::Socket::INET6 => 0, JSON => 0, - Geo::IP => 0, }, EXE_FILES => [ @exe_files ], PMLIBDIRS => [ 'lib' ], diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 5601c1eef7..fc5cf597d1 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -459,11 +459,10 @@ 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'}; - 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, + undef, undef, undef, undef, $custom_id, $url_address, $agent_mode, $alias ); if (! defined ($agent_id)) { diff --git a/pandora_server/lib/PandoraFMS/GIS.pm b/pandora_server/lib/PandoraFMS/GIS.pm index 85138f8af9..1f9e1ce27e 100644 --- a/pandora_server/lib/PandoraFMS/GIS.pm +++ b/pandora_server/lib/PandoraFMS/GIS.pm @@ -40,8 +40,6 @@ Exported Functions: =item * C -=item * C - =back =head1 METHODS @@ -66,7 +64,6 @@ our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( distance_moved - get_geoip_info ); # Some intenrnal constants @@ -128,46 +125,6 @@ sub distance_moved ($$$$$$$) { return $dist_in_meters; } -########################################################################## -=head2 C<< get_geoip_info (I<$pa_config>, I<$address>, I<$dispersion>) >> - -Get GIS information from the MaxMind GeoIP database on file using Geo::IP module - -B: I if there is not information available or a B with: - * I - * I - -=cut -########################################################################## -sub get_geoip_info { - my ($pa_config, $address) = @_; - - # Return undef if feature is not activated - return undef unless ($pa_config->{'activate_gis'} && $pa_config->{'recon_reverse_geolocation_file'} ne ''); - - my $record = undef; - eval { - local $SIG{__DIE__}; - my $gi = Geo::IP->open($pa_config->{'recon_reverse_geolocation_file'}, GEOIP_STANDARD); - die("Cannot load the geoip file \"" . $pa_config->{'recon_reverse_geolocation_file'} . "\".\n") unless defined($gi); - $record = $gi->record_by_addr($address); - }; - if ($@) { - logger($pa_config, "Error giving coordinates to IP: $address. $@", 8); - } - return undef unless defined($record); - - # Fuzzy position filter - my ($longitude, $latitude) = get_random_close_point ( - $pa_config, $record->longitude, $record->latitude - ); - - return { - "longitude" => $longitude, - "latitude" => $latitude - }; -} - ########################################################################## =head2 C<< get_random_close_point(I<$pa_config>, I<$center_longitude>, I<$center_latitude>) >> diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 34405bca3c..4a5820ac82 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -34,7 +34,7 @@ Requires: perl(NetAddr::IP) net-snmp net-tools Requires: perl(IO::Socket::INET6) perl(IO::Socket::SSL) perl(Net::Telnet) Requires: fping nmap sudo perl(JSON) Requires: perl(Time::HiRes) perl(Encode::Locale) -Requires: perl perl(Sys::Syslog) perl(HTML::Entities) perl(Geo::IP) expect +Requires: perl perl(Sys::Syslog) perl(HTML::Entities) expect %description Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments. diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 5892761e25..c02ba1f769 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -263,11 +263,9 @@ install () { echo " Recommended: p5-DBI p5-NetAddr-IP p5-XML-Simple p5-XML-Twig p5-HTML-Parser p5-DBD-mysql p5-Socket6 p5-IO-Socket-INET6 p5-JSON" echo " Optional: nmap" echo " " - echo " And install Geo::IP manually." - echo " " echo "To get them from source through CPAN do" echo " " - echo " $ cpan Time::Local DBI Socket6 XML::Simple XML::Twig IO::Socket Time::HiRes NetAddr::IP HTML::Entities IO::Socket::INET6 JSON Geo::IP" + echo " $ cpan Time::Local DBI Socket6 XML::Simple XML::Twig IO::Socket Time::HiRes NetAddr::IP HTML::Entities IO::Socket::INET6 JSON" echo " " rm output exit 1 diff --git a/pandora_server/util/agent_gis_update.pl b/pandora_server/util/agent_gis_update.pl deleted file mode 100755 index 79e6fc88de..0000000000 --- a/pandora_server/util/agent_gis_update.pl +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/perl - -############################################################################### -# Pandora FMS DB Management -############################################################################### -# Copyright (c) 2005-2023 Pandora FMS -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; version 2 -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA -############################################################################### - -# Includes list -use strict; -use warnings; -use Time::Local; # DateTime basic manipulation -use DBI; # DB interface with MySQL -use POSIX qw(strftime); -use Time::HiRes qw(usleep); - -# Default lib dir for RPM and DEB packages -BEGIN { push @INC, '/usr/lib/perl5'; } - -use PandoraFMS::Core; -use PandoraFMS::Config; -use PandoraFMS::DB; -use PandoraFMS::GIS; - -# Pandora server configuration -my %conf; - -# Pandora db handler -my $dbh; - -# FLUSH in each IO -$| = 1; - -sub print_agent_gis_update_help() { - print "Usage: $0 \n"; -} - -# Get options -my ($configuration_file) = @ARGV; -if (!defined($configuration_file) || $configuration_file eq '-h' || $configuration_file eq '--help') { - print_agent_gis_update_help(); - exit defined($configuration_file) ? 0 : 1; -} - -# Load configuration file -$conf{'pandora_path'} = $configuration_file; -$conf{'quiet'} = 0; -pandora_load_config(\%conf); - -use Data::Dumper; -#print Dumper(\%conf); - -if (!$conf{'activate_gis'} || $conf{'recon_reverse_geolocation_file'} eq '') { - print "Geolocation feature es blocked.\n"; - exit 0; -} - -# Connect to the DB -$dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'}); -if (!defined($dbh)){ - print "Cannot connect to database\n"; - exit 1; -} - -# Get all agents with IP assigned -my @agents = get_db_rows($dbh, - "SELECT id_agente, direccion, alias FROM tagente WHERE disabled = 0 AND direccion <> ''" -); - -my $c_time = strftime ("%Y/%m/%d %H:%M:%S", localtime()); -foreach my $agent (@agents) { - my $location = get_geoip_info (\%conf, $agent->{'direccion'}); - if (defined($location)) { - pandora_update_gis_data(\%conf, $dbh, $agent->{'id_agente'}, $agent->{'id_agente'}, $location->{'longitude'}, $location->{'latitude'}, undef, undef, $c_time); - } -} - -print "Successfull relocation\n"; - -db_disconnect($dbh); -exit 0; \ No newline at end of file diff --git a/tests/Dockerfile b/tests/Dockerfile index 4c0629690a..86b3ed9e93 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -91,8 +91,6 @@ RUN dnf install -y vim wget bzip2 curl && \ gettext \ wmic \ chromium \ - cpanminus && \ - cpanm Geo::IP && \ mkdir -p /opt/phantomjs/bin && cd /opt/phantomjs/bin && \ wget https://netcologne.dl.sourceforge.net/project/pandora/Tools%20and%20dependencies%20%28All%20versions%29/DEB%20Debian%2C%20Ubuntu/phantomjs && \ chmod +x phantomjs && \