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:
parent
2f280a1d0d
commit
8d281138ef
|
@ -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>
|
2011-08-10 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* pandora_server.spec, pandora_server.redhat.spec: Added perl-Socket6
|
* pandora_server.spec, pandora_server.redhat.spec: Added perl-Socket6
|
||||||
|
|
|
@ -446,17 +446,26 @@ sub process_module_data ($$$$$$$$$) {
|
||||||
|
|
||||||
# Get module parameters, matching column names in tagente_modulo
|
# Get module parameters, matching column names in tagente_modulo
|
||||||
my $module_conf;
|
my $module_conf;
|
||||||
$module_conf->{'max'} = get_tag_value ($data, 'max', undef);
|
|
||||||
$module_conf->{'min'} = get_tag_value ($data, 'min', undef);
|
# Supported tags
|
||||||
$module_conf->{'descripcion'} = get_tag_value ($data, 'description', undef);
|
my $tags = {'name' => 0, 'data' => 0, 'type' => 0, 'description' => 0, 'max' => 0,
|
||||||
$module_conf->{'post_process'} = get_tag_value ($data, 'post_process', undef);
|
'min' => 0, 'descripcion' => 0, 'post_process' => 0, 'module_interval' => 0, 'min_critical' => 0,
|
||||||
$module_conf->{'module_interval'} = get_tag_value ($data, 'module_interval', undef);
|
'max_critical' => 0, 'min_warning' => 0, 'max_warning' => 0, 'disabled' => 0, 'min_ff_event' => 0};
|
||||||
$module_conf->{'min_critical'} = get_tag_value ($data, 'min_critical', undef);
|
|
||||||
$module_conf->{'max_critical'} = get_tag_value ($data, 'max_critical', undef);
|
# Other tags will be saved here
|
||||||
$module_conf->{'min_warning'} = get_tag_value ($data, 'min_warning', undef);
|
$module_conf->{'extended_info'} = '';
|
||||||
$module_conf->{'max_warning'} = get_tag_value ($data, 'max_warning', undef);
|
|
||||||
$module_conf->{'disabled'} = get_tag_value ($data, 'disabled', undef);
|
# Read tags
|
||||||
$module_conf->{'min_ff_event'} = get_tag_value ($data, 'min_ff_event', undef);
|
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
|
# Calculate the module interval in seconds
|
||||||
$module_conf->{'module_interval'} *= $interval if (defined ($module_conf->{'module_interval'}));
|
$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->{'max_warning'} = 0 unless defined ($module_conf->{'max_warning'});
|
||||||
$module_conf->{'disabled'} = 0 unless defined ($module_conf->{'disabled'});
|
$module_conf->{'disabled'} = 0 unless defined ($module_conf->{'disabled'});
|
||||||
$module_conf->{'min_ff_event'} = 0 unless defined ($module_conf->{'min_ff_event'});
|
$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
|
# Create the module
|
||||||
pandora_create_module ($pa_config, $agent->{'id_agente'}, $module_id, $module_name,
|
pandora_create_module ($pa_config, $agent->{'id_agente'}, $module_id, $module_name,
|
||||||
|
@ -517,6 +527,7 @@ sub process_module_data ($$$$$$$$$) {
|
||||||
|
|
||||||
# Control NULL columns
|
# Control NULL columns
|
||||||
$module->{'descripcion'} = '' unless defined ($module->{'descripcion'});
|
$module->{'descripcion'} = '' unless defined ($module->{'descripcion'});
|
||||||
|
$module->{'extended_info'} = '' unless defined ($module->{'extended_info'});
|
||||||
|
|
||||||
# Set default values
|
# Set default values
|
||||||
$module_conf->{'max'} = $module->{'max'} unless defined ($module_conf->{'max'});
|
$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->{'max_warning'} = $module->{'max_warning'} unless defined ($module_conf->{'max_warning'});
|
||||||
$module_conf->{'disabled'} = $module->{'disabled'} unless defined ($module_conf->{'disabled'});
|
$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->{'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
|
# The group name has to be translated to a group ID
|
||||||
my $conf_group_id = -1;
|
my $conf_group_id = -1;
|
||||||
|
@ -620,12 +632,12 @@ sub update_module_configuration ($$$$) {
|
||||||
my ($pa_config, $dbh, $module, $module_conf) = @_;
|
my ($pa_config, $dbh, $module, $module_conf) = @_;
|
||||||
|
|
||||||
# Update if at least one of the configuration tokens has changed
|
# 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}) {
|
if ($module->{$conf_token} ne $module_conf->{$conf_token}) {
|
||||||
logger ($pa_config, "Updating configuration for module '" . $module->{'nombre'} . "'.", 10);
|
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'},
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue