2010-02-15 Pablo de la Concepción <pablo.concepcion@artica.es>
* conf/pandora_server.conf, lib/PandoraFMS/Config.pm: New configuration parameters: recon_reverse_geolocation_mode, recon_reverse_geolocation_file, recon_location_scatter_radius. As now the Recon Server can try to geolocate an agent when it's found by revers geoip location. * lib/PandoraFMS/Core.pm: Added first version of POD documentation to create the manpage and to have most of the subrutines documented. Also it's possible to add the description of the location to the GIS information on the pandora_update_agent and pandora_create_agent subroutines. And finaly moved away the GIS related functions (distance_moved) to their own new module PandoraFMS::GIS * lib/PandoraFMS/GIS.pm: New module to keep all the GIS related functions of Pandora FMS. Now it exports distance_moved, get_reverse_geoip_sql, get_reverse_geoip_file and get_random_close_point. * lib/PandoraFMS/ReconServer.pm: Updated to get GIS information by doing reverse IP geolocation using GIS module. * man/man3/PandoraFMS::Core.pm.3, man/man3/PandoraFMS::GIS.pm.3: New manpages for Core and GIS modules. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2368 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9bd6094414
commit
094794cf74
|
@ -1,3 +1,27 @@
|
|||
2010-02-15 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* conf/pandora_server.conf, lib/PandoraFMS/Config.pm: New configuration
|
||||
parameters: recon_reverse_geolocation_mode, recon_reverse_geolocation_file,
|
||||
recon_location_scatter_radius. As now the Recon Server can try to geolocate
|
||||
an agent when it's found by revers geoip location.
|
||||
|
||||
* lib/PandoraFMS/Core.pm: Added first version of POD documentation to
|
||||
create the manpage and to have most of the subrutines documented. Also
|
||||
it's possible to add the description of the location to the GIS information
|
||||
on the pandora_update_agent and pandora_create_agent subroutines. And
|
||||
finaly moved away the GIS related functions (distance_moved) to their own
|
||||
new module PandoraFMS::GIS
|
||||
|
||||
* lib/PandoraFMS/GIS.pm: New module to keep all the GIS related functions
|
||||
of Pandora FMS. Now it exports distance_moved, get_reverse_geoip_sql,
|
||||
get_reverse_geoip_file and get_random_close_point.
|
||||
|
||||
* lib/PandoraFMS/ReconServer.pm: Updated to get GIS information by doing
|
||||
reverse IP geolocation using GIS module.
|
||||
|
||||
* man/man3/PandoraFMS::Core.pm.3, man/man3/PandoraFMS::GIS.pm.3: New
|
||||
manpages for Core and GIS modules.
|
||||
|
||||
2010-02-15 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* bin/tentacle_server: Updated tentacle server and synchronized with the
|
||||
|
|
|
@ -240,3 +240,20 @@ max_queue_files 250
|
|||
# Radius of the Error in meters to consider two gis locations as the same location.
|
||||
# location_error 50
|
||||
|
||||
|
||||
# Recon reverse geolocation mode [disabled, sql, file]
|
||||
# * disabled: The recon task doesn't try to geolocate the ip discovered.
|
||||
# * sql: The recon task trys to query the SQL database to geolocate the ip discovered
|
||||
# * file: The recon task trys to find the geolocation information of the ip discovered in
|
||||
# the file indicated in the recon_reverse_geolocation_file parameter
|
||||
# recon_reverse_geolocation_mode disabled
|
||||
|
||||
# Recon reverse geolocation file (databases with the reverse geolocation information using
|
||||
# MaxMind GPL GeoLiteCity.dat format).
|
||||
|
||||
#recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat
|
||||
|
||||
# Radius (in meters) of the circle in where the agents will be place randomly when finded by a recon task
|
||||
# The center of the cicle is guessed by geolocating the IP.
|
||||
#recon_location_scatter_radius 1000
|
||||
|
||||
|
|
|
@ -223,6 +223,10 @@ sub pandora_load_config {
|
|||
$pa_config->{"web_threads"} = 1; # 3.0
|
||||
$pa_config->{"activate_gis"} = 0; # 3.1
|
||||
$pa_config->{"location_error"} = 50; # 3.1
|
||||
$pa_config->{"recon_reverse_geolocation_mode"} = 'disabled'; # 3.1
|
||||
$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->{"max_queue_files"} = 250;
|
||||
|
||||
# Internal MTA for alerts, each server need its own config.
|
||||
|
@ -558,6 +562,15 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^location_error\s+(\d+)/i) {
|
||||
$pa_config->{'location_error'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^recon_reverse_geolocation_mode\s+(\w+)/i) {
|
||||
$pa_config->{'recon_reverse_geolocation_mode'} = clean_blank($1);
|
||||
} #FIXME: Find a better regexp to validate the path
|
||||
elsif ($parametro =~ m/^recon_reverse_geolocation_file\s+(.*)/i) {
|
||||
$pa_config->{'recon_reverse_geolocation_file'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^recon_location_scatter_radius\s+(\d+)/i) {
|
||||
$pa_config->{'recon_location_scatter_radius'} = clean_blank($1);
|
||||
}
|
||||
} # end of loop for parameter #
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package PandoraFMS::Core;
|
|||
# Core Pandora FMS functions.
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2005-2009 Artica Soluciones Tecnologicas S.L
|
||||
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public License
|
||||
|
@ -17,6 +17,84 @@ package PandoraFMS::Core;
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##########################################################################
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PandoraFMS::Core - Core functions of Pandora FMS
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.1
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use PandoraFMS::Core;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module contains all the base functions of B<Pandora FMS>, the most basic operations of the system are done here.
|
||||
|
||||
=head2 Interface
|
||||
Exported Functions:
|
||||
|
||||
=over
|
||||
|
||||
=item * C<pandora_audit>
|
||||
|
||||
=item * C<pandora_create_agent>
|
||||
|
||||
=item * C<pandora_create_incident>
|
||||
|
||||
=item * C<pandora_create_module>
|
||||
|
||||
=item * C<pandora_evaluate_alert>
|
||||
|
||||
=item * C<pandora_evaluate_compound_alert>
|
||||
|
||||
=item * C<pandora_evaluate_snmp_alerts>
|
||||
|
||||
=item * C<pandora_event>
|
||||
|
||||
=item * C<pandora_execute_alert>
|
||||
|
||||
=item * C<pandora_execute_action>
|
||||
|
||||
=item * C<pandora_exec_forced_alerts>
|
||||
|
||||
=item * C<pandora_generate_alerts>
|
||||
|
||||
=item * C<pandora_generate_compound_alerts>
|
||||
|
||||
=item * C<pandora_module_keep_alive>
|
||||
|
||||
=item * C<pandora_module_keep_alive_nd>
|
||||
|
||||
=item * C<pandora_ping>
|
||||
|
||||
=item * C<pandora_ping_latency>
|
||||
|
||||
=item * C<pandora_planned_downtime>
|
||||
|
||||
=item * C<pandora_process_alert>
|
||||
|
||||
=item * C<pandora_process_module>
|
||||
|
||||
=item * C<pandora_reset_server>
|
||||
|
||||
=item * C<pandora_server_keep_alive>
|
||||
|
||||
=item * C<pandora_update_agent>
|
||||
|
||||
=item * C<pandora_update_module_on_error>
|
||||
|
||||
=item * C<pandora_update_server>
|
||||
|
||||
=back
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
@ -29,6 +107,7 @@ use POSIX qw(strftime);
|
|||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Config;
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::GIS qw(distance_moved);
|
||||
|
||||
require Exporter;
|
||||
|
||||
|
@ -61,7 +140,6 @@ our @EXPORT = qw(
|
|||
pandora_update_agent
|
||||
pandora_update_module_on_error
|
||||
pandora_update_server
|
||||
|
||||
@ServerTypes
|
||||
);
|
||||
|
||||
|
@ -71,7 +149,11 @@ our @ServerTypes = qw (dataserver networkserver snmpconsole reconserver pluginse
|
|||
our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not execute the alert, but increment its internal counter', 'Cease the alert', 'Recover the alert', 'Reset internal counter');
|
||||
|
||||
##########################################################################
|
||||
# Generate alerts for a given module.
|
||||
=head2 C<< pandora_generate_alerts (I<$pa_config> I<$data> I<$status> I<$agent> I<$module> I<$utimestamp> I<$dbh>) >>
|
||||
|
||||
Generate alerts for a given I<$module>.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_generate_alerts ($$$$$$$;$) {
|
||||
my ($pa_config, $data, $status, $agent, $module, $utimestamp, $dbh, $extraMacros) = @_;
|
||||
|
@ -103,13 +185,19 @@ sub pandora_generate_alerts ($$$$$$$;$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Evaluate trigger conditions for a given alert. Returns:
|
||||
# 0 Execute the alert.
|
||||
# 1 Do not execute the alert.
|
||||
# 2 Do not execute the alert, but increment its internal counter.
|
||||
# 3 Cease the alert.
|
||||
# 4 Recover the alert.
|
||||
# 5 Reset internal counter (alert not fired, interval elapsed).
|
||||
=head2 C<< pandora_evaluate_alert (I<$pa_config>, I<$agent>, I<$data>, I<$last_status>, I<$alert>, I<$utimestamp>, I<$dbh>) >>
|
||||
|
||||
Evaluate trigger conditions for a given alert.
|
||||
|
||||
B<Returns>:
|
||||
0 Execute the alert.
|
||||
1 Do not execute the alert.
|
||||
2 Do not execute the alert, but increment its internal counter.
|
||||
3 Cease the alert.
|
||||
4 Recover the alert.
|
||||
5 Reset internal counter (alert not fired, interval elapsed).
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_evaluate_alert ($$$$$$$) {
|
||||
my ($pa_config, $agent, $data, $last_status, $alert, $utimestamp, $dbh) = @_;
|
||||
|
@ -194,7 +282,11 @@ sub pandora_evaluate_alert ($$$$$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Process an alert given the status returned by pandora_evaluate_alert.
|
||||
=head2 C<< pandora_process_alert (I<$pa_config>, I<$data>, I<$agent>, I<$module>, I<$alert>, I<$rc>, I<$dbh>) >>
|
||||
|
||||
Process an alert given the status returned by pandora_evaluate_alert.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_process_alert ($$$$$$$;$) {
|
||||
my ($pa_config, $data, $agent, $module, $alert, $rc, $dbh, $extraMacros) = @_;
|
||||
|
@ -278,8 +370,12 @@ sub pandora_process_alert ($$$$$$$;$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Evaluate the given compound alert. Returns 1 if the alert should be
|
||||
# fired, 0 if not.
|
||||
=head2 C<< pandora_evaluate_compound_alert (I<$pa_config>, I<$id>, I<$name>, I<$dbh>) >>
|
||||
|
||||
Evaluate the given compound alert. Returns 1 if the alert should be
|
||||
fired, 0 if not.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_evaluate_compound_alert ($$$$) {
|
||||
my ($pa_config, $id, $name, $dbh) = @_;
|
||||
|
@ -334,7 +430,11 @@ sub pandora_evaluate_compound_alert ($$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Generate compound alerts that depend on a given alert.
|
||||
=head2 C<< pandora_generate_compound_alerts (I<$pa_config>, I<$data>, I<$status>, I<$agent>, I<$module>, I<$alert>, I<$utimestamp>, I<$dbh>) >>
|
||||
|
||||
Generate compound alerts that depend on a given alert.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_generate_compound_alerts ($$$$$$$$) {
|
||||
my ($pa_config, $data, $status, $agent, $module, $alert, $utimestamp, $dbh) = @_;
|
||||
|
@ -360,7 +460,11 @@ sub pandora_generate_compound_alerts ($$$$$$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Execute the given alert.
|
||||
=head2 C<< pandora_execute_alert (I<$pa_config>, I<$data>, I<$agent>, I<$module>, I<$alert>, I<$alert_mode>, I<$dbh>) >>
|
||||
|
||||
Execute the given alert.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_execute_alert ($$$$$$$;$) {
|
||||
my ($pa_config, $data, $agent, $module,
|
||||
|
@ -420,7 +524,11 @@ sub pandora_execute_alert ($$$$$$$;$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Execute the given action.
|
||||
=head2 C<< pandora_execute_action (I<$pa_config>, I<$data>, I<$agent>, I<$alert>, I<$alert_mode>, I<$action>, I<$module>, I<$dbh>) >>
|
||||
|
||||
Execute the given action.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_execute_action ($$$$$$$$;$) {
|
||||
my ($pa_config, $data, $agent, $alert,
|
||||
|
@ -512,7 +620,11 @@ sub pandora_execute_action ($$$$$$$$;$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Update agent access table.
|
||||
=head2 C<< pandora_access_update (I<$pa_config>, I<$agent_id>, I<$dbh>) >>
|
||||
|
||||
Update agent access table.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_access_update ($$$) {
|
||||
my ($pa_config, $agent_id, $dbh) = @_;
|
||||
|
@ -526,7 +638,11 @@ sub pandora_access_update ($$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Process Pandora module.
|
||||
=head2 C<< pandora_process_module (I<$pa_config>, I<$data>, I<$agent>, I<$module>, I<$module_type>, I<$timestamp>, I<$utimestamp>, I<$server_id>, I<$dbh>) >>
|
||||
|
||||
Process Pandora module.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_process_module ($$$$$$$$$;$) {
|
||||
my ($pa_config, $dataObject, $agent, $module, $module_type,
|
||||
|
@ -620,7 +736,11 @@ sub pandora_process_module ($$$$$$$$$;$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Update planned downtimes.
|
||||
=head2 C<< pandora_planned_downtime (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Update planned downtimes.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_planned_downtime ($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
@ -662,7 +782,11 @@ sub pandora_planned_downtime ($$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Reset the status of all server types for the current server.
|
||||
=head2 C<< pandora_reset_server (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Reset the status of all server types for the current server.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_reset_server ($$) {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
@ -671,8 +795,18 @@ sub pandora_reset_server ($$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Update server status: 0 dataserver, 1 network server, 2 snmp console,
|
||||
# 3 recon, 4 plugin, 5 prediction, 6 wmi.
|
||||
=head2 C<< pandora_update_server (I<$pa_config>, I<$dbh>, I<$server_name>, I<$status>, I<$server_type>, I<$num_threads>, I<$queue_size>) >>
|
||||
|
||||
Update server status:
|
||||
0 dataserver
|
||||
1 network server
|
||||
2 snmp console,
|
||||
3 recon
|
||||
4 plugin
|
||||
5 prediction
|
||||
6 wmi.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_update_server ($$$$$;$$) {
|
||||
my ($pa_config, $dbh, $server_name, $status,
|
||||
|
@ -713,12 +847,16 @@ sub pandora_update_server ($$$$$;$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Update last contact, timezone and position fields in agent table
|
||||
=head2 C<< pandora_update_agent (I<$pa_config>, I<$agent_timestamp>, I<$agent_id>, I<$os_version>, I<$agent_version>, I<$agent_interval>, I<$dbh>, [I<$timezone_offset>], [I<$longitude>], [I<$latitude>], [I<$altitude>], [I<$position_description>]) >>
|
||||
|
||||
Update last contact, timezone and position fields in B<tagente>
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_update_agent ($$$$$$$;$$$$) {
|
||||
sub pandora_update_agent ($$$$$$$;$$$$$) {
|
||||
my ($pa_config, $agent_timestamp, $agent_id, $os_version,
|
||||
$agent_version, $agent_interval, $dbh, $timezone_offset,
|
||||
$longitude, $latitude, $altitude) = @_;
|
||||
$longitude, $latitude, $altitude, $position_description) = @_;
|
||||
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
|
||||
|
||||
|
@ -764,8 +902,14 @@ sub pandora_update_agent ($$$$$$$;$$$$) {
|
|||
|
||||
# If the agent has moved outside the range stablised as location error
|
||||
if (distance_moved($pa_config, $last_agent_info->{'last_longitude'}, $last_agent_info->{'last_latitude'}, $last_agent_info->{'last_altitude'}, $longitude, $latitude, $altitude) > $pa_config->{'location_error'}){
|
||||
# Save the agent data in the agent table
|
||||
save_agent_position($pa_config, $timestamp, $last_agent_info->{'last_longitude'},$last_agent_info->{'last_latitude'}, $last_agent_info->{'last_altitude'}, $agent_id, $dbh);
|
||||
if (defined($position_description)) {
|
||||
# Save the agent data in the agent table
|
||||
save_agent_position($pa_config, $timestamp, $last_agent_info->{'last_longitude'},$last_agent_info->{'last_latitude'}, $last_agent_info->{'last_altitude'}, $position_description, $agent_id, $dbh);
|
||||
}
|
||||
else {
|
||||
# Save the agent data in the agent table
|
||||
save_agent_position($pa_config, $timestamp, $last_agent_info->{'last_longitude'},$last_agent_info->{'last_latitude'}, $last_agent_info->{'last_altitude'},'' , $agent_id, $dbh);
|
||||
}
|
||||
# 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 = ?, timezone_offset = ?,
|
||||
last_longitude = ?, last_latitude =?, last_altitude = ? WHERE id_agente = ?',
|
||||
|
@ -782,47 +926,11 @@ sub pandora_update_agent ($$$$$$$;$$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Measures the distance taking in acount the earth curvature
|
||||
# The distance is based on Havesine formula
|
||||
# Refferences (Theory):
|
||||
# * http://franchu.net/2007/11/16/gis-calculo-de-distancias-sobre-la-tierra/
|
||||
# * http://en.wikipedia.org/wiki/Haversine_formula
|
||||
# References (C implementation):
|
||||
# * http://blog.julien.cayzac.name/2008/10/arc-and-distance-between-two-points-on.html
|
||||
##########################################################################
|
||||
sub distance_moved ($$$$$$$) {
|
||||
my ($pa_config, $last_longitude, $last_latitude, $last_altitude, $longitude, $latitude, $altitude) = @_;
|
||||
=head2 C<< pandora_module_keep_alive (I<$pa_config>, I<$id_agent>, I<$agent_name>, I<$server_id>, I<$dbh>) >>
|
||||
|
||||
my $pi = 4*atan2(1,1);
|
||||
my $earth_radius_in_meters = 6372797.560856;
|
||||
Updates the keep_alive module for the given agent.
|
||||
|
||||
my $long_difference = $last_longitude - $longitude;
|
||||
my $lat_difference = $last_latitude - $latitude;
|
||||
#my $alt_difference = $last_altitude - $altitude;
|
||||
|
||||
my $to_radians= $pi/180;
|
||||
my $to_half_radians= $pi/360;
|
||||
|
||||
my $long_aux = sin ($long_difference*$to_half_radians);
|
||||
my $lat_aux = sin ($lat_difference*$to_half_radians);
|
||||
$long_aux *= $long_aux;
|
||||
$lat_aux *= $lat_aux;
|
||||
# Temporary value to make sorter the asin formula.
|
||||
my $asinaux = sqrt($lat_aux + cos($last_latitude*$to_radians) * cos($latitude*$to_radians) * $long_aux );
|
||||
# Assure the aux value is not greater than 1
|
||||
if ($asinaux > 1) { $asinaux = 1; }
|
||||
# We use: asin(x) = atan2(x, sqrt(1-x*x))
|
||||
my $dist_in_rad = 2.0 * atan2($asinaux, sqrt (1 - $asinaux * $asinaux));
|
||||
my $dist_in_meters = $earth_radius_in_meters * $dist_in_rad;
|
||||
|
||||
logger($pa_config, "Distance moved:" . $dist_in_meters ." meters", 10);
|
||||
|
||||
return $dist_in_meters;
|
||||
}
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Updates the keep_alive module for the given agent.
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_module_keep_alive ($$$$$) {
|
||||
my ($pa_config, $id_agent, $agent_name, $server_id, $dbh) = @_;
|
||||
|
@ -838,7 +946,11 @@ sub pandora_module_keep_alive ($$$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Create an internal Pandora incident.
|
||||
=head2 C<< pandora_create_incident (I<$pa_config>, I<$dbh>, I<$title>, I<$text>, I<$priority>, I<$status>, I<$origin>, I<$id_group>) >>
|
||||
|
||||
Create an internal Pandora incident.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_create_incident ($$$$$$$$) {
|
||||
my ($pa_config, $dbh, $title, $text,
|
||||
|
@ -852,7 +964,11 @@ sub pandora_create_incident ($$$$$$$$) {
|
|||
|
||||
|
||||
##########################################################################
|
||||
# Create an internal audit entry.
|
||||
=head2 C<< pandora_audit (I<$pa_config>, I<$description>, I<$name>, I<$action>, I<$dbh>) >>
|
||||
|
||||
Create an internal audit entry.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_audit ($$$$$) {
|
||||
my ($pa_config, $description, $name, $action, $dbh) = @_;
|
||||
|
@ -871,8 +987,11 @@ sub pandora_audit ($$$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Create a new entry in tagente_modulo and the corresponding entry in
|
||||
# tagente_estado.
|
||||
=head2 C<< pandora_create_module (I<$pa_config>, I<$agent_id>, I<$module_type_id>, I<$module_name>, I<$max>, I<$min>, I<$post_process>, I<$description>, I<$interval>, I<$dbh>) >>
|
||||
|
||||
Create a new entry in tagente_modulo and the corresponding entry in B<tagente_estado>.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_create_module ($$$$$$$$$$) {
|
||||
my ($pa_config, $agent_id, $module_type_id, $module_name, $max,
|
||||
|
@ -893,14 +1012,22 @@ sub pandora_create_module ($$$$$$$$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Create a new entry in tagente with position information
|
||||
=head2 C<< pandora_create_agent (I<$pa_config>, I<$server_name>, I<$agent_name>, I<$address>, I<$address_id>, I<$group_id>, I<$parent_id>, I<$os_id>, I<$description>, I<$interval>, I<$dbh>, [I<$timezone_offset>], [I<$longitude>], [I<$latitude>], [I<$altitude>], [I<$position_description>]) >>
|
||||
|
||||
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,
|
||||
$address_id, $group_id, $parent_id, $os_id,
|
||||
$description, $interval, $dbh, $timezone_offset,
|
||||
$longitude, $latitude, $altitude) = @_;
|
||||
$longitude, $latitude, $altitude, $position_description) = @_;
|
||||
|
||||
|
||||
if (!defined($group_id)) {
|
||||
$group_id = $pa_config->{'autocreate_group'};
|
||||
}
|
||||
logger ($pa_config, "Server '$server_name' creating agent '$agent_name' address '$address'.", 10);
|
||||
|
||||
$description = "Created by $server_name" unless ($description ne '');
|
||||
|
@ -917,19 +1044,27 @@ sub pandora_create_agent ($$$$$$$$$$$;$$$$) {
|
|||
# Save the first position
|
||||
my $utimestamp = time ();
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
||||
save_agent_position($pa_config, $timestamp, $longitude, $latitude, $altitude, $agent_id, $dbh);
|
||||
if (defined($position_description)) {
|
||||
save_agent_position($pa_config, $timestamp, $longitude, $latitude, $altitude, $position_description, $agent_id, $dbh);
|
||||
}
|
||||
else {
|
||||
save_agent_position($pa_config, $timestamp, $longitude, $latitude, $altitude, '', $agent_id, $dbh);
|
||||
}
|
||||
}
|
||||
|
||||
logger ($pa_config, "Server '$server_name' CREATED agent '$agent_name' address '$address'.", 10);
|
||||
# FIXME: use $group_id instead of $pa_config->{'autocreate_group'} ????
|
||||
pandora_event ($pa_config, "Agent [$agent_name] created by $server_name", $pa_config->{'autocreate_group'}, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh);
|
||||
pandora_event ($pa_config, "Agent [$agent_name] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh);
|
||||
return $agent_id;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Generate an event.
|
||||
=head2 C<< pandora_event (I<$pa_config>, I<$evento>, I<$id_grupo>, I<$id_agente>, I<$severity>, I<$id_alert_am>, I<$id_agentmodule>, I<$event_type>, I<$event_status>, I<$dbh>) >>
|
||||
|
||||
Generate an event.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_event ($$$$$$$$$) {
|
||||
sub pandora_event ($$$$$$$$$$) {
|
||||
my ($pa_config, $evento, $id_grupo, $id_agente, $severity,
|
||||
$id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh) = @_;
|
||||
|
||||
|
@ -938,13 +1073,16 @@ sub pandora_event ($$$$$$$$$) {
|
|||
my $utimestamp = time ();
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
||||
$id_agentmodule = 0 unless defined ($id_agentmodule);
|
||||
|
||||
db_do ($dbh, 'INSERT INTO tevento (`id_agente`, `id_grupo`, `evento`, `timestamp`, `estado`, `utimestamp`, `event_type`, `id_agentmodule`, `id_alert_am`, `criticity`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, $evento, $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Update module status on error.
|
||||
=head2 C<< pandora_update_module_on_error (I<$pa_config>, I<$id_agent_module>, I<$dbh>) >>
|
||||
|
||||
Update module status on error.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_update_module_on_error ($$$) {
|
||||
my ($pa_config, $id_agent_module, $dbh) = @_;
|
||||
|
@ -957,7 +1095,11 @@ sub pandora_update_module_on_error ($$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Execute forced alerts.
|
||||
=head2 C<< pandora_exec_forced_alerts (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Execute forced alerts.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_exec_forced_alerts {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
@ -990,7 +1132,11 @@ sub pandora_exec_forced_alerts {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Update keep_alive modules for agents without data.
|
||||
=head2 C<< pandora_module_keep_alive_nd (I<$pa_config>, I<$dbh>) >>
|
||||
|
||||
Update keep_alive modules for agents without data.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_module_keep_alive_nd {
|
||||
my ($pa_config, $dbh) = @_;
|
||||
|
@ -1014,7 +1160,11 @@ sub pandora_module_keep_alive_nd {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Execute alerts that apply to the given SNMP trap.
|
||||
=head2 C<< pandora_evaluate_snmp_alerts (I<$pa_config>, I<$trap_id>, I<$trap_agent>, I<$trap_oid>, I<$trap_oid_text>, I<$trap_custom_oid>, I<$trap_custom_value>, I<$dbh>) >>
|
||||
|
||||
Execute alerts that apply to the given SNMP trap.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_evaluate_snmp_alerts ($$$$$$$$) {
|
||||
my ($pa_config, $trap_id, $trap_agent, $trap_oid,
|
||||
|
@ -1124,7 +1274,14 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$) {
|
|||
}
|
||||
|
||||
##############################################################################
|
||||
# Ping the given host. Returns 1 if the host is alive, 0 otherwise.
|
||||
=head2 C<< pandora_ping (I<$pa_config>, I<$host>) >>
|
||||
|
||||
Ping the given host.
|
||||
Returns:
|
||||
1 if the host is alive
|
||||
0 otherwise.
|
||||
|
||||
=cut
|
||||
##############################################################################
|
||||
sub pandora_ping ($$) {
|
||||
my ($pa_config, $host) = @_;
|
||||
|
@ -1136,7 +1293,11 @@ sub pandora_ping ($$) {
|
|||
}
|
||||
|
||||
##############################################################################
|
||||
# Ping the given host. Returns the average round-trip time.
|
||||
=head2 C<< pandora_ping_latency (I<$pa_config>, I<$host>) >>
|
||||
|
||||
Ping the given host. Returns the average round-trip time.
|
||||
|
||||
=cut
|
||||
##############################################################################
|
||||
sub pandora_ping_latency ($$) {
|
||||
my ($pa_config, $host) = @_;
|
||||
|
@ -1478,7 +1639,11 @@ sub pandora_inhibit_alerts ($$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Updates agent's end_timestamp and number_of_packages in tgis_data table
|
||||
=head2 C<< update_agent_position (I<$pa_config>, I<$timestamp>, I<$agent_id>, I<$dbh>) >>
|
||||
|
||||
# Updates agent's I<end_timestamp> and I<number_of_packages> in B<tgis_data> table
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub update_agent_position($$$$) {
|
||||
my ($pa_config, $timestamp, $agent_id, $dbh) = @_;
|
||||
|
@ -1495,15 +1660,19 @@ sub update_agent_position($$$$) {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Saves the last position of an agent in the tgis_data table
|
||||
=head2 C<< save_agent_position (I<$pa_config>, I<$timestamp>, I<$longitude>, I<$latitude>, I<$altitude>, I<$description>, I<$agent_id>, I<$dbh>) >>
|
||||
|
||||
Saves the last position of an agent in the B<tgis_data> table
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub save_agent_position($$$$$$$) {
|
||||
my ($pa_config, $timestamp, $longitude,$latitude, $altitude, $agent_id, $dbh) = @_;
|
||||
sub save_agent_position($$$$$$$$) {
|
||||
my ($pa_config, $timestamp, $longitude, $latitude, $altitude, $description, $agent_id, $dbh) = @_;
|
||||
|
||||
logger($pa_config, "Saving new agent position: timestamp=$timestamp longitude=$longitude latitude=$latitude altitude=$altitude", 10);
|
||||
|
||||
db_insert($dbh, 'INSERT INTO tgis_data (`longitude`, `latitude`, `altitude`, `tagente_id_agente`, `start_timestamp`, `end_timestamp`) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
$longitude, $latitude, $altitude, $agent_id, $timestamp, $timestamp);
|
||||
db_insert($dbh, 'INSERT INTO tgis_data (`longitude`, `latitude`, `altitude`, `tagente_id_agente`, `start_timestamp`, `end_timestamp`, `description`) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
||||
$longitude, $latitude, $altitude, $agent_id, $timestamp, $timestamp, $description);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1512,3 +1681,22 @@ sub save_agent_position($$$$$$$) {
|
|||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
L<DBI>, L<XML::Simple>, L<HTML::Entities>, L<Time::Local>, L<POSIX>, L<PandoraFMS::DB>, L<PandoraFMS::Config>, L<PandoraFMS::Tools>, L<PandoraFMS::GIS>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
This is released under the GNU Lesser General Public License.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<DBI>, L<XML::Simple>, L<HTML::Entities>, L<Time::Local>, L<POSIX>, L<PandoraFMS::DB>, L<PandoraFMS::Config>, L<PandoraFMS::Tools>, L<PandoraFMS::GIS>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
|
||||
|
||||
|
||||
=cut
|
||||
|
|
|
@ -0,0 +1,238 @@
|
|||
package PandoraFMS::GIS;
|
||||
##########################################################################
|
||||
# GIS Pandora FMS functions.
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser 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.
|
||||
##########################################################################
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PandoraFMS::GIS - Geographic Information System functions of Pandora FMS
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 3.1
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use PandoraFMS::GIS;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module contains the B<GIS> (Geographic Information System) related functions of B<Pandora FMS>
|
||||
|
||||
=head2 Interface
|
||||
Exported Functions:
|
||||
|
||||
=over
|
||||
|
||||
=item * C<distance_moved>
|
||||
|
||||
=item * C<get_reverse_geoip_sql>
|
||||
|
||||
=item * C<get_reverse_geoip_file>
|
||||
|
||||
=item * C<get_random_close_point>
|
||||
|
||||
=back
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Tools;
|
||||
# TODO:Test if is instaled
|
||||
|
||||
my $geoIPPurePerlavilable= (eval 'use Geo::IP::PurePerl; 1') ? 1 : 0;
|
||||
|
||||
|
||||
require Exporter;
|
||||
|
||||
our @ISA = ("Exporter");
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT = qw(
|
||||
distance_moved
|
||||
get_reverse_geoip_sql
|
||||
get_reverse_geoip_file
|
||||
get_random_close_point
|
||||
);
|
||||
# Some intenrnal constants
|
||||
|
||||
my $earth_radius_in_meters = 6372797.560856;
|
||||
my $pi = 4*atan2(1,1);
|
||||
my $to_radians= $pi/180;
|
||||
my $to_half_radians= $pi/360;
|
||||
my $to_degrees = 180/$pi;
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< distance_moved (I<$pa_config>, I<$last_longitude>, I<$last_latitude>, I<$last_altitude>, I<$longitude>, I<$latitude>, I<$altitude>) >>
|
||||
|
||||
Measures the distance between the last position and the previous one taking in acount the earth curvature
|
||||
The distance is based on Havesine formula and so far doesn't take on account the altitude
|
||||
|
||||
B<< Refferences (I<Theory>): >>
|
||||
* L<http://franchu.net/2007/11/16/gis-calculo-de-distancias-sobre-la-tierra/>
|
||||
* L<http://en.wikipedia.org/wiki/Haversine_formula>
|
||||
|
||||
B<< References (I<C implementation>): >>
|
||||
* L<http://blog.julien.cayzac.name/2008/10/arc-and-distance-between-two-points-on.html>
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub distance_moved ($$$$$$$) {
|
||||
my ($pa_config, $last_longitude, $last_latitude, $last_altitude, $longitude, $latitude, $altitude) = @_;
|
||||
|
||||
|
||||
my $long_difference = $last_longitude - $longitude;
|
||||
my $lat_difference = $last_latitude - $latitude;
|
||||
#my $alt_difference = $last_altitude - $altitude;
|
||||
|
||||
|
||||
my $long_aux = sin ($long_difference*$to_half_radians);
|
||||
my $lat_aux = sin ($lat_difference*$to_half_radians);
|
||||
$long_aux *= $long_aux;
|
||||
$lat_aux *= $lat_aux;
|
||||
# Temporary value to make sorter the asin formula.
|
||||
my $asinaux = sqrt($lat_aux + cos($last_latitude*$to_radians) * cos($latitude*$to_radians) * $long_aux );
|
||||
# Assure the aux value is not greater than 1
|
||||
if ($asinaux > 1) { $asinaux = 1; }
|
||||
# We use: asin(x) = atan2(x, sqrt(1-x*x))
|
||||
my $dist_in_rad = 2.0 * atan2($asinaux, sqrt (1 - $asinaux * $asinaux));
|
||||
my $dist_in_meters = $earth_radius_in_meters * $dist_in_rad;
|
||||
|
||||
logger($pa_config, "Distance moved:" . $dist_in_meters ." meters", 10);
|
||||
|
||||
return $dist_in_meters;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< get_revesrse_geoip_sql (I<$pa_config>, I<$ip_addr>, I<$dbh>) >>
|
||||
|
||||
Gets the GIS information obtained from the B<SQL> Database:
|
||||
|
||||
B<Returns>: I<undef> if there is not information available or a B<hash> with:
|
||||
* I<country_code>
|
||||
* I<country_code3>
|
||||
* I<country_name>
|
||||
* I<region>
|
||||
* I<city>
|
||||
* I<postal_code>
|
||||
* I<longitude>
|
||||
* I<latitude>
|
||||
* I<metro_code>
|
||||
* I<area_code>
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub get_reverse_geoip_sql($$$) {
|
||||
my ($pa_config,$ip_addr, $dbh) = @_;
|
||||
|
||||
my $id_range = get_db_value($dbh, 'SELECT `id_range` FROM tgis_reverse_geoip_ranges WHERE INET_ATON(?) >= `first_IP_decimal` AND INET_ATON(?) <= `last_IP_decimal` LIMIT 1', $ip_addr, $ip_addr);
|
||||
if (defined($id_range)) {
|
||||
logger($pa_config,"Range id of '$ip_addr' is '$id_range'", 8);
|
||||
my $region_info = get_db_single_row($dbh, 'SELECT * FROM tgis_reverse_geoip_info WHERE `id_range` = ?',$id_range);
|
||||
logger($pa_config, "region info of id_range '$id_range' is: country:".$region_info->{'country_name'}." region:".$region_info->{'region'}." city:".$region_info->{'city'}." longitude:".$region_info->{'longitude'}." latitude:".$region_info->{'longitude'}, 8);
|
||||
return $region_info;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< get_reverse_geoip_file (I<$pa_config>, I<$ip_addr>) >>
|
||||
|
||||
Gets GIS information from the MaxMind GeooIP database on file using the
|
||||
GPL perl API from MaxMindGeoIP
|
||||
|
||||
B<Returns>: I<undef> if there is not information available or a B<hash> with:
|
||||
* I<country_code>
|
||||
* I<country_code3>
|
||||
* I<country_name>
|
||||
* I<region>
|
||||
* I<city>
|
||||
* I<postal_code>
|
||||
* I<longitude>
|
||||
* I<latitude>
|
||||
* I<metro_code>
|
||||
* I<area_code>
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub get_reverse_geoip_file($$) {
|
||||
my ($pa_config,$ip_addr) = @_;
|
||||
if ($geoIPPurePerlavilable == 1) {
|
||||
my $geoipdb = Geo::IP::PurePerl->open( $pa_config->{'recon_reverse_geolocation_file'});
|
||||
if (defined($geoipdb)) {
|
||||
my $region_info = $geoipdb->get_city_record_as_hash($ip_addr);
|
||||
logger($pa_config, "Region info found for IP '$ip_addr' is: country:".$region_info->{'country_name'}." region:".$region_info->{'region'}." city:".$region_info->{'city'}." longitude:".$region_info->{'longitude'}." latitude:".$region_info->{'longitude'}, 8);
|
||||
return $region_info;
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< get_random_close_point(I<$pa_config>, I<$center_longitude>, I<$center_latitude>) >>
|
||||
|
||||
Gets the B<Longitude> and the B<Laitiutde> of a random point in the surroundings of the
|
||||
coordintaes received (I<$center_longitude>, I<$center_latitude>).
|
||||
|
||||
Returns C<< (I<$longitude>, I<$laitiutde>) >>
|
||||
=cut
|
||||
##########################################################################
|
||||
sub get_random_close_point ($$$) {
|
||||
my ($pa_config, $center_longitude, $center_latitude) = @_;
|
||||
|
||||
my $sign = int rand(2);
|
||||
my $longitude = ($sign*(-1)+(1-$sign)) * rand($pa_config->{'recon_location_scatter_radius'}/$earth_radius_in_meters)*$to_degrees;
|
||||
logger($pa_config,"Longitude random offset '$longitude' ", 8);
|
||||
$longitude += $center_longitude;
|
||||
logger($pa_config,"Longitude with random offset '$longitude' ", 8);
|
||||
$sign = int rand(2);
|
||||
my $latitude = ($sign*(-1)+(1-$sign)) * rand($pa_config->{'recon_location_scatter_radius'}/$earth_radius_in_meters)*$to_degrees;
|
||||
logger($pa_config,"Longitude random offset '$latitude' ", 8);
|
||||
$latitude += $center_latitude;
|
||||
logger($pa_config,"Latiitude with random offset '$latitude' ", 8);
|
||||
return ($longitude, $latitude);
|
||||
}
|
||||
|
||||
# End of function declaration
|
||||
# End of defined Code
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
L<PandoraFMS::DB>, L<PandoraFMS::Tools> (Optional L<Geo::IP::PurePerl> to use file reverse geolocation database that is faster than the SQL)
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
This is released under the GNU Lesser General Public License.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<PandoraFMS::DB>, L<PandoraFMS::Tools>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
|
||||
|
||||
=cut
|
|
@ -32,6 +32,7 @@ use PandoraFMS::Tools;
|
|||
use PandoraFMS::DB;
|
||||
use PandoraFMS::Core;
|
||||
use PandoraFMS::ProducerConsumerServer;
|
||||
use PandoraFMS::GIS qw(get_reverse_geoip_sql get_reverse_geoip_file get_random_close_point);
|
||||
|
||||
# Inherits from PandoraFMS::ProducerConsumerServer
|
||||
our @ISA = qw(PandoraFMS::ProducerConsumerServer);
|
||||
|
@ -164,17 +165,66 @@ sub data_consumer ($$) {
|
|||
next;
|
||||
}
|
||||
|
||||
# Crate a new agent
|
||||
my $agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'},
|
||||
my $agent_id;
|
||||
logger($pa_config, "GIS Status = ".$pa_config->{'activate_gis'}, 10);
|
||||
|
||||
# If GIS is activated try to geolocate the ip address of the agent and store also it's position.
|
||||
|
||||
if($pa_config->{'activate_gis'} == 1 && $pa_config->{'recon_reverse_geolocation_mode'} !~ m/^disabled$/i) {
|
||||
# Try to get aproximated positional information for the Agent.
|
||||
my $region_info = undef;
|
||||
if ($pa_config->{'recon_reverse_geolocation_mode'} =~ m/^sql$/i) {
|
||||
logger($pa_config, "Trying to get gis data of $addr from the SQL database", 8);
|
||||
$region_info = get_reverse_geoip_sql($pa_config, $addr, $dbh);
|
||||
}
|
||||
elsif ($pa_config->{'recon_reverse_geolocation_mode'} =~ m/^file$/i) {
|
||||
logger($pa_config, "Trying to get gis data of $addr from the file database", 8);
|
||||
$region_info = get_reverse_geoip_file($pa_config, $addr);
|
||||
}
|
||||
else {
|
||||
logger($pa_config, "ERROR:Trying to get gis data of $addr. Unknown source", 5);
|
||||
}
|
||||
if (defined($region_info)) {
|
||||
my $location_description = '';
|
||||
if (defined($region_info->{'region'})) {
|
||||
$location_description .= "$region_info->{'region'}, ";
|
||||
}
|
||||
if (defined($region_info->{'city'})) {
|
||||
$location_description .= "$region_info->{'city'}, ";
|
||||
}
|
||||
if (defined($region_info->{'country_name'})) {
|
||||
$location_description .= "($region_info->{'country_name'})";
|
||||
}
|
||||
# We store a random offset in the coordinates to avoid all the agents apear on the same place.
|
||||
my ($longitude, $latitude) = get_random_close_point ($pa_config, $region_info->{'longitude'}, $region_info->{'latitude'});
|
||||
|
||||
logger($pa_config, "Placing agent on random position (Lon,Lat) = ($longitude, $latitude)", 8);
|
||||
# Crate a new agent adding the positional info (as is unknown we set 0 time_offset, and 0 altitude)
|
||||
$agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'},
|
||||
$host_name, $addr, $addr_id,
|
||||
$task->{'id_group'}, $parent_id, $id_os, '', 300, $dbh, 0, $longitude, $latitude, 0, $location_description);
|
||||
}
|
||||
else {
|
||||
logger($pa_config,"Id location of '$addr' for host '$host_name' NOT found", 3);
|
||||
# Crate a new agent
|
||||
$agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'},
|
||||
$host_name, $addr, $addr_id,
|
||||
$task->{'id_group'}, $parent_id, $id_os, '', 300, $dbh);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Crate a new agent
|
||||
$agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'},
|
||||
$host_name, $addr, $addr_id,
|
||||
$task->{'id_group'}, $parent_id, $id_os, '', 300, $dbh);
|
||||
}
|
||||
|
||||
# Assign the new address to the agent
|
||||
db_insert ($dbh, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
|
||||
VALUES (?, ?)', $addr_id, $agent_id);
|
||||
|
||||
# Crate network profile modules for the agent
|
||||
create_network_profile_modules ($pa_config, $dbh, $agent_id, $task->{'id_network_profile'}, $addr);
|
||||
|
||||
# Generate an event
|
||||
pandora_event ($pa_config, "[RECON] New host [$host_name] detected on network [" . $task->{'subnet'} . ']',
|
||||
$task->{'id_group'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $dbh);
|
||||
|
@ -238,7 +288,7 @@ sub guess_os {
|
|||
}
|
||||
|
||||
##########################################################################
|
||||
# Return the ID of the given address, 0 if it does not exist.
|
||||
# Return the ID of the given address, -1 if it does not exist.
|
||||
##########################################################################
|
||||
sub get_addr_id ($$) {
|
||||
my ($dbh, $addr) = @_;
|
||||
|
|
|
@ -0,0 +1,337 @@
|
|||
.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "PandoraFMS::Core 3"
|
||||
.TH PandoraFMS::Core 3 "2010-02-15" "perl v5.10.0" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
PandoraFMS::Core \- Core functions of Pandora FMS
|
||||
.SH "VERSION"
|
||||
.IX Header "VERSION"
|
||||
Version 3.1
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
.Vb 1
|
||||
\& use PandoraFMS::Core;
|
||||
.Ve
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
This module contains all the base functions of \fBPandora \s-1FMS\s0\fR, the most basic operations of the system are done here.
|
||||
.SS "Interface Exported Functions:"
|
||||
.IX Subsection "Interface Exported Functions:"
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_audit\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_create_agent\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_create_incident\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_create_module\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_evaluate_alert\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_evaluate_compound_alert\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_evaluate_snmp_alerts\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_event\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_execute_alert\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_execute_action\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_exec_forced_alerts\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_generate_alerts\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_generate_compound_alerts\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_module_keep_alive\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_module_keep_alive_nd\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_ping\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_ping_latency\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_planned_downtime\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_process_alert\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_process_module\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_reset_server\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_server_keep_alive\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_update_agent\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_update_module_on_error\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`pandora_update_server\*(C'\fR
|
||||
.SH "METHODS"
|
||||
.IX Header "METHODS"
|
||||
.ie n .SS """pandora_generate_alerts (\fI$pa_config\fP \fI$data\fP \fI$status\fP \fI$agent\fP \fI$module\fP \fI$utimestamp\fP \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_generate_alerts (\fP\f(CI$pa_config\fP\f(CW \fP\f(CI$data\fP\f(CW \fP\f(CI$status\fP\f(CW \fP\f(CI$agent\fP\f(CW \fP\f(CI$module\fP\f(CW \fP\f(CI$utimestamp\fP\f(CW \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_generate_alerts ($pa_config $data $status $agent $module $utimestamp $dbh)"
|
||||
Generate alerts for a given \fI\f(CI$module\fI\fR.
|
||||
.ie n .SS """pandora_evaluate_alert (\fI$pa_config\fP, \fI$agent\fP, \fI$data\fP, \fI$last_status\fP, \fI$alert\fP, \fI$utimestamp\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_evaluate_alert (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$agent\fP\f(CW, \fP\f(CI$data\fP\f(CW, \fP\f(CI$last_status\fP\f(CW, \fP\f(CI$alert\fP\f(CW, \fP\f(CI$utimestamp\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_evaluate_alert ($pa_config, $agent, $data, $last_status, $alert, $utimestamp, $dbh)"
|
||||
Evaluate trigger conditions for a given alert.
|
||||
.PP
|
||||
\&\fBReturns\fR:
|
||||
0 Execute the alert.
|
||||
1 Do not execute the alert.
|
||||
2 Do not execute the alert, but increment its internal counter.
|
||||
3 Cease the alert.
|
||||
4 Recover the alert.
|
||||
5 Reset internal counter (alert not fired, interval elapsed).
|
||||
.ie n .SS """pandora_process_alert (\fI$pa_config\fP, \fI$data\fP, \fI$agent\fP, \fI$module\fP, \fI$alert\fP, \fI$rc\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_process_alert (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$data\fP\f(CW, \fP\f(CI$agent\fP\f(CW, \fP\f(CI$module\fP\f(CW, \fP\f(CI$alert\fP\f(CW, \fP\f(CI$rc\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_process_alert ($pa_config, $data, $agent, $module, $alert, $rc, $dbh)"
|
||||
Process an alert given the status returned by pandora_evaluate_alert.
|
||||
.ie n .SS """pandora_evaluate_compound_alert (\fI$pa_config\fP, \fI$id\fP, \fI$name\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_evaluate_compound_alert (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$id\fP\f(CW, \fP\f(CI$name\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_evaluate_compound_alert ($pa_config, $id, $name, $dbh)"
|
||||
Evaluate the given compound alert. Returns 1 if the alert should be
|
||||
fired, 0 if not.
|
||||
.ie n .SS """pandora_generate_compound_alerts (\fI$pa_config\fP, \fI$data\fP, \fI$status\fP, \fI$agent\fP, \fI$module\fP, \fI$alert\fP, \fI$utimestamp\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_generate_compound_alerts (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$data\fP\f(CW, \fP\f(CI$status\fP\f(CW, \fP\f(CI$agent\fP\f(CW, \fP\f(CI$module\fP\f(CW, \fP\f(CI$alert\fP\f(CW, \fP\f(CI$utimestamp\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_generate_compound_alerts ($pa_config, $data, $status, $agent, $module, $alert, $utimestamp, $dbh)"
|
||||
Generate compound alerts that depend on a given alert.
|
||||
.ie n .SS """pandora_execute_alert (\fI$pa_config\fP, \fI$data\fP, \fI$agent\fP, \fI$module\fP, \fI$alert\fP, \fI$alert_mode\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_execute_alert (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$data\fP\f(CW, \fP\f(CI$agent\fP\f(CW, \fP\f(CI$module\fP\f(CW, \fP\f(CI$alert\fP\f(CW, \fP\f(CI$alert_mode\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, $alert_mode, $dbh)"
|
||||
Execute the given alert.
|
||||
.ie n .SS """pandora_execute_action (\fI$pa_config\fP, \fI$data\fP, \fI$agent\fP, \fI$alert\fP, \fI$alert_mode\fP, \fI$action\fP, \fI$module\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_execute_action (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$data\fP\f(CW, \fP\f(CI$agent\fP\f(CW, \fP\f(CI$alert\fP\f(CW, \fP\f(CI$alert_mode\fP\f(CW, \fP\f(CI$action\fP\f(CW, \fP\f(CI$module\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_execute_action ($pa_config, $data, $agent, $alert, $alert_mode, $action, $module, $dbh)"
|
||||
Execute the given action.
|
||||
.ie n .SS """pandora_access_update (\fI$pa_config\fP, \fI$agent_id\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_access_update (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$agent_id\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_access_update ($pa_config, $agent_id, $dbh)"
|
||||
Update agent access table.
|
||||
.ie n .SS """pandora_process_module (\fI$pa_config\fP, \fI$data\fP, \fI$agent\fP, \fI$module\fP, \fI$module_type\fP, \fI$timestamp\fP, \fI$utimestamp\fP, \fI$server_id\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_process_module (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$data\fP\f(CW, \fP\f(CI$agent\fP\f(CW, \fP\f(CI$module\fP\f(CW, \fP\f(CI$module_type\fP\f(CW, \fP\f(CI$timestamp\fP\f(CW, \fP\f(CI$utimestamp\fP\f(CW, \fP\f(CI$server_id\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_process_module ($pa_config, $data, $agent, $module, $module_type, $timestamp, $utimestamp, $server_id, $dbh)"
|
||||
Process Pandora module.
|
||||
.ie n .SS """pandora_planned_downtime (\fI$pa_config\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_planned_downtime (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_planned_downtime ($pa_config, $dbh)"
|
||||
Update planned downtimes.
|
||||
.ie n .SS """pandora_reset_server (\fI$pa_config\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_reset_server (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_reset_server ($pa_config, $dbh)"
|
||||
Reset the status of all server types for the current server.
|
||||
.ie n .SS """pandora_update_server (\fI$pa_config\fP, \fI$dbh\fP, \fI$server_name\fP, \fI$status\fP, \fI$server_type\fP, \fI$num_threads\fP, \fI$queue_size\fP)"""
|
||||
.el .SS "\f(CWpandora_update_server (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$dbh\fP\f(CW, \fP\f(CI$server_name\fP\f(CW, \fP\f(CI$status\fP\f(CW, \fP\f(CI$server_type\fP\f(CW, \fP\f(CI$num_threads\fP\f(CW, \fP\f(CI$queue_size\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_update_server ($pa_config, $dbh, $server_name, $status, $server_type, $num_threads, $queue_size)"
|
||||
Update server status:
|
||||
0 dataserver
|
||||
1 network server
|
||||
2 snmp console,
|
||||
3 recon
|
||||
4 plugin
|
||||
5 prediction
|
||||
6 wmi.
|
||||
.ie n .SS """pandora_update_agent (\fI$pa_config\fP, \fI$agent_timestamp\fP, \fI$agent_id\fP, \fI$os_version\fP, \fI$agent_version\fP, \fI$agent_interval\fP, \fI$dbh\fP, [\fI$timezone_offset\fP], [\fI$longitude\fP], [\fI$latitude\fP], [\fI$altitude\fP], [\fI$position_description\fP])"""
|
||||
.el .SS "\f(CWpandora_update_agent (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$agent_timestamp\fP\f(CW, \fP\f(CI$agent_id\fP\f(CW, \fP\f(CI$os_version\fP\f(CW, \fP\f(CI$agent_version\fP\f(CW, \fP\f(CI$agent_interval\fP\f(CW, \fP\f(CI$dbh\fP\f(CW, [\fP\f(CI$timezone_offset\fP\f(CW], [\fP\f(CI$longitude\fP\f(CW], [\fP\f(CI$latitude\fP\f(CW], [\fP\f(CI$altitude\fP\f(CW], [\fP\f(CI$position_description\fP\f(CW])\fP"
|
||||
.IX Subsection "pandora_update_agent ($pa_config, $agent_timestamp, $agent_id, $os_version, $agent_version, $agent_interval, $dbh, [$timezone_offset], [$longitude], [$latitude], [$altitude], [$position_description])"
|
||||
Update last contact, timezone and position fields in \fBtagente\fR
|
||||
.ie n .SS """pandora_module_keep_alive (\fI$pa_config\fP, \fI$id_agent\fP, \fI$agent_name\fP, \fI$server_id\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_module_keep_alive (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$id_agent\fP\f(CW, \fP\f(CI$agent_name\fP\f(CW, \fP\f(CI$server_id\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_module_keep_alive ($pa_config, $id_agent, $agent_name, $server_id, $dbh)"
|
||||
Updates the keep_alive module for the given agent.
|
||||
.ie n .SS """pandora_create_incident (\fI$pa_config\fP, \fI$dbh\fP, \fI$title\fP, \fI$text\fP, \fI$priority\fP, \fI$status\fP, \fI$origin\fP, \fI$id_group\fP)"""
|
||||
.el .SS "\f(CWpandora_create_incident (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$dbh\fP\f(CW, \fP\f(CI$title\fP\f(CW, \fP\f(CI$text\fP\f(CW, \fP\f(CI$priority\fP\f(CW, \fP\f(CI$status\fP\f(CW, \fP\f(CI$origin\fP\f(CW, \fP\f(CI$id_group\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_create_incident ($pa_config, $dbh, $title, $text, $priority, $status, $origin, $id_group)"
|
||||
Create an internal Pandora incident.
|
||||
.ie n .SS """pandora_audit (\fI$pa_config\fP, \fI$description\fP, \fI$name\fP, \fI$action\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_audit (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$description\fP\f(CW, \fP\f(CI$name\fP\f(CW, \fP\f(CI$action\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_audit ($pa_config, $description, $name, $action, $dbh)"
|
||||
Create an internal audit entry.
|
||||
.ie n .SS """pandora_create_module (\fI$pa_config\fP, \fI$agent_id\fP, \fI$module_type_id\fP, \fI$module_name\fP, \fI$max\fP, \fI$min\fP, \fI$post_process\fP, \fI$description\fP, \fI$interval\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_create_module (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$agent_id\fP\f(CW, \fP\f(CI$module_type_id\fP\f(CW, \fP\f(CI$module_name\fP\f(CW, \fP\f(CI$max\fP\f(CW, \fP\f(CI$min\fP\f(CW, \fP\f(CI$post_process\fP\f(CW, \fP\f(CI$description\fP\f(CW, \fP\f(CI$interval\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_create_module ($pa_config, $agent_id, $module_type_id, $module_name, $max, $min, $post_process, $description, $interval, $dbh)"
|
||||
Create a new entry in tagente_modulo and the corresponding entry in \fBtagente_estado\fR.
|
||||
.ie n .SS """pandora_create_agent (\fI$pa_config\fP, \fI$server_name\fP, \fI$agent_name\fP, \fI$address\fP, \fI$address_id\fP, \fI$group_id\fP, \fI$parent_id\fP, \fI$os_id\fP, \fI$description\fP, \fI$interval\fP, \fI$dbh\fP, [\fI$timezone_offset\fP], [\fI$longitude\fP], [\fI$latitude\fP], [\fI$altitude\fP], [\fI$position_description\fP])"""
|
||||
.el .SS "\f(CWpandora_create_agent (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$server_name\fP\f(CW, \fP\f(CI$agent_name\fP\f(CW, \fP\f(CI$address\fP\f(CW, \fP\f(CI$address_id\fP\f(CW, \fP\f(CI$group_id\fP\f(CW, \fP\f(CI$parent_id\fP\f(CW, \fP\f(CI$os_id\fP\f(CW, \fP\f(CI$description\fP\f(CW, \fP\f(CI$interval\fP\f(CW, \fP\f(CI$dbh\fP\f(CW, [\fP\f(CI$timezone_offset\fP\f(CW], [\fP\f(CI$longitude\fP\f(CW], [\fP\f(CI$latitude\fP\f(CW], [\fP\f(CI$altitude\fP\f(CW], [\fP\f(CI$position_description\fP\f(CW])\fP"
|
||||
.IX Subsection "pandora_create_agent ($pa_config, $server_name, $agent_name, $address, $address_id, $group_id, $parent_id, $os_id, $description, $interval, $dbh, [$timezone_offset], [$longitude], [$latitude], [$altitude], [$position_description])"
|
||||
Create a new entry in \fBtagente\fR optionaly with position information
|
||||
.ie n .SS """pandora_event (\fI$pa_config\fP, \fI$evento\fP, \fI$id_grupo\fP, \fI$id_agente\fP, \fI$severity\fP, \fI$id_alert_am\fP, \fI$id_agentmodule\fP, \fI$event_type\fP, \fI$event_status\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_event (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$evento\fP\f(CW, \fP\f(CI$id_grupo\fP\f(CW, \fP\f(CI$id_agente\fP\f(CW, \fP\f(CI$severity\fP\f(CW, \fP\f(CI$id_alert_am\fP\f(CW, \fP\f(CI$id_agentmodule\fP\f(CW, \fP\f(CI$event_type\fP\f(CW, \fP\f(CI$event_status\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_event ($pa_config, $evento, $id_grupo, $id_agente, $severity, $id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh)"
|
||||
Generate an event.
|
||||
.ie n .SS """pandora_update_module_on_error (\fI$pa_config\fP, \fI$id_agent_module\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_update_module_on_error (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$id_agent_module\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_update_module_on_error ($pa_config, $id_agent_module, $dbh)"
|
||||
Update module status on error.
|
||||
.ie n .SS """pandora_exec_forced_alerts (\fI$pa_config\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_exec_forced_alerts (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_exec_forced_alerts ($pa_config, $dbh)"
|
||||
Execute forced alerts.
|
||||
.ie n .SS """pandora_module_keep_alive_nd (\fI$pa_config\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_module_keep_alive_nd (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_module_keep_alive_nd ($pa_config, $dbh)"
|
||||
Update keep_alive modules for agents without data.
|
||||
.ie n .SS """pandora_evaluate_snmp_alerts (\fI$pa_config\fP, \fI$trap_id\fP, \fI$trap_agent\fP, \fI$trap_oid\fP, \fI$trap_oid_text\fP, \fI$trap_custom_oid\fP, \fI$trap_custom_value\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWpandora_evaluate_snmp_alerts (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$trap_id\fP\f(CW, \fP\f(CI$trap_agent\fP\f(CW, \fP\f(CI$trap_oid\fP\f(CW, \fP\f(CI$trap_oid_text\fP\f(CW, \fP\f(CI$trap_custom_oid\fP\f(CW, \fP\f(CI$trap_custom_value\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $trap_agent, $trap_oid, $trap_oid_text, $trap_custom_oid, $trap_custom_value, $dbh)"
|
||||
Execute alerts that apply to the given \s-1SNMP\s0 trap.
|
||||
.ie n .SS """pandora_ping (\fI$pa_config\fP, \fI$host\fP)"""
|
||||
.el .SS "\f(CWpandora_ping (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$host\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_ping ($pa_config, $host)"
|
||||
Ping the given host.
|
||||
Returns:
|
||||
1 if the host is alive
|
||||
0 otherwise.
|
||||
.ie n .SS """pandora_ping_latency (\fI$pa_config\fP, \fI$host\fP)"""
|
||||
.el .SS "\f(CWpandora_ping_latency (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$host\fP\f(CW)\fP"
|
||||
.IX Subsection "pandora_ping_latency ($pa_config, $host)"
|
||||
Ping the given host. Returns the average round-trip time.
|
||||
.ie n .SS """update_agent_position (\fI$pa_config\fP, \fI$timestamp\fP, \fI$agent_id\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWupdate_agent_position (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$timestamp\fP\f(CW, \fP\f(CI$agent_id\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "update_agent_position ($pa_config, $timestamp, $agent_id, $dbh)"
|
||||
# Updates agent's \fIend_timestamp\fR and \fInumber_of_packages\fR in \fBtgis_data\fR table
|
||||
.ie n .SS """save_agent_position (\fI$pa_config\fP, \fI$timestamp\fP, \fI$longitude\fP, \fI$latitude\fP, \fI$altitude\fP, \fI$description\fP, \fI$agent_id\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWsave_agent_position (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$timestamp\fP\f(CW, \fP\f(CI$longitude\fP\f(CW, \fP\f(CI$latitude\fP\f(CW, \fP\f(CI$altitude\fP\f(CW, \fP\f(CI$description\fP\f(CW, \fP\f(CI$agent_id\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "save_agent_position ($pa_config, $timestamp, $longitude, $latitude, $altitude, $description, $agent_id, $dbh)"
|
||||
Saves the last position of an agent in the \fBtgis_data\fR table
|
||||
.SH "DEPENDENCIES"
|
||||
.IX Header "DEPENDENCIES"
|
||||
\&\s-1DBI\s0, XML::Simple, HTML::Entities, Time::Local, \s-1POSIX\s0, PandoraFMS::DB, PandoraFMS::Config, PandoraFMS::Tools, PandoraFMS::GIS
|
||||
.SH "LICENSE"
|
||||
.IX Header "LICENSE"
|
||||
This is released under the \s-1GNU\s0 Lesser General Public License.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
\&\s-1DBI\s0, XML::Simple, HTML::Entities, Time::Local, \s-1POSIX\s0, PandoraFMS::DB, PandoraFMS::Config, PandoraFMS::Tools, PandoraFMS::GIS
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 2005\-2010 Artica Soluciones Tecnologicas S.L
|
|
@ -0,0 +1,220 @@
|
|||
.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "PandoraFMS::GIS 3"
|
||||
.TH PandoraFMS::GIS 3 "2010-02-15" "perl v5.10.0" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
PandoraFMS::GIS \- Geographic Information System functions of Pandora FMS
|
||||
.SH "VERSION"
|
||||
.IX Header "VERSION"
|
||||
Version 3.1
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
.Vb 1
|
||||
\& use PandoraFMS::GIS;
|
||||
.Ve
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
This module contains the \fB\s-1GIS\s0\fR (Geographic Information System) related functions of \fBPandora \s-1FMS\s0\fR
|
||||
.SS "Interface Exported Functions:"
|
||||
.IX Subsection "Interface Exported Functions:"
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`distance_moved\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`get_reverse_geoip_sql\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`get_reverse_geoip_file\*(C'\fR
|
||||
.IP "\(bu" 4
|
||||
\&\f(CW\*(C`get_random_close_point\*(C'\fR
|
||||
.SH "METHODS"
|
||||
.IX Header "METHODS"
|
||||
.ie n .SS """distance_moved (\fI$pa_config\fP, \fI$last_longitude\fP, \fI$last_latitude\fP, \fI$last_altitude\fP, \fI$longitude\fP, \fI$latitude\fP, \fI$altitude\fP)"""
|
||||
.el .SS "\f(CWdistance_moved (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$last_longitude\fP\f(CW, \fP\f(CI$last_latitude\fP\f(CW, \fP\f(CI$last_altitude\fP\f(CW, \fP\f(CI$longitude\fP\f(CW, \fP\f(CI$latitude\fP\f(CW, \fP\f(CI$altitude\fP\f(CW)\fP"
|
||||
.IX Subsection "distance_moved ($pa_config, $last_longitude, $last_latitude, $last_altitude, $longitude, $latitude, $altitude)"
|
||||
Measures the distance between the last position and the previous one taking in acount the earth curvature
|
||||
The distance is based on Havesine formula and so far doesn't take on account the altitude
|
||||
.PP
|
||||
\&\fBRefferences (\f(BITheory\fB):\fR
|
||||
* <http://franchu.net/2007/11/16/gis\-calculo\-de\-distancias\-sobre\-la\-tierra/>
|
||||
* <http://en.wikipedia.org/wiki/Haversine_formula>
|
||||
.PP
|
||||
\&\fBReferences (\f(BIC implementation\fB):\fR
|
||||
* <http://blog.julien.cayzac.name/2008/10/arc\-and\-distance\-between\-two\-points\-on.html>
|
||||
.ie n .SS """get_revesrse_geoip_sql (\fI$pa_config\fP, \fI$ip_addr\fP, \fI$dbh\fP)"""
|
||||
.el .SS "\f(CWget_revesrse_geoip_sql (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$ip_addr\fP\f(CW, \fP\f(CI$dbh\fP\f(CW)\fP"
|
||||
.IX Subsection "get_revesrse_geoip_sql ($pa_config, $ip_addr, $dbh)"
|
||||
Gets the \s-1GIS\s0 information obtained from the \fB\s-1SQL\s0\fR Database:
|
||||
.PP
|
||||
\&\fBReturns\fR: \fIundef\fR if there is not information available or a \fBhash\fR with:
|
||||
* \fIcountry_code\fR
|
||||
* \fIcountry_code3\fR
|
||||
* \fIcountry_name\fR
|
||||
* \fIregion\fR
|
||||
* \fIcity\fR
|
||||
* \fIpostal_code\fR
|
||||
* \fIlongitude\fR
|
||||
* \fIlatitude\fR
|
||||
* \fImetro_code\fR
|
||||
* \fIarea_code\fR
|
||||
.ie n .SS """get_reverse_geoip_file (\fI$pa_config\fP, \fI$ip_addr\fP)"""
|
||||
.el .SS "\f(CWget_reverse_geoip_file (\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$ip_addr\fP\f(CW)\fP"
|
||||
.IX Subsection "get_reverse_geoip_file ($pa_config, $ip_addr)"
|
||||
Gets \s-1GIS\s0 information from the MaxMind GeooIP database on file using the
|
||||
\&\s-1GPL\s0 perl \s-1API\s0 from MaxMindGeoIP
|
||||
.PP
|
||||
\&\fBReturns\fR: \fIundef\fR if there is not information available or a \fBhash\fR with:
|
||||
* \fIcountry_code\fR
|
||||
* \fIcountry_code3\fR
|
||||
* \fIcountry_name\fR
|
||||
* \fIregion\fR
|
||||
* \fIcity\fR
|
||||
* \fIpostal_code\fR
|
||||
* \fIlongitude\fR
|
||||
* \fIlatitude\fR
|
||||
* \fImetro_code\fR
|
||||
* \fIarea_code\fR
|
||||
.ie n .SS """get_random_close_point(\fI$pa_config\fP, \fI$center_longitude\fP, \fI$center_latitude\fP)"""
|
||||
.el .SS "\f(CWget_random_close_point(\fP\f(CI$pa_config\fP\f(CW, \fP\f(CI$center_longitude\fP\f(CW, \fP\f(CI$center_latitude\fP\f(CW)\fP"
|
||||
.IX Subsection "get_random_close_point($pa_config, $center_longitude, $center_latitude)"
|
||||
Gets the \fBLongitude\fR and the \fBLaitiutde\fR of a random point in the surroundings of the
|
||||
coordintaes received (\fI\f(CI$center_longitude\fI\fR, \fI\f(CI$center_latitude\fI\fR).
|
||||
.PP
|
||||
Returns \f(CW\*(C`(\f(CI$longitude\f(CW, \f(CI$laitiutde\f(CW)\*(C'\fR
|
||||
.SH "DEPENDENCIES"
|
||||
.IX Header "DEPENDENCIES"
|
||||
PandoraFMS::DB, PandoraFMS::Tools (Optional Geo::IP::PurePerl to use file reverse geolocation database that is faster than the \s-1SQL\s0)
|
||||
.SH "LICENSE"
|
||||
.IX Header "LICENSE"
|
||||
This is released under the \s-1GNU\s0 Lesser General Public License.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
PandoraFMS::DB, PandoraFMS::Tools
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 2005\-2010 Artica Soluciones Tecnologicas S.L
|
Loading…
Reference in New Issue