From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH manager 1/2] fix #5067: vzdump: include total backup size in notification
Date: Mon, 8 Jan 2024 11:44:13 +0100 [thread overview]
Message-ID: <d0b4642a-4f1d-48f7-98d4-d6feecb29825@proxmox.com> (raw)
In-Reply-To: <20231214141154.279100-1-l.wagner@proxmox.com>
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 <l.wagner@proxmox.com>
> ---
> 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 = <<EOT;
> {{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
next prev parent reply other threads:[~2024-01-08 10:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 14:11 Lukas Wagner
2023-12-14 14:11 ` [pve-devel] [PATCH manager 2/2] vzdump: make helper functions for sending notifications private Lukas Wagner
2024-01-08 10:44 ` Lukas Wagner [this message]
2024-01-29 9:38 ` [pve-devel] applied-series: [PATCH manager 1/2] fix #5067: vzdump: include total backup size in notification Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d0b4642a-4f1d-48f7-98d4-d6feecb29825@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox