wip discovery f34

Former-commit-id: bb08450d3304ff140c4bae37e77b20a2329c600b
This commit is contained in:
fbsanchez 2019-04-04 12:28:17 +02:00
parent 9e83f139e1
commit fcafe76943
2 changed files with 56 additions and 42 deletions

View File

@ -420,7 +420,7 @@ sub PandoraFMS::Recon::Base::connect_agents($$$$$) {
##########################################################################
# Create agents from db_scan.
# Create agents from db_scan. Uses DataServer methods.
# data = [
# 'agent_data' => {},
# 'module_data' => []
@ -494,9 +494,10 @@ sub PandoraFMS::Recon::Base::create_agents($$) {
# Add modules.
if (ref($modules) eq "ARRAY") {
foreach my $module (@{$modules}) {
# Translate data structure to simulate XML parser return.
my %data_translated = map { $_ => [ $module->{$_} ] } keys %{$module};
# Translate fields.
# Process modules.
PandoraFMS::DataServer::process_module_data (
$pa_config, \%data_translated,
$server_id, $current_agent,

View File

@ -1450,6 +1450,8 @@ sub db_scan($) {
my $i = 0;
foreach my $target (@targets) {
my @data;
my @modules;
call('message', 'Checking target ' . $target, 10);
# Force target acquirement.
@ -1462,51 +1464,62 @@ sub db_scan($) {
$self->{'task_data'}
);
if (!defined($dbObj)) {
if (!$dbObj->is_connected()) {
call('message', 'Cannot connect to target ' . $target, 3);
$self->{'summary'}->{'not_alive'} += 1;
next;
push @modules, {
name => 'mysql_connection',
type => 'generic_proc',
data => 0,
description => 'MySQL availability'
};
} else {
$self->{'summary'}->{'discovered'} += 1;
$self->{'summary'}->{'alive'} += 1;
push @modules, {
name => 'mysql_connection',
type => 'generic_proc',
data => 1,
description => 'MySQL availability'
};
# Analyze.
$self->{'step'} = STEP_STATISTICS;
$self->{'c_network_name'} = $dbObj->get_host();
$self->call('update_progress', 10);
# Retrieve connection statistics.
# Retrieve uptime statistics
# Retrieve query stats
# Retrieve connections
# Retrieve innodb
# Retrieve cache
push @modules, $dbObj->get_statistics();
$self->call('update_progress', 50);
# Custom queries.
push @modules, $dbObj->execute_custom_queries();
$self->call('update_progress', 90);
}
$self->{'summary'}->{'discovered'} += 1;
$self->{'summary'}->{'alive'} += 1;
my @modules;
# Put engine agent at the beginning of the list.
unshift @data,{
'agent_data' => {
'agent_name' => $dbObj->get_agent_name(),
'os' => $type,
'os_version' => 'Discovery',
'interval' => $self->{'task_data'}->{'interval_sweep'},
'id_group' => $self->{'task_data'}->{'id_group'},
'address' => $dbObj->get_host(),
'description' => '',
},
'module_data' => \@modules,
};
# Analyze.
$self->{'step'} = STEP_STATISTICS;
$self->{'c_network_name'} = $dbObj->get_host();
$self->call('update_progress', 10);
# Retrieve connection statistics.
# Retrieve uptime statistics
# Retrieve query stats
# Retrieve connections
# Retrieve innodb
# Retrieve cache
push @modules, $dbObj->get_statistics();
$self->call('update_progress', 50);
# Custom queries.
push @modules, $dbObj->execute_custom_queries();
$self->call('update_progress', 90);
my $data = [
{
'agent_data' => {
'agent_name' => $dbObj->get_agent_name(),
'os' => $type,
'os_version' => 'Discovery',
'interval' => $self->{'task_data'}->{'interval_sweep'},
'id_group' => $self->{'task_data'}->{'id_group'},
'address' => $dbObj->get_host(),
'description' => '',
},
'module_data' => \@modules,
}
];
$self->call('create_agents', $data);
$self->call('create_agents', \@data);
# Destroy item.
undef($dbObj);