Fix counting entity size

tags/zabbix-agent-addons-0.2.70-1
Daniel Berteaud 6 years ago
parent ca9bab4d12
commit c3f9b4d919
  1. 9
      zabbix_scripts/check_backuppc_sudo

@ -85,16 +85,17 @@ if ( $host ) {
my $freq = ( $conf->{FullPeriod} > $conf->{IncrPeriod} ) ? $conf->{IncrPeriod} : $conf->{FullPeriod}; my $freq = ( $conf->{FullPeriod} > $conf->{IncrPeriod} ) ? $conf->{IncrPeriod} : $conf->{FullPeriod};
my $duration = 0; my $duration = 0;
my $bkp_num = 0; my $bkp_num = 0;
my $new_size_of_last_full = 0
foreach my $backup ( $bpc->BackupInfoRead( $host ) ) { foreach my $backup ( $bpc->BackupInfoRead( $host ) ) {
next if ( $backup->{type} !~ m/^full|incr$/ ); next if ( $backup->{type} !~ m/^full|incr$/ );
# For the last full backup of this host, we do not count # For the last full backup of this host, we do not count
# the new file size, but the total size # the new file size, but the total size
# We substract 2 times the new file size because we want the total size
if ( $backup->{type} eq 'full' ) { if ( $backup->{type} eq 'full' ) {
$full_size = $backup->{size} - 2 * $backup->{sizeNew}; $full_size = $backup->{size};
$new_size_of_last_full = $backup->{sizeNew};
} }
$size += $backup->{sizeNew}; $json->{size} += $backup->{sizeNew};
$total_new += $backup->{sizeNew}; $total_new += $backup->{sizeNew};
$total_comp += $backup->{sizeNewComp}; $total_comp += $backup->{sizeNewComp};
$duration += $backup->{endTime} - $backup->{startTime}; $duration += $backup->{endTime} - $backup->{startTime};
@ -104,7 +105,7 @@ if ( $host ) {
# Compute the average cost as the number of hours per day spent # Compute the average cost as the number of hours per day spent
# to backup this host # to backup this host
$json->{perf} += ( $bkp_num > 0 ) ? $duration / ( 3600 * $bkp_num * $freq ) : 0; $json->{perf} += ( $bkp_num > 0 ) ? $duration / ( 3600 * $bkp_num * $freq ) : 0;
$json->{size} += $size + $full_size; $json->{size} += $full_size - 2 * $new_size_of_last_full;
} }
$json->{ratio} = ( $total_new > 0 ) ? 100 - ( $total_comp * 100 / $total_new ) : 0; $json->{ratio} = ( $total_new > 0 ) ? 100 - ( $total_comp * 100 / $total_new ) : 0;

Loading…
Cancel
Save