diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index ed8e880527..7565443dcf 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,15 @@ +2011-02-07 Sancho Lerena + + * pandora_server/DEBIAN/control, + pandora_server/pandora_server.spec, + pandora_server/pandora_server.redhat.spec: Added LWP dependency for + reverse Geocoding feature. This is included on all distros. + + * pandora_server/conf/pandora_server.conf, + pandora_server/lib/PandoraFMS/Config.pm, + pandora_server/lib/PandoraFMS/DataServer.pm: Added support for reverse geocoding using + GoogleMaps api. + 2011-01-31 Sergio Martin * lib/PandoraFMS/DB.pm: Fixed a codification bug with diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index b2ef8f3e89..fabf3da0e0 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -6,5 +6,5 @@ Section: admin Installed-Size: 640 Maintainer: Miguel de Dios Homepage: http://pandorafms.org/ -Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo +Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo, libwww-perl 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. This is the server package. Server makes the remote checks and process information transfer by Pandora FMS agents to the server. diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf index 700a5a006f..02bff4c6f6 100755 --- a/pandora_server/conf/pandora_server.conf +++ b/pandora_server/conf/pandora_server.conf @@ -272,3 +272,11 @@ max_queue_files 250 # Update parent from the agent xml #update_parent 1 +# +# +# This enable realtime reverse geocoding using Google Maps public api. +# This requires internet access, and could have performance penalties processing GIS +# information due the connetion needed to resolve all GIS input. +# +# google_maps_description 1 + diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index b78bed9dfb..fae3a3626d 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -231,6 +231,7 @@ sub pandora_load_config { $pa_config->{"recon_reverse_geolocation_file"} = '/usr/local/share/GeoIP/GeoIPCity.dat'; # 3.1 $pa_config->{"recon_location_scatter_radius"} = 50; # 3.1 $pa_config->{"update_parent"} = 0; # 3.1 + $pa_config->{"google_maps_description"} = 0; $pa_config->{"max_queue_files"} = 250; @@ -547,6 +548,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^restart\s+([0-1])/i) { $pa_config->{'restart'} = clean_blank($1); } + elsif ($parametro =~ m/^google_maps_description\s+([0-1])/i) { + $pa_config->{'google_maps_description'} = clean_blank($1); + } elsif ($parametro =~ m/^activate_gis\s+([0-1])/i) { $pa_config->{'activate_gis'} = clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 496132075b..52a0ec98e5 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -28,6 +28,9 @@ use Time::Local; use XML::Simple; use POSIX qw(setsid strftime); +# For Reverse Geocoding +use LWP::Simple; + # Default lib dir for RPM and DEB packages use lib '/usr/lib/perl5'; @@ -229,7 +232,18 @@ sub process_xml_data ($$$$$) { } if (!defined($position_description) ) { #FIXME: Validate the data with a regexp - $position_description = ''; # Default value + + # This code gets description (Reverse Geocoding) from a current GPS coordinates using Google maps API + # This requires a connection to internet and could be very slow and have a huge impact in performance. + # Other methods for reverse geocoding will be supplied in the future (openstreetmaps in a local server) + + if ($pa_config->{'google_maps_description'}){ + my $content = get ('http://maps.google.com/maps/geo?q='.$latitude.','.$longitude.'&output=csv&sensor=false'); + my @address = split (/\"/,$content); + $position_description = $address[1]; + } else { + $position_description = ''; # Default value + } } logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude position_description=$position_description", 8); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index eb9f875fa0..5c3f64673b 100644 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -199,6 +199,9 @@ sub pandora_get_os ($) { elsif ($command =~ m/embedded/i){ return 14; } + elsif ($command =~ m/android/i){ + return 15; + } elsif ($command =~ m/BSD/i){ return 4; } diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 661b479c55..55dfb3e619 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -23,7 +23,7 @@ Prereq: %{_sbindir}/useradd AutoReq: 0 Provides: %{name}-%{version} Requires: coreutils -Requires: perl-DBI perl-DBD-mysql +Requires: perl-DBI perl-DBD-mysql perl-libwww-perl Requires: perl-XML-Simple perl-XML-SAX Requires: perl-NetAddr-IP net-snmp net-tools Requires: nmap wmic sudo diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index aa9b6a4f2d..3bb1ec92e7 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -21,7 +21,7 @@ BuildArchitectures: noarch Requires(pre): /usr/sbin/useradd AutoReq: 0 Provides: %{name}-%{version} -Requires: perl-DBI perl-DBD-mysql +Requires: perl-DBI perl-DBD-mysql perl-libwww-perl Requires: perl-NetAddr-IP net-snmp net-tools Requires: nmap wmic sudo perl-HTML-Tree perl-XML-SAX