2010-02-25 Pablo de la Concepción <pablo.concepcion@artica.es>
* conf/pandora_server.conf: New option, update_parent to let the agent update it's parent by sending the parent name on the XML. * lib/PandoraFMS/Config.pm: Support for new option update_parent. * lib/PandoraFMS/Core.pm, lib/PandoraFMS/Dataserver.pm: Modified to update the parent of an agent at creation time and on update if the update_parent parameter is set to 1 * man/man3/PandoraFMS::Core.pm.3: Updated manpage with the new documentation of the interface git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2422 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
213ec3df72
commit
ba7ed06c8a
|
@ -1,3 +1,17 @@
|
|||
2010-02-25 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* conf/pandora_server.conf: New option, update_parent to let the
|
||||
agent update it's parent by sending the parent name on the XML.
|
||||
|
||||
* lib/PandoraFMS/Config.pm: Support for new option update_parent.
|
||||
|
||||
* lib/PandoraFMS/Core.pm, lib/PandoraFMS/Dataserver.pm: Modified to
|
||||
update the parent of an agent at creation time and on update if
|
||||
the update_parent parameter is set to 1
|
||||
|
||||
* man/man3/PandoraFMS::Core.pm.3: Updated manpage with the new
|
||||
documentation of the interface
|
||||
|
||||
2010-02-24 Pablo de la Concepción <pablo.concepcion@artica.es>
|
||||
|
||||
* lib/PandoraFMS/Core.pm, lib/PandoraFMS/Dataserver.pm: Modified to
|
||||
|
|
|
@ -259,3 +259,6 @@ max_queue_files 250
|
|||
|
||||
# Pandora Server self-monitoring (embedded agent) (by default disabled)
|
||||
# self_monitoring 1
|
||||
|
||||
# Update parent from the agent xml
|
||||
#update_parent 1
|
||||
|
|
|
@ -226,6 +226,7 @@ sub pandora_load_config {
|
|||
$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->{"update_parent"} = 0; # 3.1
|
||||
|
||||
$pa_config->{"max_queue_files"} = 250;
|
||||
|
||||
|
@ -576,6 +577,9 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^self_monitoring\s([0-1])/i) {
|
||||
$pa_config->{'self_monitoring'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^update_parent\s([0-1])/i) {
|
||||
$pa_config->{'update_parent'} = clean_blank($1);
|
||||
}
|
||||
} # end of loop for parameter #
|
||||
|
||||
|
||||
|
|
|
@ -865,15 +865,15 @@ sub pandora_update_server ($$$$$;$$) {
|
|||
=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>]) [I<$parent_agent_name>]) >>
|
||||
|
||||
Update last contact, timezone fields in B<tagente> and current position (this
|
||||
can affect B<tgis_data_status> and B<tgis_data_history>). If the I<$parent_agent_name> is
|
||||
defined and there is an agent with that name, also the parent is updated.
|
||||
can affect B<tgis_data_status> and B<tgis_data_history>). If the I<$parent_agent_id> is
|
||||
defined also the parent is updated.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_update_agent ($$$$$$$;$$$$$$) {
|
||||
my ($pa_config, $agent_timestamp, $agent_id, $os_version,
|
||||
$agent_version, $agent_interval, $dbh, $timezone_offset,
|
||||
$longitude, $latitude, $altitude, $position_description, $parent_agent_name) = @_;
|
||||
$longitude, $latitude, $altitude, $position_description, $parent_agent_id) = @_;
|
||||
|
||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
|
||||
|
||||
|
@ -885,17 +885,6 @@ sub pandora_update_agent ($$$$$$$;$$$$$$) {
|
|||
pandora_access_update ($pa_config, $agent_id, $dbh);
|
||||
}
|
||||
|
||||
# Check if the parent is defined and exist.
|
||||
my $parent_id = '';
|
||||
if (defined ($parent_agent_name)) {
|
||||
$parent_id = get_agent_id ($dbh, $parent_agent_name);
|
||||
if ($parent_id < 1) {
|
||||
logger($pa_config, "Can't set parent: Parent with name '$parent_agent_name' not found",8);
|
||||
$parent_id = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# No update for interval, timezone and position fields (some old agents don't support it)
|
||||
if ($agent_interval == -1){
|
||||
db_do($dbh, 'UPDATE tagente SET agent_version = ?, ultimo_contacto_remoto = ?, ultimo_contacto = ?, os_version = ? WHERE id_agente = ?',
|
||||
|
@ -904,11 +893,11 @@ sub pandora_update_agent ($$$$$$$;$$$$$$) {
|
|||
}
|
||||
|
||||
if ( defined ($timezone_offset)) {
|
||||
if ($parent_id != '') {
|
||||
if (defined($parent_agent_id)) {
|
||||
# Update the table tagente with all the new data and set the new parent
|
||||
db_do ($dbh, 'UPDATE tagente SET intervalo = ?, agent_version = ?, ultimo_contacto_remoto = ?, ultimo_contacto = ?, os_version = ?,
|
||||
timezone_offset = ?, id_parent = ? WHERE id_agente = ?', $agent_interval, $agent_version, $agent_timestamp, $timestamp, $os_version,
|
||||
$timezone_offset, $parent_id, $agent_id);
|
||||
$timezone_offset, $parent_agent_id, $agent_id);
|
||||
}
|
||||
else {
|
||||
# Update the table tagente with all the new data
|
||||
|
@ -917,10 +906,10 @@ sub pandora_update_agent ($$$$$$$;$$$$$$) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if ($parent_id != '') {
|
||||
if (defined($parent_agent_id)) {
|
||||
# Update the table tagente with all the new data and set the new parent
|
||||
db_do ($dbh, 'UPDATE tagente SET intervalo = ?, agent_version = ?, ultimo_contacto_remoto = ?, ultimo_contacto = ?, os_version = ?, id_parent = ?
|
||||
WHERE id_agente = ?', $agent_interval, $agent_version, $agent_timestamp, $timestamp, $os_version, $parent_id, $agent_id);
|
||||
WHERE id_agente = ?', $agent_interval, $agent_version, $agent_timestamp, $timestamp, $os_version, $parent_agent_id, $agent_id);
|
||||
}
|
||||
else {
|
||||
# Update the table tagente with all the new data
|
||||
|
|
|
@ -163,7 +163,15 @@ sub process_xml_data ($$$$$) {
|
|||
}
|
||||
|
||||
# Parent Agent Name
|
||||
my $parent_id = 0; # Default value for unknown parent
|
||||
my $parent_agent_name = $data->{'parent_agent_name'};
|
||||
if (defined ($parent_agent_name)) {
|
||||
$parent_id = get_agent_id ($dbh, $parent_agent_name);
|
||||
if ($parent_id < 1) { # Unknown parent
|
||||
$parent_id = 0;
|
||||
}
|
||||
}
|
||||
logger($pa_config,"Parent_agent_name: $parent_agent_name parent_id: $parent_id",10);
|
||||
|
||||
my $valid_position_data = 1;
|
||||
|
||||
|
@ -250,12 +258,12 @@ sub process_xml_data ($$$$$) {
|
|||
# Create the agent
|
||||
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0 ) {
|
||||
logger($pa_config, "Creating agent $agent_name at long: $longitude lat: $latitude alt: $altitude", 5);
|
||||
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, '', 0, $group_id, 0, $os,
|
||||
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, '', 0, $group_id, $parent_id, $os,
|
||||
$description, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude, $position_description);
|
||||
}
|
||||
else { # Ignore agent positional data
|
||||
logger($pa_config, "Creating agent $agent_name", 5);
|
||||
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, '', 0, $group_id, 0, $os,
|
||||
$agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, '', 0, $group_id, $parent_id, $os,
|
||||
$description, $interval, $dbh, $timezone_offset);
|
||||
}
|
||||
if (! defined ($agent_id)) {
|
||||
|
@ -263,24 +271,16 @@ sub process_xml_data ($$$$$) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
else { # The agent was already created
|
||||
my $mode = get_db_value($dbh, 'SELECT modo FROM tagente WHERE id_agente = ?', $agent_id);
|
||||
logger($pa_config,"Parent_agent_name $parent_agent_name",10);
|
||||
if ($mode == 0) { #The agent is not learning so ignore the parent.
|
||||
$parent_agent_name = '';
|
||||
}
|
||||
logger($pa_config,"Parent_agent_name $parent_agent_name",10);
|
||||
}
|
||||
$AgentSem->up ();
|
||||
|
||||
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0) {
|
||||
logger($pa_config,"Parent_agent_name $parent_agent_name",10);
|
||||
if (defined($parent_agent_name) && $parent_agent_name ne '') {
|
||||
if ($pa_config->{'update_parent'} == 1 && $parent_id != 0) {
|
||||
logger($pa_config,"Parent_agent_name $parent_agent_name",10);
|
||||
logger($pa_config, "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude parent: $parent_agent_name", 5);
|
||||
logger($pa_config, "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude parent_id: $parent_id", 5);
|
||||
# Update agent information including position information and the paret
|
||||
pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset,
|
||||
$longitude, $latitude, $altitude, $position_description, $parent_agent_name);
|
||||
$longitude, $latitude, $altitude, $position_description, $parent_id);
|
||||
}
|
||||
else {
|
||||
logger($pa_config, "Updating agent $agent_name at long: $longitude lat: $latitude alt: $altitude", 5);
|
||||
|
@ -288,10 +288,10 @@ sub process_xml_data ($$$$$) {
|
|||
} pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $longitude, $latitude, $altitude, $position_description);
|
||||
}
|
||||
else {
|
||||
if (defined($parent_agent_name) && $parent_agent_name ne '') {
|
||||
logger($pa_config, "Updating agent $agent_name", 5);
|
||||
if ($pa_config->{'update_parent'} == 1 && $parent_id != 0) {
|
||||
logger($pa_config, "Updating agent $agent_name parent_id: $parent_id", 5);
|
||||
# Update agent information including the parent without position information
|
||||
pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, undef, undef, undef, undef, $parent_agent_name);
|
||||
pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, undef, undef, undef, undef, $parent_id);
|
||||
}
|
||||
else {
|
||||
logger($pa_config, "Updating agent $agent_name", 5);
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "PandoraFMS::Core 3"
|
||||
.TH PandoraFMS::Core 3 "2010-02-24" "perl v5.10.0" "User Contributed Perl Documentation"
|
||||
.TH PandoraFMS::Core 3 "2010-02-25" "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
|
||||
|
@ -270,8 +270,8 @@ Update server status:
|
|||
.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\f(CI$parent_agent_name\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]) [$parent_agent_name])"
|
||||
Update last contact, timezone fields in \fBtagente\fR and current position (this
|
||||
can affect \fBtgis_data_status\fR and \fBtgis_data_history\fR). If the \fI\f(CI$parent_agent_name\fI\fR is
|
||||
defined and there is an agent with that name, also the parent is updated.
|
||||
can affect \fBtgis_data_status\fR and \fBtgis_data_history\fR). If the \fI\f(CI$parent_agent_id\fI\fR is
|
||||
defined also the parent is updated.
|
||||
.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)"
|
||||
|
|
Loading…
Reference in New Issue