Add support to link modules via XML data files.
This commit is contained in:
parent
e2518338f6
commit
01217fe3b2
|
@ -88,6 +88,7 @@ ALTER TABLE tusuario ADD CONSTRAINT fk_id_filter FOREIGN KEY (id_filter) REFEREN
|
|||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE tagente_modulo ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
|
||||
ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
|
||||
ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tagente_datos`
|
||||
|
|
|
@ -76,6 +76,7 @@ ALTER TABLE tagente_modulo ADD COLUMN dynamic_max bigint(20) default '0';
|
|||
ALTER TABLE tagente_modulo ADD COLUMN dynamic_min bigint(20) default '0';
|
||||
ALTER TABLE tagente_modulo ADD COLUMN dynamic_next bigint(20) NOT NULL default '0';
|
||||
ALTER TABLE tagente_modulo ADD COLUMN dynamic_two_tailed tinyint(1) unsigned default '0';
|
||||
ALTER TABLE tagente_modulo ADD COLUMN parent_module_id NUMBER(10, 0);
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tnetwork_component`
|
||||
|
|
|
@ -290,6 +290,7 @@ CREATE TABLE tagente_modulo (
|
|||
prediction_sample_window INTEGER default 0,
|
||||
prediction_samples INTEGER default 0,
|
||||
prediction_threshold INTEGER default 0,
|
||||
parent_module_id NUMBER(10, 0),
|
||||
CONSTRAINT t_agente_modulo_wizard_cons CHECK (wizard_level IN ('basic','advanced','nowizard'))
|
||||
);
|
||||
CREATE INDEX tagente_modulo_id_agente_idx ON tagente_modulo(id_agente);
|
||||
|
|
|
@ -252,6 +252,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
|
|||
`prediction_sample_window` int(10) default 0,
|
||||
`prediction_samples` int(4) default 0,
|
||||
`prediction_threshold` int(4) default 0,
|
||||
`parent_module_id` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_agente_modulo`),
|
||||
KEY `main_idx` (`id_agente_modulo`,`id_agente`),
|
||||
KEY `tam_agente` (`id_agente`),
|
||||
|
|
|
@ -563,6 +563,27 @@ sub process_xml_data ($$$$$) {
|
|||
}
|
||||
}
|
||||
|
||||
# Link modules
|
||||
foreach my $module_data (@{$data->{'module'}}) {
|
||||
|
||||
my $module_name = get_tag_value ($module_data, 'name', '');
|
||||
$module_name =~ s/\r//g;
|
||||
$module_name =~ s/\n//g;
|
||||
|
||||
# Unnamed module
|
||||
next if ($module_name eq '');
|
||||
|
||||
# No parent module defined
|
||||
my $parent_module_name = get_tag_value ($module_data, 'module_parent', undef);
|
||||
if (! defined ($parent_module_name)) {
|
||||
use Data::Dumper;
|
||||
print Dumper($module_data);
|
||||
next;
|
||||
}
|
||||
|
||||
link_modules($pa_config, $dbh, $agent_id, $module_name, $parent_module_name);
|
||||
}
|
||||
|
||||
# Process inventory modules
|
||||
enterprise_hook('process_inventory_data', [$pa_config, $data, $server_id, $agent_name,
|
||||
$interval, $timestamp, $dbh]);
|
||||
|
@ -884,5 +905,25 @@ sub process_xml_server ($$$$) {
|
|||
pandora_update_server ($pa_config, $dbh, $data->{'server_name'}, 0, 1, $server_type, $threads, $modules, $version, $data->{'keepalive'});
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Link two modules
|
||||
###############################################################################
|
||||
sub link_modules {
|
||||
my ($pa_config, $dbh, $agent_id, $child_name, $parent_name) = @_;
|
||||
|
||||
# Get the child module ID.
|
||||
my $child_id = get_agent_module_id ($dbh, $child_name, $agent_id);
|
||||
return unless ($child_id != -1);
|
||||
|
||||
# Get the parent module ID.
|
||||
my $parent_id = get_agent_module_id ($dbh, $parent_name, $agent_id);
|
||||
return unless ($parent_id != -1);
|
||||
|
||||
# Link them.
|
||||
logger($pa_config, "Linking module $child_name to module $parent_name for agent ID $agent_id", 10);
|
||||
db_do($dbh, "UPDATE tagente_modulo SET parent_module_id = ? WHERE id_agente_modulo = ?", $parent_id, $child_id);
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
|
Loading…
Reference in New Issue