2011-08-10 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/DataServer.pm: Added support for custom module tags
	  (stored in column extended_info).



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4712 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2011-08-10 16:58:26 +00:00
parent 2f280a1d0d
commit 8d281138ef
2 changed files with 31 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2011-08-10 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DataServer.pm: Added support for custom module tags
(stored in column extended_info).
2011-08-10 Sancho Lerena <slerena@artica.es>
* pandora_server.spec, pandora_server.redhat.spec: Added perl-Socket6

View File

@ -446,17 +446,26 @@ sub process_module_data ($$$$$$$$$) {
# Get module parameters, matching column names in tagente_modulo
my $module_conf;
$module_conf->{'max'} = get_tag_value ($data, 'max', undef);
$module_conf->{'min'} = get_tag_value ($data, 'min', undef);
$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);
# Supported tags
my $tags = {'name' => 0, 'data' => 0, 'type' => 0, 'description' => 0, 'max' => 0,
'min' => 0, 'descripcion' => 0, 'post_process' => 0, 'module_interval' => 0, 'min_critical' => 0,
'max_critical' => 0, 'min_warning' => 0, 'max_warning' => 0, 'disabled' => 0, 'min_ff_event' => 0};
# Other tags will be saved here
$module_conf->{'extended_info'} = '';
# Read tags
while (my ($tag, $value) = each (%{$data})) {
if (defined ($tags->{$tag})) {
$module_conf->{$tag} = $value->[0];
} else {
$module_conf->{'extended_info'} .= "$tag: " . $value->[0] . '<br/>';
}
}
# Description XML tag and column name don't match
$module_conf->{'descripcion'} = $module_conf->{'description'};
# Calculate the module interval in seconds
$module_conf->{'module_interval'} *= $interval if (defined ($module_conf->{'module_interval'}));
@ -502,6 +511,7 @@ sub process_module_data ($$$$$$$$$) {
$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'});
$module_conf->{'extended_info'} = '' unless defined ($module_conf->{'extended_info'});
# Create the module
pandora_create_module ($pa_config, $agent->{'id_agente'}, $module_id, $module_name,
@ -517,6 +527,7 @@ sub process_module_data ($$$$$$$$$) {
# Control NULL columns
$module->{'descripcion'} = '' unless defined ($module->{'descripcion'});
$module->{'extended_info'} = '' unless defined ($module->{'extended_info'});
# Set default values
$module_conf->{'max'} = $module->{'max'} unless defined ($module_conf->{'max'});
@ -530,6 +541,7 @@ sub process_module_data ($$$$$$$$$) {
$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'});
$module_conf->{'extended_info'} = $module->{'extended_info'} unless defined ($module_conf->{'extended_info'});
# The group name has to be translated to a group ID
my $conf_group_id = -1;
@ -620,12 +632,12 @@ sub update_module_configuration ($$$$) {
my ($pa_config, $dbh, $module, $module_conf) = @_;
# Update if at least one of the configuration tokens has changed
foreach my $conf_token ('min', 'max', 'descripcion', 'post_process', 'module_interval', 'min_critical', 'max_critical', 'min_warning', 'max_warning', 'disabled', 'min_ff_event') {
foreach my $conf_token ('min', 'max', 'descripcion', 'post_process', 'module_interval', 'min_critical', 'max_critical', 'min_warning', 'max_warning', 'disabled', 'min_ff_event', 'extended_info') {
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 = ?
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 = ?, extended_info = ?
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_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'});
$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_conf->{'extended_info'}, $module->{'id_agente_modulo'});
return;
}
}