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 961E7BF976 for ; Mon, 8 Jan 2024 11:44:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6D455A48A for ; Mon, 8 Jan 2024 11:44:16 +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 ; Mon, 8 Jan 2024 11:44:15 +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 F3F6C44D98 for ; Mon, 8 Jan 2024 11:44:14 +0100 (CET) Message-ID: Date: Mon, 8 Jan 2024 11:44:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: de-AT, en-US To: pve-devel@lists.proxmox.com References: <20231214141154.279100-1-l.wagner@proxmox.com> From: Lukas Wagner In-Reply-To: <20231214141154.279100-1-l.wagner@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: Re: [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: Mon, 08 Jan 2024 10:44:46 -0000 ping On 12/14/23 15:11, Lukas Wagner wrote: > 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 = < {{error-message}} > {{heading-1 "Details"}} > {{table guest-table}} > - > +{{#verbatim}} > Total running time: {{duration total-time}} > - > +Total size: {{human-bytes total-size}} > +{{/verbatim}} > {{heading-1 "Logs"}} > {{verbatim-monospaced logs}} > EOT > @@ -456,7 +459,7 @@ sub send_notification { > my $mode = $opts->{"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 = { -- - Lukas