From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 10419BA797 for ; Thu, 14 Dec 2023 15:12:32 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E606F17C20 for ; Thu, 14 Dec 2023 15:12:01 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 14 Dec 2023 15:12:01 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 08A0A4761A for ; Thu, 14 Dec 2023 15:12:01 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Thu, 14 Dec 2023 15:11:53 +0100 Message-Id: <20231214141154.279100-1-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH manager 1/2] fix #5067: vzdump: include total backup size in notification X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Dec 2023 14:12:32 -0000 The old backup job notification mails from before the notification system overhaul included the total time as well as the total size. The total size was missing from the new, template-based backup report, thus we add it back in this commit. Signed-off-by: Lukas Wagner --- PVE/VZDump.pm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 4185ed62..91f60418 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -414,15 +414,17 @@ sub sanitize_task_list { } } -sub count_failed_tasks { +my sub aggregate_task_statistics { my ($tasklist) = @_; my $error_count = 0; + my $total_size = 0; for my $task (@$tasklist) { $error_count++ if $task->{state} ne 'ok'; + $total_size += $task->{size} if $task->{state} eq 'ok'; } - return $error_count; + return $error_count, $total_size; } sub get_hostname { @@ -437,9 +439,10 @@ my $body_template = <{"notification-mode"} // 'auto'; sanitize_task_list($tasklist); - my $error_count = count_failed_tasks($tasklist); + my ($error_count, $total_size) = aggregate_task_statistics($tasklist); my $failed = ($error_count || $err); @@ -486,12 +489,13 @@ sub send_notification { my $hostname = get_hostname(); my $notification_props = { - "hostname" => $hostname, + "hostname" => $hostname, "error-message" => $err, - "guest-table" => build_guest_table($tasklist), - "logs" => $text_log_part, - "status-text" => $status_text, - "total-time" => $total_time, + "guest-table" => build_guest_table($tasklist), + "logs" => $text_log_part, + "status-text" => $status_text, + "total-time" => $total_time, + "total-size" => $total_size, }; my $fields = { -- 2.39.2