From 7e853f62f18d505e67ae814e337e5ead0728ef6d Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 27 Apr 2011 17:44:14 +0000 Subject: [PATCH] 2011-04-27 Ramon Novoa * conf/pandora_server.conf: Added the dbengine configuration token. * lib/PandoraFMS/DataServer.pm: Read aditional module parameters from the XML data file. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4283 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 ++++ pandora_server/conf/pandora_server.conf | 3 ++ pandora_server/lib/PandoraFMS/DataServer.pm | 43 ++++++++++++++++----- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 8b702be097..f35ef78083 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2011-04-27 Ramon Novoa + + * conf/pandora_server.conf: Added the dbengine configuration token. + + * lib/PandoraFMS/DataServer.pm: Read aditional module parameters from + the XML data file. + 2011-04-20 Ramon Novoa * lib/PandoraFMS/Core.pm, diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf index d460fb85f0..da9842a66f 100755 --- a/pandora_server/conf/pandora_server.conf +++ b/pandora_server/conf/pandora_server.conf @@ -38,6 +38,9 @@ errorlog_file /var/log/pandora/pandora_server.error # daemon 1 +# dbengine: mysql, postgresql or oracle (mysql by default) +#dbengine mysql + # Database credentials. A VERY important configuration. # This must be the same credentials used by your Pandora FMS Console # but could be different if your console is not running in the same diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ab2f2fa2ca..d64a65dd6d 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -454,6 +454,12 @@ sub process_module_data ($$$$$$$$$) { $module_conf->{'descripcion'} = get_tag_value ($data, 'description', undef); $module_conf->{'post_process'} = get_tag_value ($data, 'post_process', undef); $module_conf->{'module_interval'} = get_tag_value ($data, 'module_interval', undef); + $module_conf->{'min_critical'} = get_tag_value ($data, 'min_critical', undef); + $module_conf->{'max_critical'} = get_tag_value ($data, 'max_critical', undef); + $module_conf->{'min_warning'} = get_tag_value ($data, 'min_warning', undef); + $module_conf->{'max_warning'} = get_tag_value ($data, 'max_warning', undef); + $module_conf->{'disabled'} = get_tag_value ($data, 'disabled', undef); + $module_conf->{'min_ff_event'} = get_tag_value ($data, 'min_ff_event', undef); # Calculate the module interval in seconds $module_conf->{'module_interval'} *= $interval if (defined ($module_conf->{'module_interval'})); @@ -493,6 +499,12 @@ sub process_module_data ($$$$$$$$$) { $module_conf->{'descripcion'} = '' unless defined ($module_conf->{'descripcion'}); $module_conf->{'post_process'} = 0 unless defined ($module_conf->{'post_process'}); $module_conf->{'module_interval'} = $interval unless defined ($module_conf->{'module_interval'}); # 1 * $interval + $module_conf->{'min_critical'} = 0 unless defined ($module_conf->{'min_critical'}); + $module_conf->{'max_critical'} = 0 unless defined ($module_conf->{'max_critical'}); + $module_conf->{'min_warning'} = 0 unless defined ($module_conf->{'min_warning'}); + $module_conf->{'max_warning'} = 0 unless defined ($module_conf->{'max_warning'}); + $module_conf->{'disabled'} = 0 unless defined ($module_conf->{'disabled'}); + $module_conf->{'min_ff_event'} = 0 unless defined ($module_conf->{'min_ff_event'}); # Create the module pandora_create_module ($pa_config, $agent->{'id_agente'}, $module_id, $module_name, @@ -515,11 +527,24 @@ sub process_module_data ($$$$$$$$$) { $module_conf->{'descripcion'} = $module->{'descripcion'} unless defined ($module_conf->{'descripcion'}); $module_conf->{'post_process'} = $module->{'post_process'} unless defined ($module_conf->{'post_process'}); $module_conf->{'module_interval'} = $module->{'module_interval'} unless defined ($module_conf->{'module_interval'}); + $module_conf->{'min_critical'} = $module->{'min_critical'} unless defined ($module_conf->{'min_critical'}); + $module_conf->{'max_critical'} = $module->{'max_critical'} unless defined ($module_conf->{'max_critical'}); + $module_conf->{'min_warning'} = $module->{'min_warning'} unless defined ($module_conf->{'min_warning'}); + $module_conf->{'max_warning'} = $module->{'max_warning'} unless defined ($module_conf->{'max_warning'}); + $module_conf->{'disabled'} = $module->{'disabled'} unless defined ($module_conf->{'disabled'}); + $module_conf->{'min_ff_event'} = $module->{'min_ff_event'} unless defined ($module_conf->{'min_ff_event'}); - # Update module configuration if in learning mode - if ($agent->{'modo'} eq '1') { - update_module_configuration ($pa_config, $dbh, $module, $module_conf); + # The group name has to be translated to a group ID + my $conf_group_id = -1; + if (defined $module_conf->{'group'}) { + my $conf_group_id = get_group_id ($dbh, $module_conf->{'group'}); } + $module_conf->{'id_module_group'} = ($conf_group_id == -1) ? $module->{'id_module_group'} : $conf_group_id; + } + + # Update module configuration if in learning mode + if ($agent->{'modo'} eq '1') { + update_module_configuration ($pa_config, $dbh, $module, $module_conf); } $ModuleSem->up (); @@ -598,14 +623,14 @@ sub update_module_configuration ($$$$) { my ($pa_config, $dbh, $module, $module_conf) = @_; # Update if at least one of the configuration tokens has changed - if ($module->{'min'} != $module_conf->{'min'} || $module->{'max'} != $module_conf->{'max'} || - $module->{'descripcion'} ne $module_conf->{'descripcion'} || $module->{'post_process'} != $module_conf->{'post_process'} || - $module->{'module_interval'} != $module_conf->{'module_interval'}) { - logger($pa_config, "Updating configuration for module '" . $module->{'nombre'} . "'.", 10); - db_do ($dbh, 'UPDATE tagente_modulo SET min = ?, max = ?, descripcion = ?, post_process = ?, module_interval = ? + foreach my $conf_token ('min', 'max', 'descripcion', 'post_process', 'module_interval', 'min_critical', 'max_critical', 'min_warning', 'max_warning', 'disabled', 'min_ff_event') { + if ($module->{$conf_token} ne $module_conf->{$conf_token}) { + logger ($pa_config, "Updating configuration for module '" . $module->{'nombre'} . "'.", 10); + db_do ($dbh, 'UPDATE tagente_modulo SET min = ?, max = ?, descripcion = ?, post_process = ?, module_interval = ?, min_critical = ?, max_critical = ?, min_warning = ?, max_warning = ?, disabled = ?, min_ff_event = ? WHERE id_agente_modulo = ?', $module_conf->{'min'}, $module_conf->{'max'}, $module_conf->{'descripcion'} eq '' ? $module->{'descripcion'} : $module_conf->{'descripcion'}, - $module_conf->{'post_process'}, $module_conf->{'module_interval'}, $module->{'id_agente_modulo'}); + $module_conf->{'post_process'}, $module_conf->{'module_interval'}, $module_conf->{'min_critical'}, $module_conf->{'max_critical'}, $module_conf->{'min_warning'}, $module_conf->{'max_warning'}, $module_conf->{'disabled'}, $module_conf->{'min_ff_event'}, $module->{'id_agente_modulo'}); return; + } } }