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:
parent
9ce6297c53
commit
40f27f4576
|
@ -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>
|
2010-10-18 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/DB.pm
|
* lib/PandoraFMS/DB.pm
|
||||||
|
|
|
@ -133,6 +133,7 @@ our @EXPORT = qw(
|
||||||
pandora_create_agent
|
pandora_create_agent
|
||||||
pandora_create_incident
|
pandora_create_incident
|
||||||
pandora_create_module
|
pandora_create_module
|
||||||
|
pandora_create_module_from_hash
|
||||||
pandora_evaluate_alert
|
pandora_evaluate_alert
|
||||||
pandora_evaluate_compound_alert
|
pandora_evaluate_compound_alert
|
||||||
pandora_evaluate_snmp_alerts
|
pandora_evaluate_snmp_alerts
|
||||||
|
@ -1094,6 +1095,21 @@ sub pandora_create_module ($$$$$$$$$$) {
|
||||||
return $module_id;
|
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>]) >>
|
=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>]) >>
|
||||||
|
|
||||||
|
|
|
@ -395,21 +395,6 @@ sub pandora_delete_module_data ($$) {
|
||||||
|
|
||||||
return 1;
|
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.
|
# Validate event.
|
||||||
|
@ -749,7 +734,7 @@ sub pandora_manage_main ($$$) {
|
||||||
|
|
||||||
$parameters{'id_modulo'} = 1;
|
$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') {
|
elsif ($param eq '--create_network_module') {
|
||||||
param_check($ltotal, 17, 13);
|
param_check($ltotal, 17, 13);
|
||||||
|
@ -817,7 +802,7 @@ sub pandora_manage_main ($$$) {
|
||||||
|
|
||||||
$parameters{'id_modulo'} = 1;
|
$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') {
|
elsif ($param eq '--create_snmp_module') {
|
||||||
param_check($ltotal, 25, 19);
|
param_check($ltotal, 25, 19);
|
||||||
|
@ -872,7 +857,9 @@ sub pandora_manage_main ($$$) {
|
||||||
$parameters{'min'} = $min unless !defined ($min);
|
$parameters{'min'} = $min unless !defined ($min);
|
||||||
$parameters{'max'} = $max unless !defined ($max);
|
$parameters{'max'} = $max unless !defined ($max);
|
||||||
$parameters{'post_process'} = $post_process unless !defined ($post_process);
|
$parameters{'post_process'} = $post_process unless !defined ($post_process);
|
||||||
$parameters{'module_interval'} = $interval unless !defined ($interval);
|
$parameters{'module_interval'} = $interval unless !defined ($interval);
|
||||||
|
$parameters{'snmp_community'} = $community unless !defined ($community);
|
||||||
|
$parameters{'snmp_oid'} = $oid unless !defined ($oid);
|
||||||
|
|
||||||
if($version == 3) {
|
if($version == 3) {
|
||||||
$parameters{'custom_string_1'} = $snmp3_priv_method;
|
$parameters{'custom_string_1'} = $snmp3_priv_method;
|
||||||
|
@ -886,7 +873,7 @@ sub pandora_manage_main ($$$) {
|
||||||
# id_modulo = 2 for snmp modules
|
# id_modulo = 2 for snmp modules
|
||||||
$parameters{'id_modulo'} = 2;
|
$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') {
|
elsif ($param eq '--create_plugin_module') {
|
||||||
param_check($ltotal, 20, 11);
|
param_check($ltotal, 20, 11);
|
||||||
|
@ -951,7 +938,7 @@ sub pandora_manage_main ($$$) {
|
||||||
|
|
||||||
$parameters{'id_modulo'} = 4;
|
$parameters{'id_modulo'} = 4;
|
||||||
|
|
||||||
pandora_create_agent_module ($conf, \%parameters, $dbh);
|
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
|
||||||
}
|
}
|
||||||
elsif ($param eq '--delete_module') {
|
elsif ($param eq '--delete_module') {
|
||||||
param_check($ltotal, 2);
|
param_check($ltotal, 2);
|
||||||
|
@ -1369,7 +1356,7 @@ sub pandora_manage_main ($$$) {
|
||||||
delete $module->{'configuration_data'};
|
delete $module->{'configuration_data'};
|
||||||
|
|
||||||
# Create module
|
# 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
|
# 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'}]);
|
my $array_pointer_ale = enterprise_hook('get_policy_module_alerts',[$dbh, $policy_id, $module->{'id_policy_module'}]);
|
||||||
|
|
Loading…
Reference in New Issue