From 3126a2a3cd995e74a92a75d6c11a1eb32b186069 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 3 Aug 2009 15:12:07 +0000 Subject: [PATCH] 2009-08-03 Ramon Novoa * lib/PandoraFMS/Core.pm: Add id_agente to tagente_estado when creating a new module. * lib/PandoraFMS/DataServer.pm: Added support for inventory XML files. * lib/PandoraFMS/Tools.pm: Moved get_tag_value function from DataServer.pm to Tools.pm. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1826 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 10 ++++++++ pandora_server/lib/PandoraFMS/Core.pm | 2 +- pandora_server/lib/PandoraFMS/DataServer.pm | 26 ++++++--------------- pandora_server/lib/PandoraFMS/Tools.pm | 20 ++++++++++++++++ 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index b1d19f9a18..8377ba681a 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,13 @@ +2009-08-03 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Add id_agente to tagente_estado when + creating a new module. + + * lib/PandoraFMS/DataServer.pm: Added support for inventory XML files. + + * lib/PandoraFMS/Tools.pm: Moved get_tag_value function from + DataServer.pm to Tools.pm. + 2009-07-30 Manuel Arostegui * SLES10/pandora_wmi, pandora_plugin, pandora_prediction diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 70c444911f..c0006bfba7 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -720,7 +720,7 @@ sub pandora_create_module ($$$$$$$$) { my $module_id = db_insert($dbh, 'INSERT INTO tagente_modulo (`id_agente`, `id_tipo_modulo`, `nombre`, `max`, `min`, `descripcion`, `module_interval`, `id_modulo`) VALUES (?, ?, ?, ?, ?, ?, ?, 1)', $agent_id, $module_type_id, $module_name, $max, $min, $description, $interval); - db_do ($dbh, 'INSERT INTO tagente_estado (`id_agente_modulo`, `last_try`) VALUES (?, \'0000-00-00 00:00:00\')', $module_id); + db_do ($dbh, 'INSERT INTO tagente_estado (`id_agente_modulo`, `id_agente`, `last_try`) VALUES (?, ?, \'0000-00-00 00:00:00\')', $module_id, $agent_id); return $module_id; } diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 7c6e0f9aad..9e552b39c4 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -32,6 +32,9 @@ use PandoraFMS::DB; use PandoraFMS::Core; use PandoraFMS::ProducerConsumerServer; +# Load enterprise module +enterprise_load (); + # Inherits from PandoraFMS::ProducerConsumerServer our @ISA = qw(PandoraFMS::ProducerConsumerServer); @@ -214,6 +217,10 @@ sub process_xml_data ($$$$) { } } } + + # Process inventory modules + enterprise_hook('process_inventory_data', [$pa_config, $data, $server_id, $agent_name, + $interval, $timestamp, $dbh]); } ########################################################################## @@ -260,24 +267,5 @@ sub process_module_data ($$$$$$$$$) { } } -########################################################################## -# Returns the value of an XML tag from a hash returned by XMLin (one level -# depth). -########################################################################## -sub get_tag_value ($$$) { - my ($hash_ref, $tag, $def_value) = @_; - - return $def_value unless defined ($hash_ref->{$tag}) and ref ($hash_ref->{$tag}); - - # Return the first found value - foreach my $value (@{$hash_ref->{$tag}}) { - - # If the tag is defined but has no value a ref to an empty hash is returned by XML::Simple - return $value unless ref ($value); - } - - return $def_value; -} - 1; __END__ diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 17020b529c..45b67b8dd4 100644 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -42,6 +42,7 @@ our @EXPORT = qw( enterprise_hook enterprise_load print_message + get_tag_value ); ########################################################################## @@ -362,6 +363,25 @@ sub print_message ($$$) { } } +########################################################################## +# Returns the value of an XML tag from a hash returned by XMLin (one level +# depth). +########################################################################## +sub get_tag_value ($$$) { + my ($hash_ref, $tag, $def_value) = @_; + + return $def_value unless defined ($hash_ref->{$tag}) and ref ($hash_ref->{$tag}); + + # Return the first found value + foreach my $value (@{$hash_ref->{$tag}}) { + + # If the tag is defined but has no value a ref to an empty hash is returned by XML::Simple + return $value unless ref ($value); + } + + return $def_value; +} + # End of function declaration # End of defined Code