From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 70F391FF37F for ; Thu, 18 Apr 2024 12:17:42 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A79641A46C; Thu, 18 Apr 2024 12:17:43 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com Date: Thu, 18 Apr 2024 12:17:06 +0200 Message-Id: <20240418101706.237597-11-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240418101706.237597-1-l.wagner@proxmox.com> References: <20240418101706.237597-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.002 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 Subject: [pbs-devel] [PATCH proxmox-backup v5 10/10] proxmox-backup-mgr: gc jobs: pretty-print bytes/duration/timestamps X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Signed-off-by: Lukas Wagner --- pbs-tools/src/format.rs | 14 +++++++++++++- src/bin/proxmox-backup-manager.rs | 31 ++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/pbs-tools/src/format.rs b/pbs-tools/src/format.rs index c208d8cb..bc9f20a8 100644 --- a/pbs-tools/src/format.rs +++ b/pbs-tools/src/format.rs @@ -1,9 +1,11 @@ use std::borrow::Borrow; +use std::time::Duration; -use anyhow::Error; +use anyhow::{Context, Error}; use serde_json::Value; use proxmox_human_byte::HumanByte; +use proxmox_time::TimeSpan; pub fn strip_server_file_extension(name: &str) -> &str { if name.ends_with(".didx") || name.ends_with(".fidx") || name.ends_with(".blob") { @@ -64,3 +66,13 @@ pub fn render_bytes_human_readable(value: &Value, _record: &Value) -> Result Result { + if val.is_null() { + return Ok(String::new()); + } + let duration = val.as_u64().context("not a number")?; + let time_span = TimeSpan::from(Duration::from_secs(duration)); + + Ok(format!("{time_span}")) +} diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs index 94fc6b2f..28271cb4 100644 --- a/src/bin/proxmox-backup-manager.rs +++ b/src/bin/proxmox-backup-manager.rs @@ -115,7 +115,36 @@ async fn garbage_collection_list_jobs(param: Value) -> Result { let mut data = result["data"].take(); let return_type = &api2::admin::gc::API_METHOD_LIST_ALL_GC_JOBS.returns; - let options = default_table_format_options(); + use pbs_tools::format::{render_bytes_human_readable, render_duration, render_epoch}; + let options = default_table_format_options() + .column(ColumnConfig::new("store")) + .column( + ColumnConfig::new("last-run-endtime") + .right_align(false) + .renderer(render_epoch), + ) + .column( + ColumnConfig::new("duration") + .right_align(false) + .renderer(render_duration), + ) + .column( + ColumnConfig::new("removed-bytes") + .right_align(false) + .renderer(render_bytes_human_readable), + ) + .column( + ColumnConfig::new("pending-bytes") + .right_align(false) + .renderer(render_bytes_human_readable), + ) + .column(ColumnConfig::new("last-run-state")) + .column(ColumnConfig::new("schedule")) + .column( + ColumnConfig::new("next-run") + .right_align(false) + .renderer(render_epoch), + ); format_and_print_result_full(&mut data, return_type, &output_format, &options); -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel