Discovery F3

Former-commit-id: 1990149c5f5795f825bc337fd7ae29d360348d45
This commit is contained in:
fbsanchez 2019-04-08 16:23:32 +02:00
parent 8e00fdebb4
commit 54bd3bf089
2 changed files with 31 additions and 4 deletions

View File

@ -494,7 +494,7 @@ sub PandoraFMS::Recon::Base::create_agents($$) {
# Update agent information # Update agent information
pandora_update_agent( pandora_update_agent(
$pa_config, time(), $agent_id, $pa_config, strftime("%Y-%m-%d %H:%M:%S", localtime()), $agent_id,
$agent->{'os_version'}, $agent->{'agent_version'}, $agent->{'os_version'}, $agent->{'agent_version'},
$agent->{'interval'}, $dbh, undef, $parent_id $agent->{'interval'}, $dbh, undef, $parent_id
); );

View File

@ -1448,16 +1448,28 @@ sub db_scan($) {
my @targets = split /,/, $self->{'task_data'}->{'subnet'}; my @targets = split /,/, $self->{'task_data'}->{'subnet'};
my $global_step = 100 / (scalar @targets);
my $global_percent = 0;
my $i = 0; my $i = 0;
foreach my $target (@targets) { foreach my $target (@targets) {
my @data; my @data;
my @modules; my @modules;
$self->{'step'} = STEP_DATABASE_SCAN;
$self->{'c_network_name'} = $target;
$self->{'c_network_percent'} = 0;
# Send message
call('message', 'Checking target ' . $target, 10); call('message', 'Checking target ' . $target, 10);
# Force target acquirement. # Force target acquirement.
$self->{'task_data'}->{'dbhost'} = $target; $self->{'task_data'}->{'dbhost'} = $target;
$self->{'task_data'}->{'target_index'} = $i++; $self->{'task_data'}->{'target_index'} = $i++;
# Update progress
$self->{'c_network_percent'} = 10;
$self->call('update_progress', $global_percent + (10 / (scalar @targets)));
# Connect to target. # Connect to target.
my $dbObj = PandoraFMS::Recon::Util::enterprise_new( my $dbObj = PandoraFMS::Recon::Util::enterprise_new(
'PandoraFMS::Recon::Applications::'.$type, 'PandoraFMS::Recon::Applications::'.$type,
@ -1466,6 +1478,10 @@ sub db_scan($) {
if (!$dbObj->is_connected()) { if (!$dbObj->is_connected()) {
call('message', 'Cannot connect to target ' . $target, 3); call('message', 'Cannot connect to target ' . $target, 3);
$global_percent += $global_step;
$self->{'c_network_percent'} = 90;
# Update progress
$self->call('update_progress', $global_percent + (90 / (scalar @targets)));
$self->{'summary'}->{'not_alive'} += 1; $self->{'summary'}->{'not_alive'} += 1;
push @modules, { push @modules, {
name => $type . ' connection', name => $type . ' connection',
@ -1489,8 +1505,9 @@ sub db_scan($) {
# Analyze. # Analyze.
$self->{'step'} = STEP_STATISTICS; $self->{'step'} = STEP_STATISTICS;
$self->{'c_network_percent'} = 30;
$self->call('update_progress', $global_percent + (30 / (scalar @targets)));
$self->{'c_network_name'} = $dbObj->get_host(); $self->{'c_network_name'} = $dbObj->get_host();
$self->call('update_progress', 10);
# Retrieve connection statistics. # Retrieve connection statistics.
# Retrieve uptime statistics # Retrieve uptime statistics
@ -1498,15 +1515,21 @@ sub db_scan($) {
# Retrieve connections # Retrieve connections
# Retrieve innodb # Retrieve innodb
# Retrieve cache # Retrieve cache
$self->{'c_network_percent'} = 50;
$self->call('update_progress', $global_percent + (50 / (scalar @targets)));
push @modules, $dbObj->get_statistics(); push @modules, $dbObj->get_statistics();
$self->call('update_progress', 50);
# Custom queries. # Custom queries.
$self->{'step'} = STEP_CUSTOM_QUERIES;
$self->{'c_network_percent'} = 80;
$self->call('update_progress', $global_percent + (80 / (scalar @targets)));
push @modules, $dbObj->execute_custom_queries(); push @modules, $dbObj->execute_custom_queries();
$self->call('update_progress', 90);
if (defined($dbObjCfg->{'scan_databases'}) if (defined($dbObjCfg->{'scan_databases'})
&& $dbObjCfg->{'scan_databases'} == 1) { && $dbObjCfg->{'scan_databases'} == 1) {
# Skip database scan in Oracle tasks
next if $self->{'type'} == DISCOVERY_APP_ORACLE;
my $__data = $dbObj->scan_databases(); my $__data = $dbObj->scan_databases();
if (ref($__data) eq "ARRAY") { if (ref($__data) eq "ARRAY") {
@ -1545,6 +1568,10 @@ sub db_scan($) {
# Destroy item. # Destroy item.
undef($dbObj); undef($dbObj);
$global_percent += $global_step;
$self->{'c_network_percent'} = 100;
$self->call('update_progress', $global_percent);
} }
# Update progress. # Update progress.