Wait for BackupPC_link to run before we take new sizes in our stat

So it won't send wrong comp_ratio of size values
tags/zabbix-agent-addons-0.2.95-1
Daniel Berteaud 5 years ago
parent 847efa1243
commit ba0a868fd4
  1. 16
      zabbix_scripts/check_backuppc_sudo

@ -64,7 +64,7 @@ if ( $host ) {
# 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
# Also exclude if size is not defined. This can happen in BackupPC v3 when
# the 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} );
$json->{bkp}++;
}
@ -73,13 +73,8 @@ if ( $host ) {
my $i = ( $bpc_info[-1]->{type} =~ m/^full|incr$/ ) ? -1 : -2;
$json->{errors} = $bpc_info[$i]->{xferErrs};
$json->{new_size} = $bpc_info[$i]->{sizeNew};
$json->{duration} = $bpc_info[$i]->{endTime} - $bpc_info[$i]->{startTime};
$json->{type} = $bpc_info[$i]->{type};
$json->{comp_ratio} = ( $bpc_info[$i]->{sizeNew} > 0 ) ?
sprintf( "%.2f", 100 - ( $bpc_info[$i]->{sizeNewComp} * 100 / $bpc_info[$i]->{sizeNew} ) )
:
0;
$json->{new_size_avg} = int $sizes->mean;
$json->{new_size_median} = int $sizes->median;
@ -90,6 +85,15 @@ if ( $host ) {
$json->{total_size} = $sizes->sum + $json->{full_size} - 2 * $new_size_of_last_full;
$json->{age} = time - $bpc_info[$i]->{startTime};
# For newSize, we need to wait for BackupPC_link to run, which can be delayed
# if a nightly process is running. In this case, use the stats from the previous backup
$i = ( $backup->{sizeNew} ) ? -1 : -2;
$json->{new_size} = $bpc_info[$i]->{sizeNew};
$json->{comp_ratio} = ( $bpc_info[$i]->{sizeNew} > 0 ) ?
sprintf( "%.2f", 100 - ( $bpc_info[$i]->{sizeNewComp} * 100 / $bpc_info[$i]->{sizeNew} ) )
:
0;
$json->{max_errors} = $conf->{MaxXferError} || 0;
}
} elsif ( $entity ) {

Loading…
Cancel
Save