Fix backups total size computation when there's only one full

tags/zabbix-agent-addons-0.2.98-1
Daniel Berteaud 5 years ago
parent bcf313009b
commit 810f192184
  1. 8
      zabbix_scripts/check_backuppc_sudo

@ -59,13 +59,13 @@ if ( $host ) {
next if ( $backup->{type} !~ m/^full|incr$/ ); next if ( $backup->{type} !~ m/^full|incr$/ );
if ( $backup->{type} eq "full" ) { if ( $backup->{type} eq "full" ) {
$json->{full_size} = $backup->{size}; $json->{full_size} = $backup->{size};
$new_size_of_last_full = $backup->{sizeNew}; $new_size_of_last_full = $backup->{sizeNew} if $backup->{num} > 0;
} }
# Push all the sizes in our data set to compute avg sizes # Push all the sizes in our data set to compute avg sizes
# Exclude backup N°0 as it'll always have much more new data than normal backups # Exclude backup N°0 as it'll always have much more new data than normal backups
# Also exclude if size is not defined. This can happen in BackupPC v3 when # Also exclude if size is not defined. This can happen in BackupPC v3 when
# the BackupPC_link process is waiting for the nightly to finish # the BackupPC_link process is waiting for the nightly to finish
$sizes->add_data($backup->{sizeNew}) unless ( $backup->{num} == 0 || !$backup->{sizeNew} ); $sizes->add_data($backup->{sizeNew}) if ( $backup->{num} > 0 && $backup->{sizeNew} );
$json->{bkp}++; $json->{bkp}++;
} }
@ -132,9 +132,9 @@ if ( $host ) {
# Save the total size of the last full backup # Save the total size of the last full backup
if ( $backup->{type} eq 'full' ) { if ( $backup->{type} eq 'full' ) {
$host_full_size = $backup->{size}; $host_full_size = $backup->{size};
$host_new_size_of_last_full = $backup->{sizeNew}; $host_new_size_of_last_full = $backup->{sizeNew} if $backup->{num} > 0;
} }
$host_new_size += $backup->{sizeNew} unless ( $backup->{num} == 0 || !$backup->{sizeNew} ); $host_new_size += $backup->{sizeNew} if ( $backup->{num} > 0 && $backup->{sizeNew} );
$entity_total_new += $backup->{sizeNew}; $entity_total_new += $backup->{sizeNew};
$entity_total_comp += $backup->{sizeNewComp}; $entity_total_comp += $backup->{sizeNewComp};

Loading…
Cancel
Save