From ca2f76e842a81af0d2ad01d9ef45f95db3795f32 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 13 Dec 2019 23:45:37 +0100 Subject: [PATCH] Fix when a host has a single backup with 0 new file size Which can heppen if you deleted backups manually --- zabbix_scripts/check_backuppc_sudo | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zabbix_scripts/check_backuppc_sudo b/zabbix_scripts/check_backuppc_sudo index 223483b..f583704 100644 --- a/zabbix_scripts/check_backuppc_sudo +++ b/zabbix_scripts/check_backuppc_sudo @@ -89,7 +89,8 @@ if ( $host ) { # 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; + # Except when we ave a single backup, in which case we read stats of this only backup + $i = ( $backup->{sizeNew} || scalar @bpc_info == 1 ) ? -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} ) )