Remove entity

master
Heuzef 5 years ago
parent d44c565dd1
commit 3b01d346c6
  1. 48
      backuppc_check.pl

@ -80,53 +80,7 @@ if ( $host ) {
} }
} }
my $total_new = 0; else {
my $total_comp = 0;
foreach my $host ( keys %{ $bpc->HostInfoRead } ) {
next unless $host =~ m/^(vm_)?\Q$entity\E_.*/;
my $full_size;
$json->{hosts}++;
my $hostConf = $bpc->ConfigDataRead($host);
my $conf = { %$mainConf, %$hostConf };
my $freq = ( $conf->{FullPeriod} > $conf->{IncrPeriod} ) ? $conf->{IncrPeriod} : $conf->{FullPeriod};
my $bkp_num = 0;
my $new_size_of_last_full = 0;
foreach my $backup ( $bpc->BackupInfoRead( $host ) ) {
next if ( $backup->{type} !~ m/^full|incr$/ );
# Save the total size of the last full backup
if ( $backup->{type} eq 'full' ) {
$full_size = $backup->{size};
$new_size_of_last_full = $backup->{sizeNew};
}
$json->{size} += $backup->{sizeNew};
$total_new += $backup->{sizeNew};
$total_comp += $backup->{sizeNewComp};
$bkp_num++;
$json->{bkp}++;
}
# Compute the average cost as the number of hours per day spent
# to backup this host
$json->{perf} += ( $bkp_num > 0 ) ? $duration / ( 3600 * $bkp_num * $freq ) : 0;
# $json->{size} represent the total size used by this host.
# But we want to substract the new size of the last full, as for this one we
# do not count sizeNew but size. As we've already added sizeNew we need to substract it 2 times
$json->{size} += $full_size - 2 * $new_size_of_last_full;
}
$json->{ratio} = ( $total_new > 0 ) ? 100 - ( $total_comp * 100 / $total_new ) : 0;
# Round some values
foreach my $key ( qw(ratio perf) ) {
$json->{$key} = sprintf( "%.2f", $json->{$key} );
}
} else {
print<<"EOF"; print<<"EOF";
Usage: $0 --host=<host> Usage: $0 --host=<host>

Loading…
Cancel
Save