2010-10-19 Sergio Martin <sergio.martin@artica.es>

* lib/PandoraFMS/Core.pm
	util/pandora_manage.pl: Moved and renamed the module
	creation from hash function from CLI to Core



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3420 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-10-19 09:53:16 +00:00
parent 9ce6297c53
commit 40f27f4576
3 changed files with 30 additions and 21 deletions

View File

@ -1,3 +1,9 @@
2010-10-19 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/Core.pm
util/pandora_manage.pl: Moved and renamed the module
creation from hash function from CLI to Core
2010-10-18 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/DB.pm

View File

@ -133,6 +133,7 @@ our @EXPORT = qw(
pandora_create_agent
pandora_create_incident
pandora_create_module
pandora_create_module_from_hash
pandora_evaluate_alert
pandora_evaluate_compound_alert
pandora_evaluate_snmp_alerts
@ -1094,6 +1095,21 @@ sub pandora_create_module ($$$$$$$$$$) {
return $module_id;
}
##########################################################################
## Create an agent module
##########################################################################
sub pandora_create_module_from_hash ($$$) {
my ($pa_config, $parameters, $dbh) = @_;
logger($pa_config, "Creating module '$parameters->{'nombre'}' for agent ID $parameters->{'id_agente'}.", 10);
my $module_id = db_process_insert($dbh, 'tagente_modulo', $parameters);
db_do ($dbh, 'INSERT INTO tagente_estado (`id_agente_modulo`, `id_agente`, `last_try`) VALUES (?, ?, \'0000-00-00 00:00:00\')', $module_id, $parameters->{'id_agente'});
return $module_id;
}
##########################################################################
=head2 C<< pandora_create_agent (I<$pa_config>, I<$server_name>, I<$agent_name>, I<$address>, 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>]) >>

View File

@ -396,21 +396,6 @@ sub pandora_delete_module_data ($$) {
return 1;
}
##########################################################################
## Create an agent module
##########################################################################
sub pandora_create_agent_module ($$$) {
my ($pa_config, $parameters, $dbh) = @_;
logger($pa_config, "Creating module '$parameters->{'name'}' for agent ID $parameters->{'id_agente'}.", 10);
my $module_id = db_process_insert($dbh, 'tagente_modulo', $parameters);
db_do ($dbh, 'INSERT INTO tagente_estado (`id_agente_modulo`, `id_agente`, `last_try`) VALUES (?, ?, \'0000-00-00 00:00:00\')', $module_id, $parameters->{'id_agente'});
return $module_id;
}
##########################################################################
# Validate event.
# This validates all events pending to ACK for the same id_agent_module
@ -749,7 +734,7 @@ sub pandora_manage_main ($$$) {
$parameters{'id_modulo'} = 1;
pandora_create_agent_module ($conf, \%parameters, $dbh);
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
}
elsif ($param eq '--create_network_module') {
param_check($ltotal, 17, 13);
@ -817,7 +802,7 @@ sub pandora_manage_main ($$$) {
$parameters{'id_modulo'} = 1;
pandora_create_agent_module ($conf, \%parameters, $dbh);
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
}
elsif ($param eq '--create_snmp_module') {
param_check($ltotal, 25, 19);
@ -873,6 +858,8 @@ sub pandora_manage_main ($$$) {
$parameters{'max'} = $max unless !defined ($max);
$parameters{'post_process'} = $post_process unless !defined ($post_process);
$parameters{'module_interval'} = $interval unless !defined ($interval);
$parameters{'snmp_community'} = $community unless !defined ($community);
$parameters{'snmp_oid'} = $oid unless !defined ($oid);
if($version == 3) {
$parameters{'custom_string_1'} = $snmp3_priv_method;
@ -886,7 +873,7 @@ sub pandora_manage_main ($$$) {
# id_modulo = 2 for snmp modules
$parameters{'id_modulo'} = 2;
pandora_create_agent_module ($conf, \%parameters, $dbh);
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
}
elsif ($param eq '--create_plugin_module') {
param_check($ltotal, 20, 11);
@ -951,7 +938,7 @@ sub pandora_manage_main ($$$) {
$parameters{'id_modulo'} = 4;
pandora_create_agent_module ($conf, \%parameters, $dbh);
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
}
elsif ($param eq '--delete_module') {
param_check($ltotal, 2);
@ -1369,7 +1356,7 @@ sub pandora_manage_main ($$$) {
delete $module->{'configuration_data'};
# Create module
my $id_module = pandora_create_agent_module ($conf, $module, $dbh);
my $id_module = pandora_create_module_from_hash ($conf, $module, $dbh);
# Get policy alerts and create it on created modules
my $array_pointer_ale = enterprise_hook('get_policy_module_alerts',[$dbh, $policy_id, $module->{'id_policy_module'}]);